edonkey.c 15 KB
Newer Older
1 2 3
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
's avatar
committed
4 5 6 7 8 9
#include <stdlib.h>
#include <stdio.h>
#include <sys/shm.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
's avatar
committed
10

's avatar
committed
11 12 13 14 15 16 17 18
#include "mapidflib.h"
#include "mapidlib.h"
#include "mapidevices.h"
#include "mapid.h"
#include "fhelp.h"
#include "debug.h"
#include "mapiipc.h"
#include "mstring.h"
's avatar
committed
19 20

#include <pcap.h>
's avatar
committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include <netinet/in.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <time.h>

#include "edonkey.h"
's avatar
committed
37
#include "log.h"
38
#include "trackflib.h"
's avatar
committed
39 40 41 42 43 44 45

struct filters {
	int protocol;
	unsigned int saddr;
	unsigned int daddr;
	uint16_t sp;
	uint16_t dp;
's avatar
committed
46
	struct timeval last_timestamp;
's avatar
committed
47 48 49 50 51 52 53 54
	struct filters *next;
};

struct list{
	struct filters *head;
	struct filters *tail;
};

's avatar
committed
55
/*
's avatar
committed
56 57
int isEdonkey(int, char);
unsigned int getSize(char *);
's avatar
committed
58
*/
's avatar
committed
59
struct mapid_edonkey {
's avatar
committed
60 61
	int *shift[1];
	int *skip[1];
's avatar
committed
62
	struct list **edonkeylist;
's avatar
committed
63
};
's avatar
committed
64
/*
's avatar
committed
65 66 67 68 69 70
struct edonkey_header
{
	char protocol;
	char size[4];
	char type;
};
's avatar
committed
71
*/
's avatar
committed
72
char edonkey_string[] = "\x03\x02\x00\x70\x72\x01\x00\x00\x00";
's avatar
committed
73
int isEdonkeyString(mapidflib_function_instance_t *instance, unsigned char *pkt, unsigned int len);
's avatar
committed
74

75
static int edonkey_init(mapidflib_function_instance_t *instance, MAPI_UNUSED int fd)
's avatar
committed
76
{
's avatar
committed
77 78
	int i = 0;

's avatar
committed
79
	instance->internal_data = malloc(sizeof(struct mapid_edonkey));
's avatar
committed
80 81 82 83 84 85 86
	((struct mapid_edonkey*)instance->internal_data)->edonkeylist = (struct list**)malloc(sizeof(struct list*)*HASHTABLESIZE);
	memset(((struct mapid_edonkey*)instance->internal_data)->edonkeylist, 0, (sizeof(struct list*)*HASHTABLESIZE));
	for(i = 0; i < HASHTABLESIZE; i++) {
		((struct mapid_edonkey*)instance->internal_data)->edonkeylist[i] = (struct list*)malloc(sizeof(struct list));
		((struct mapid_edonkey*)instance->internal_data)->edonkeylist[i]->head = NULL;
		((struct mapid_edonkey*)instance->internal_data)->edonkeylist[i]->tail = NULL;
	}
's avatar
committed
87

's avatar
committed
88 89 90
	((struct mapid_edonkey*)instance->internal_data)->shift[0] = make_shift(edonkey_string, 9);
	((struct mapid_edonkey*)instance->internal_data)->skip[0] = make_skip(edonkey_string, 9);

's avatar
committed
91 92 93 94
	return 0;
}	


's avatar
committed
95 96 97 98 99 100
int isEdonkeyString(mapidflib_function_instance_t *instance, unsigned char *pkt, unsigned int len) {
	
	if(len < 9)
		return -1;
	
	if(len >= 100) {
's avatar
committed
101
		if(mSearch((char *)(pkt), 100, edonkey_string, 9,
's avatar
committed
102 103 104 105 106 107 108
					((struct mapid_edonkey *)instance->internal_data)->skip[0],
					((struct mapid_edonkey *)instance->internal_data)->shift[0]))
		{
			return 0;
		}
	}
	else {
's avatar
committed
109
		if(mSearch((char *)(pkt), len, edonkey_string, 9,
's avatar
committed
110 111 112 113 114 115 116 117 118 119 120
					((struct mapid_edonkey *)instance->internal_data)->skip[0],
					((struct mapid_edonkey *)instance->internal_data)->shift[0]))
		{
			return 0;
		}
	}

	return -1;

}

's avatar
committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
int isEdonkey(int proto, char c)
{
	if(proto == 6)
	{
		switch(c)
		{
			/* Client <-> Server */
			case((char)EDONKEY_PROTO_EDONKEY):
			case((char)EDONKEY_PROTO_EMULE_EXT):
			case((char)EDONKEY_PROTO_EMULE_COMP):
			case((char)EDONKEY_MSG_HELLO):
			case((char)EDONKEY_MSG_BAD_PROTO):
			case((char)EDONKEY_MSG_GET_SERVER_LIST):
			case((char)EDONKEY_MSG_OFFER_FILES):
			case((char)EDONKEY_MSG_SEARCH_FILES):
			case((char)EDONKEY_MSG_DISCONNECT):
			case((char)EDONKEY_MSG_GET_SOURCES):
			case((char)EDONKEY_MSG_SEARCH_USER):
			case((char)EDONKEY_MSG_CLIENT_CB_REQ):
			case((char)EDONKEY_MSG_MORE_RESULTS):
			case((char)EDONKEY_MSG_SERVER_LIST):
			case((char)EDONKEY_MSG_SEARCH_FILE_RESULTS):
			case((char)EDONKEY_MSG_SERVER_STATUS):
			case((char)EDONKEY_MSG_SERVER_CB_REQ):
			case((char)EDONKEY_MSG_CALLBACK_FAIL):
			case((char)EDONKEY_MSG_SERVER_MESSAGE):
			case((char)EDONKEY_MSG_ID_CHANGE):
			case((char)EDONKEY_MSG_SERVER_INFO_DATA):
			case((char)EDONKEY_MSG_FOUND_SOURCES):
			case((char)EDONKEY_MSG_SEARCH_USER_RESULTS):
				return 1;
			
			/* Client <-> Client */
			case((char)EDONKEY_MSG_HELLO_CLIENT):
			case((char)EDONKEY_MSG_SENDING_PART):
			case((char)EDONKEY_MSG_REQUEST_PARTS):
			case((char)EDONKEY_MSG_NO_SUCH_FILE):
			case((char)EDONKEY_MSG_END_OF_DOWNLOAD):
			case((char)EDONKEY_MSG_VIEW_FILES):
			case((char)EDONKEY_MSG_VIEW_FILES_ANSWER):
			case((char)EDONKEY_MSG_HELLO_ANSWER):
			case((char)EDONKEY_MSG_NEW_CLIENT_ID):
			case((char)EDONKEY_MSG_CLIENT_MESSAGE):
			case((char)EDONKEY_MSG_FILE_STATUS_REQUEST):
			case((char)EDONKEY_MSG_FILE_STATUS):
			case((char)EDONKEY_MSG_HASHSET_REQUEST):
			case((char)EDONKEY_MSG_HASHSET_ANSWER):
			case((char)EDONKEY_MSG_SLOT_REQUEST):
			case((char)EDONKEY_MSG_SLOT_GIVEN):
			case((char)EDONKEY_MSG_SLOT_RELEASE):
			case((char)EDONKEY_MSG_SLOT_TAKEN):
			case((char)EDONKEY_MSG_FILE_REQUEST):
			case((char)EDONKEY_MSG_FILE_REQUEST_ANSWER):
			case((char)EDONKEY_MSG_GET_SHARED_DIRS):
			case((char)EDONKEY_MSG_GET_SHARED_FILES):
			case((char)EDONKEY_MSG_SHARED_DIRS):
			case((char)EDONKEY_MSG_SHARED_FILES):
			case((char)EDONKEY_MSG_SHARED_DENIED):
				return 2;
			
			/* EMULE EXTENSIONS */
			case((char)EMULE_MSG_HELLO_ANSWER):
			case((char)EMULE_MSG_SOURCES_REQUEST):
			case((char)EMULE_MSG_SOURCES_ANSWER):
				return 3;
		}
	}
	else if(proto == 17)	// UDP
	{
		switch(c)
		{
			/* EDONKEY UDP MESSAGES */
			case((char)EDONKEY_MSG_UDP_SERVER_STATUS_REQUEST):
			case((char)EDONKEY_MSG_UDP_SERVER_STATUS):
			case((char)EDONKEY_MSG_UDP_SEARCH_FILE):
			case((char)EDONKEY_MSG_UDP_SEARCH_FILE_RESULTS):
			case((char)EDONKEY_MSG_UDP_GET_SOURCES):
			case((char)EDONKEY_MSG_UDP_FOUND_SOURCES):
			case((char)EDONKEY_MSG_UDP_CALLBACK_REQUEST):
			case((char)EDONKEY_MSG_UDP_CALLBACK_FAIL):
			case((char)EDONKEY_MSG_UDP_SERVER_LIST):
			case((char)EDONKEY_MSG_UDP_GET_SERVER_INFO):
			case((char)EDONKEY_MSG_UDP_SERVER_INFO):
			case((char)EDONKEY_MSG_UDP_GET_SERVER_LIST):
				return 4;
	
			/* EMULE UDP EXTENSIONS */
			case((char)EMULE_MSG_UDP_REASKFILEPING):
			case((char)EMULE_MSG_UDP_REASKACK):
			case((char)EMULE_MSG_UDP_FILE_NOT_FOUND):
				case((char)EMULE_MSG_UDP_QUEUE_FULL):
				return 5;
			
			/* OVERNET UDP EXTENSIONS */
				case((char)OVERNET_MSG_UDP_CONNECT):
			case((char)OVERNET_MSG_UDP_CONNECT_REPLY):
			case((char)OVERNET_MSG_UDP_PUBLICIZE):
			case((char)OVERNET_MSG_UDP_PUBLICIZE_ACK):
			case((char)OVERNET_MSG_UDP_SEARCH):
			case((char)OVERNET_MSG_UDP_SEARCH_NEXT):
				case((char)OVERNET_MSG_UDP_SEARCH_INFO):
			case((char)OVERNET_MSG_UDP_SEARCH_RESULT):
			case((char)OVERNET_MSG_UDP_SEARCH_END):
			case((char)OVERNET_MSG_UDP_PUBLISH):
				case((char)OVERNET_MSG_UDP_PUBLISH_ACK):
				case((char)OVERNET_MSG_UDP_IDENTIFY_REPLY):
				case((char)OVERNET_MSG_UDP_IDENTIFY_ACK):
				case((char)OVERNET_MSG_UDP_FIREWALL_CONNECTION):
					case((char)OVERNET_MSG_UDP_FIREWALL_CONNECTION_ACK):
				case((char)OVERNET_MSG_UDP_FIREWALL_CONNECTION_NACK):
			case((char)OVERNET_MSG_UDP_IP_QUERY):
				case((char)OVERNET_MSG_UDP_IP_QUERY_ANSWER):
			case((char)OVERNET_MSG_UDP_IP_QUERY_END):
			case((char)OVERNET_MSG_UDP_IDENTIFY):
				return 6;
			
		}
	}
	
	switch(c)
	{
		/* EDONKEY SEARCH TYPES */
		case((char)EDONKEY_SEARCH_BOOL):
		case((char)EDONKEY_SEARCH_NAME):
		case((char)EDONKEY_SEARCH_META):
		case((char)EDONKEY_SEARCH_LIMIT):
			return 7;
	}

	return 0;
}

unsigned int getSize(char *p)
{
	unsigned int size = 0;
	int i = 0;
	int base = 1;
	
	for(i = 0; i < 4; i++)
	{
		size += p[i]&0x0f * base;
		base = base * 16;

		size += (p[i]>>4) * base;

		base = base * 16;
	}

	return size;
}

static int edonkey_process(mapidflib_function_instance_t *instance,
's avatar
committed
273 274
			MAPI_UNUSED unsigned char* dev_pkt,
			unsigned char* pkt,
's avatar
committed
275 276 277
			mapid_pkthdr_t* pkt_head)
{
	struct filters *temp = NULL, *prev = NULL, *new = NULL;
's avatar
committed
278
	unsigned char *p = NULL;
's avatar
committed
279
	
's avatar
committed
280
	struct list **edonkeylist = ((struct mapid_edonkey*)instance->internal_data)->edonkeylist;
's avatar
committed
281 282
	uint16_t ethertype;
	struct ether_header *ep = NULL;
's avatar
committed
283 284 285 286
	struct pos_header {
		uint16_t af;
		uint16_t cf;
	}	*pp = NULL;
's avatar
committed
287 288 289 290
	struct iphdr *iph = NULL;
	struct tcphdr *tcph = NULL;
	struct udphdr *udph = NULL;
	int ether_len =0 , ip_len = 0, tcp_len = 0, udp_len = 0;
's avatar
committed
291
	struct timeval ts;
's avatar
committed
292
	unsigned int len = pkt_head->caplen;
's avatar
committed
293

's avatar
committed
294 295
	struct vlan_802q_header *vlan_header;

's avatar
committed
296 297 298
	struct edonkey_header *edonkey_h;

	unsigned int saddr, daddr;
's avatar
committed
299 300
	struct in_addr source, dest;

's avatar
committed
301 302
	uint16_t sp, dp;

's avatar
committed
303
	unsigned int hashval = 0;
's avatar
committed
304
	
305 306 307
	int pkt_color = pkt_head->color;

	if(pkt_color != 0 && pkt_color != EDONKEY_COLOR) {
308 309 310
		return 0;
	}

's avatar
committed
311 312
	p = pkt;

's avatar
committed
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
	switch(instance->hwinfo->link_type) {
		case DLT_EN10MB:
				// lay the Ethernet header struct over the packet data
				ep = (struct ether_header *)p;
				ether_len = sizeof(struct ether_header);

				// skip ethernet header
				p += sizeof(struct ether_header);
				len -= sizeof(struct ether_header);

				ethertype = ntohs(ep->ether_type);

				if(ethertype  == ETHERTYPE_8021Q) {
					vlan_header = (struct vlan_802q_header*)p;
					ethertype = ntohs(vlan_header->ether_type);
					p += sizeof(struct vlan_802q_header);
				}
				
				if(ethertype == MPLS_MASK) {
					p += 4;			
				}
				else if(ethertype != ETHERTYPE_IP) {
					return 0;
				}
			break;
		case DLT_CHDLC:
				pp = (struct pos_header *)p;
				ether_len = sizeof(struct pos_header);

				p += sizeof(struct pos_header);
				len -= sizeof(struct pos_header);

				ethertype = ntohs(pp->cf);

				if (ethertype != ETHERTYPE_IP) {
					return 0;
				}
			break;
		default:
			//DEBUG_CMD(Debug_Message("Link layer not supported"));
			return 0;
's avatar
committed
354 355 356 357 358 359 360 361 362
	}
	
	// IP header struct over the packet data;
	iph = (struct iphdr*)p;
	ip_len = (iph->ihl & 0xf) * 4;

	saddr = *((unsigned int *)&(iph->saddr));
	daddr = *((unsigned int *)&(iph->daddr));
	
's avatar
committed
363 364 365
	source.s_addr = (unsigned long int)iph->saddr ;
	dest.s_addr = (unsigned long int)iph->daddr;

's avatar
committed
366
	p += iph->ihl * 4;
's avatar
committed
367
	len -= iph->ihl *4;
's avatar
committed
368

's avatar
committed
369
	
's avatar
committed
370
	hashval = (saddr + daddr) % HASHTABLESIZE;
's avatar
committed
371 372 373 374 375 376 377 378

	if(iph->protocol == 6)	// TCP
	{
		tcph = (struct tcphdr *)p;
		tcp_len = tcph->doff * 4;

		sp = ntohs(tcph->source);
		dp = ntohs(tcph->dest);
's avatar
committed
379 380 381 382

		p += tcph->doff * 4;
		len -= tcph->doff * 4;

's avatar
committed
383
		if((unsigned int)(p - pkt) == pkt_head->caplen) {
's avatar
committed
384 385 386
			return 0;
		}

's avatar
committed
387 388 389 390 391 392 393 394
	}
	else if(iph->protocol == 17)	// UDP
	{
		udph = (struct udphdr *)p;
		udp_len = sizeof(struct udphdr);

		sp = ntohs(udph->source);
		dp = ntohs(udph->dest);
's avatar
committed
395 396 397 398

		p += sizeof(struct udphdr);
		len -= sizeof(struct udphdr);

's avatar
committed
399
		if((unsigned int)(p - pkt) == pkt_head->caplen) {
's avatar
committed
400 401
			return 0;
		}
's avatar
committed
402 403 404 405 406 407
	}
	else
	{
		return 0;
	}

's avatar
committed
408 409
	gettimeofday(&ts, NULL);

's avatar
committed
410
	for(temp = edonkeylist[hashval]->head, prev = edonkeylist[hashval]->head; temp != NULL; prev = temp, temp = temp->next)
's avatar
committed
411 412 413 414 415 416 417 418
	{
			if(temp->protocol == iph->protocol &&
					(
					(temp->saddr == saddr && temp->daddr == daddr && temp->sp == sp && temp->dp == dp)
					||
					(temp->saddr == daddr && temp->daddr == saddr && temp->sp == dp && temp->dp == sp))
			  )
			{
's avatar
committed
419 420
				gettimeofday(&(temp->last_timestamp), NULL);
				
's avatar
committed
421
				if(iph->protocol == 6 && tcph->fin) {
's avatar
committed
422 423
					if(temp == edonkeylist[hashval]->head) {
						edonkeylist[hashval]->head = temp->next;
's avatar
committed
424 425 426 427
					}
					else {
						prev->next = temp->next;
					}
's avatar
committed
428 429 430
					temp->next = NULL;
					free(temp);
				}
431 432 433
				
				pkt_head->color = EDONKEY_COLOR;

's avatar
committed
434 435
				return 1;
			}
's avatar
committed
436
			else if(ts.tv_sec - temp->last_timestamp.tv_sec > 60) {
's avatar
committed
437 438
				if(temp == edonkeylist[hashval]->head) {
					edonkeylist[hashval]->head = temp->next;
's avatar
committed
439 440 441 442 443 444 445
				}
				else {
					prev->next = temp->next;
				}
				temp->next = NULL;
				free(temp);
			}
's avatar
committed
446 447
	}

's avatar
committed
448 449 450 451 452 453 454 455 456
	if(isEdonkeyString(instance, p, len) >= 0) { 
		new = (struct filters*)malloc(sizeof(struct filters));
		
		new->protocol = iph->protocol;
		new->saddr = saddr;
		new->daddr = daddr;
		new->sp = sp;
		new->dp = dp;
		gettimeofday(&(new->last_timestamp), NULL);
457 458
	
#ifdef __TRACKFLIB_LOGGING__
's avatar
committed
459
		write_to_log("eDonkey", "03020070720100000", iph->protocol, source, sp, dest, dp, p, len);
460
#endif
's avatar
committed
461 462 463 464 465 466 467 468
		for(temp = edonkeylist[hashval]->head; temp != NULL; temp = temp->next) {
			if(new->protocol == temp->protocol && (
						(new->saddr == temp->saddr && new->daddr == temp->daddr && new->sp == temp->sp && new->dp == temp->dp) 
						||
						(new->daddr == temp->saddr && new->saddr == temp->daddr && new->dp == temp->sp && new->sp == temp->dp)
						)
					)
			{
469
				pkt_head->color = EDONKEY_COLOR;
's avatar
committed
470 471 472 473 474 475
				return 1;
			}
		}
		
		new->next = edonkeylist[hashval]->head;
		edonkeylist[hashval]->head = new;
476 477
	
		pkt_head->color = EDONKEY_COLOR;
's avatar
committed
478 479
		return 1;
	}
's avatar
committed
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
	if(iph->protocol == 6)
	{
		edonkey_h = (struct edonkey_header *)p;
		
		if(edonkey_h->protocol != (char)0xE3 && edonkey_h->protocol != (char)0xC5 && edonkey_h->protocol != (char)0xd4)
		{
			return 0;
		}
		
		if(getSize(edonkey_h->size) != (pkt_head->wlen - ether_len - ip_len - tcp_len - 5))
			return 0;

		
		if(isEdonkey(iph->protocol, edonkey_h->type) == 0)
			return 0;
	}
	else if(iph->protocol == 17)
	{
		edonkey_h = (struct edonkey_header *)p;
	
		if(edonkey_h->protocol != (char)0xe3 && edonkey_h->protocol != (char)0xC5 && edonkey_h->protocol != (char)0xd4)
		{

			return 0;
		}
		
's avatar
committed
506
		if(getSize(edonkey_h->size) != (pkt_head->caplen - ether_len - ip_len - udp_len - 5))
's avatar
committed
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
		{
			if(isEdonkey(iph->protocol, edonkey_h->size[0]) == 0)
				return 0;
		}

		
		if(isEdonkey(iph->protocol, edonkey_h->type) == 0)
			return 0;
	}
	else
	{
		return 0;
	}
		
	new = (struct filters*)malloc(sizeof(struct filters));
	
	new->protocol = iph->protocol;
	new->saddr = saddr;
	new->daddr = daddr;
	new->sp = sp;
	new->dp = dp;
's avatar
committed
528
	gettimeofday(&(new->last_timestamp), NULL);
529
#ifdef __TRACKFLIB_LOGGING__	
's avatar
committed
530
	write_to_log("eDonkey", "No String match", iph->protocol, source, sp, dest, dp, p, len);
531
#endif
's avatar
committed
532
	for(temp = edonkeylist[hashval]->head; temp != NULL; temp = temp->next)
's avatar
committed
533 534 535 536 537 538 539 540
	{
		if(new->protocol == temp->protocol && (
				(new->saddr == temp->saddr && new->daddr == temp->daddr && new->sp == temp->sp && new->dp == temp->dp) 
				||
				(new->daddr == temp->saddr && new->saddr == temp->daddr && new->dp == temp->sp && new->sp == temp->dp)
				)
			)
		{
's avatar
committed
541 542
			pkt_head->color = EDONKEY_COLOR;
			free(new);
's avatar
committed
543 544 545
			return 1;
		}
	}
's avatar
committed
546 547 548

	new->next = edonkeylist[hashval]->head;
	edonkeylist[hashval]->head = new;
's avatar
committed
549 550
	pkt_head->color = EDONKEY_COLOR;
			
's avatar
committed
551 552 553 554 555 556
	return 1;
}

static int edonkey_cleanup(mapidflib_function_instance_t *instance) 
{
	struct filters *temp = NULL, *tmp = NULL;
's avatar
committed
557
	int i = 0;
's avatar
committed
558 559 560
	
  if(instance->internal_data != NULL){

's avatar
committed
561 562 563 564 565 566 567 568
	  for(i = 0; i < HASHTABLESIZE; i++) {
		  temp = ((struct mapid_edonkey*)instance->internal_data)->edonkeylist[i]->head;
		  
		  while(temp != NULL) {
			  tmp = temp;
			  temp = temp->next;
			  free(tmp);
		  }
569
		  free(((struct mapid_edonkey*)instance->internal_data)->edonkeylist[i]);
's avatar
committed
570
	  }
571 572 573

	  free(((struct mapid_edonkey*)instance->internal_data)->shift[0]);
	  free(((struct mapid_edonkey*)instance->internal_data)->skip[0]);
's avatar
committed
574 575 576
	  
	  free(((struct mapid_edonkey*)instance->internal_data)->edonkeylist);
	  free(instance->internal_data);
's avatar
committed
577 578 579 580 581 582 583 584 585 586 587 588 589
  }
  return 0;
}

static mapidflib_function_def_t finfo={
  "",
  "TRACK_EDONKEY",
  "Searches for eDonkey packets\n",
  "",
  MAPI_DEVICE_ALL,
  MAPIRES_NONE,
  0, //shm size
  0, //modifies_pkts
590 591
  1, //filters packets
  MAPIOPT_NONE,
's avatar
committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
  NULL,
  edonkey_init,
  edonkey_process,
  NULL, //get_result
  NULL, //reset
  edonkey_cleanup,
  NULL, //client_init
  NULL, //client_read_result
  NULL  //client_cleanup
};

mapidflib_function_def_t* edonkey_get_funct_info();
mapidflib_function_def_t* edonkey_get_funct_info() {
  return &finfo;
};