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

  • 相关阅读:
    ListIterator
    List与set
    iterator取集合元素
    我眼中的AI
    集合的共性方法
    集合转数组
    打开与关闭eclipse的自动补全功能
    Mr_matcher的细节1
    nodelet的应用
    nodelet的理解
  • 原文地址:https://www.cnblogs.com/kungfupanda/p/4341212.html
Copyright © 2011-2022 走看看