亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2040 | 回復(fù): 4
打印 上一主題 下一主題

[網(wǎng)絡(luò)管理] ipt_layer7.c中的master_conntrack與conntrack區(qū)別 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2006-08-18 09:52 |只看該作者 |倒序瀏覽
大家好!

下載netfilter-layer7-v2.3給linux-2.6.17.7打上l7補丁后
linux-2.6.17.7\net\ipv4\netfilter下產(chǎn)生ipt_layer7.c
其中

/* Returns true on match and false otherwise.  */
static int match(/* const */ struct sk_buff *skb,
        const struct net_device *in, const struct net_device *out,
        const struct xt_match *match, const void *matchinfo,
        int offset, unsigned int protoff, int *hotdrop)
{
        struct ipt_layer7_info * info = (struct ipt_layer7_info *)matchinfo;
        enum ip_conntrack_info master_ctinfo, ctinfo;
        struct ip_conntrack *master_conntrack, *conntrack;
        unsigned char * app_data;  
        unsigned int pattern_result, appdatalen;
        regexp * comppattern;

        if(!can_handle(skb)){
                DPRINTK("layer7: This is some protocol I can't handle.\n");
                return info->invert;
        }

        /* Treat parent & all its children together as one connection, except
        for the purpose of setting conntrack->layer7.app_proto in the actual
        connection. This makes /proc/net/ip_conntrack more satisfying. */
        if(!(conntrack = ip_conntrack_get((struct sk_buff *)skb, &ctinfo)) ||
           !(master_conntrack = ip_conntrack_get((struct sk_buff *)skb, &master_ctinfo))) {
                //DPRINTK("layer7: packet is not from a known connection, giving up.\n");
                return info->invert;
        }
        
        /* Try to get a master conntrack (and its master etc) for FTP, etc. */
        while (master_ct(master_conntrack) != NULL)
                master_conntrack = master_ct(master_conntrack);

        /* if we've classified it or seen too many packets */
        if(TOTAL_PACKETS > num_packets ||
           master_conntrack->layer7.app_proto) {
        
                pattern_result = match_no_append(conntrack, master_conntrack, ctinfo, master_ctinfo, info);
        
                /* skb->cb[0] == seen. Avoid doing things twice if there are two l7
                rules. I'm not sure that using cb for this purpose is correct, although
                it says "put your private variables there". But it doesn't look like it
                is being used for anything else in the skbs that make it here. How can
                I write to cb without making the compiler angry? */
                skb->cb[0] = 1; /* marking it seen here is probably irrelevant, but consistant */

                return (pattern_result ^ info->invert);
        }

        if(skb_is_nonlinear(skb)){
                if(skb_linearize(skb, GFP_ATOMIC) != 0){
                        if (net_ratelimit())
                                printk(KERN_ERR "layer7: failed to linearize packet, bailing.\n");
                        return info->invert;
                }
        }
        
        /* now that the skb is linearized, it's safe to set these. */
        app_data = skb->data + app_data_offset(skb);
        appdatalen = skb->tail - app_data;

        spin_lock_bh(&list_lock);
        /* the return value gets checked later, when we're ready to use it */
        comppattern = compile_and_cache(info->pattern, info->protocol);
        spin_unlock_bh(&list_lock);

        /* On the first packet of a connection, allocate space for app data */
        write_lock(&ct_lock);
        if(TOTAL_PACKETS == 1 && !skb->cb[0] && !master_conntrack->layer7.app_data) {
                master_conntrack->layer7.app_data = kmalloc(maxdatalen, GFP_ATOMIC);
                if(!master_conntrack->layer7.app_data){                                                         
                        if (net_ratelimit())
                                printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
                        write_unlock(&ct_lock);
                        return info->invert;
                }

                master_conntrack->layer7.app_data[0] = '\0';
        }
        write_unlock(&ct_lock);

        /* Can be here, but unallocated, if numpackets is increased near
        the beginning of a connection */
        if(master_conntrack->layer7.app_data == NULL)
                return (info->invert); /* unmatched */

        if(!skb->cb[0]){
                int newbytes;
                write_lock(&ct_lock);
                newbytes = add_data(master_conntrack, app_data, appdatalen);
                write_unlock(&ct_lock);

                if(newbytes == 0) { /* didn't add any data */
                        skb->cb[0] = 1;
                        /* Didn't match before, not going to match now */
                        return info->invert;
                }
        }

        /* If looking for "unknown", then never match.  "Unknown" means that
        we've given up; we're still trying with these packets. */
        if(!strcmp(info->protocol, "unknown")) {
                pattern_result = 0;
        /* If the regexp failed to compile, don't bother running it */
        } else if(comppattern && regexec(comppattern, master_conntrack->layer7.app_data)) {
                DPRINTK("layer7: matched %s\n", info->protocol);
                pattern_result = 1;
        } else pattern_result = 0;

        if(pattern_result) {
                write_lock(&ct_lock);
                master_conntrack->layer7.app_proto = kmalloc(strlen(info->protocol)+1, GFP_ATOMIC);
                if(!master_conntrack->layer7.app_proto){
                        if (net_ratelimit())
                                printk(KERN_ERR "layer7: out of memory in match, bailing.\n");
                        write_unlock(&ct_lock);
                        return (pattern_result ^ info->invert);
                }
                strcpy(master_conntrack->layer7.app_proto, info->protocol);
                write_unlock(&ct_lock);
        }

        /* mark the packet seen */
        skb->cb[0] = 1;

        return (pattern_result ^ info->invert);
}



問題:
struct ip_conntrack *master_conntrack, *conntrack;
master_conntrack與conntrack有什么區(qū)別
一直不是很理解



另:有誰對ipt_layer7.c的整個流程比較清楚 麻煩給理請一下
謝謝

論壇徽章:
0
2 [報告]
發(fā)表于 2006-08-23 13:38 |只看該作者
Some protocols open child connections to transfer data. FTP is the most familiar example. If you have loaded the ip_conntrack_ftp kernel module, l7-filter will classify FTP and all its child connections as FTP.

好象這句話可以解釋
大家說說看

論壇徽章:
0
3 [報告]
發(fā)表于 2006-08-24 09:09 |只看該作者
5246378 協(xié)議分析群 我剛建的 對協(xié)議分析感興趣的可以進(jìn)來

論壇徽章:
0
4 [報告]
發(fā)表于 2006-08-24 13:02 |只看該作者
好高深的東西

論壇徽章:
0
5 [報告]
發(fā)表于 2006-08-24 14:15 |只看該作者
有對ipt_layer7.c有研究的 可以進(jìn)QQ群5246378一起研究 共同學(xué)習(xí)進(jìn)步喲
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP