The traversal and comparison of string arrays in C Language

Source: Internet
Author: User

The traversal and comparison of string arrays in C Language

/* The list of known types of default packet .*/
Static char * _ default_packet_types [] = {
"Ddos client quota", "ddos server quota ",
"Blocked ports", "blocked sites ",
"Ip scan", "port scan ",
"Ip source route", "icmp flooding ",
"Ike flooding", "ipsec flooding ",
"Ip spoofing sites", "syn flooding ",
"Udp flooding", "tcp syn checking failed ",
NULL
};

 

// For a self-written function, use-> _ msg in packetTable to compare it with the elements in _ default_packet_types above. If the values are the same, the function jumps out. Otherwise, the loop continues.

Boolean pr_get_default_packet_flag_from_msg (PacketFilterMessageTable * packetTable, char ** packetType)
{
Char * p_msg = NULL;
Wupl_boolean flag = FALSE;
Char ** type_ptr = NULL;

/* Sanity check */
If (! PacketTable ){
Return flag;
}

If (packetTable-> _ tag_id! = FWDENY_TAG |
PacketTable-> _ msg = NULL |
PacketTable-> _ msg [0] = '\ 0 '){
Return flag;
}

P_msg = packetTable-> _ msg;

For (type_ptr = _ default_packet_types; * type_ptr! = NULL; type_ptr ++ ){
If (! Strncasecmp (p_msg, * type_ptr, sizeof (* type_ptr)-1 )){
Flag = TRUE;
Break;
}
}
* PacketType = flag = TRUE? DEFAULTPACKET: DENIEDPACKET;
Return flag;
}

 

// Code snippet for calling the above function

If (pr_get_default_packet_flag_from_msg (pk_t, & packetType )){
Is_dflt_packet = TRUE;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.