gre.c

来自「Firestorm NIDS是一个性能非常高的网络入侵检测系统 (NIDS)。目」· C语言 代码 · 共 80 行

C
80
字号
#include <stdlib.h>#include <firestorm.h>#include <packet.h>#include <args.h>#include <plugin.h>#include <alert.h>#include <signature.h>#include <decode.h>#include <preproc.h>PLUGIN_STD_DEFS();proc_dispatch dispatch;/* GRE: Generic routing encapsulation */void gre_decode(struct packet *);struct proto gre_p=init_proto("gre", gre_decode, NULL);struct proto_req gre_r[]={	proto_request("ip", 47),	null_request()};void gre_decode(struct packet *p){	struct proto_child *pc;	struct layer *l=&p->layer[p->llen];	if ( (p->layer[p->llen+1].h.raw=		l->h.raw+sizeof(struct pkt_grehdr))		> p->end ) return;	p->llen++;	if ( p->llen >= PKT_LAYERS ) return;	for(pc=l->proto->children; pc; pc=pc->next)	{		if ( l->h.gre->proto == pc->id ) {			p->layer[p->llen].flags=0;			p->layer[p->llen].session=NULL;			p->layer[p->llen].proto=pc->proto;			pc->proto->decode(p);			return;		}	}	if ( p->layer[p->llen].h.raw<p->end )		p->layer[p->llen++].proto=NULL;	dispatch(p);}int PLUGIN_DECODE (struct decode_api *d){	int ok=0;	object_check(d);	dispatch=d->dispatch;	ok+=d->decode_add(&gre_p, gre_r);	return (ok) ? PLUGIN_ERR_OK : PLUGIN_ERR_FAIL;}int PLUGIN_INIT (struct plugin_in *in, struct plugin_out *out){	plugin_check(in, out);	PLUGIN_ID("decode.gre", "Generic Routing Encapsulation");	PLUGIN_VERSION(2, 0);	PLUGIN_AUTHOR("Gianni Tedesco", "gianni@scaramanga.co.uk");	PLUGIN_LICENSE("GPL");	return PLUGIN_ERR_OK;}int PLUGIN_UNLOAD (int code) {	return PLUGIN_ERR_OK;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?