zoukankan      html  css  js  c++  java
  • C语言中字符串数组的遍历和比较

    /* 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
    };

    // 自己写的函数,用packetTable中的->_msg, 和上面的_default_packet_types里的元素进行比较,如果相等则跳出,否则继续循环

    boolean pr_get_default_packet_flag_from_msg(PacketFilterMessageTable *packetTable, char **packetType)
    {
        char         *p_msg = NULL;
        wgpr_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] == '') {
            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;
    }

    //调用上述函数的代码片段

                        if(pr_get_default_packet_flag_from_msg(pk_t, &packetType)){
                            is_dflt_packet = TRUE;
                        }

  • 相关阅读:
    模板
    Codeforces Round #598 (Div. 3)
    Codeforces Round #589 (Div. 2)
    日记集
    模板
    Codeforces Round #592 (Div. 2)
    Linux挂载新盘
    VMware实用技巧
    useradd和adduser的区别
    ubuntu VSFTPD搭建FTP服务器 提示530错误
  • 原文地址:https://www.cnblogs.com/kungfupanda/p/4341212.html
Copyright © 2011-2022 走看看