59 |
59 |
char debuglevel[NPFD];
|
60 |
60 |
char *progname;
|
61 |
61 |
char *mgmt;
|
|
62 |
char ether_type[2];
|
|
63 |
unsigned char ether_num_bytes;
|
|
64 |
char ether_bytes[10];
|
62 |
65 |
int mgmtmode=0700;
|
63 |
66 |
#define LR 0
|
64 |
67 |
#define RL 1
|
... | ... | |
546 |
549 |
|
547 |
550 |
void handle_packet(int dir,const unsigned char *buf,int size)
|
548 |
551 |
{
|
|
552 |
int i;
|
|
553 |
|
549 |
554 |
/* MTU */
|
550 |
555 |
/* if the packet is incosistent with the MTU of the line just drop it */
|
551 |
556 |
if (min_wirevalue(markov_current,MTU,dir) > 0 && size > min_wirevalue(markov_current,MTU,dir))
|
552 |
557 |
return;
|
553 |
|
|
|
558 |
|
|
559 |
/* if the packet has the whitelisted ethertype or etherbytes just send it */
|
|
560 |
if ((ether_type[0] == 0 && ether_type[1] == 0) || (size < 16))
|
|
561 |
goto wire_check;
|
|
562 |
|
|
563 |
if ((ether_type[0] != buf[14]) || (ether_type[1] != buf[15]))
|
|
564 |
goto wire_check;
|
|
565 |
|
|
566 |
if (ether_num_bytes == 0) {
|
|
567 |
writepacket(dir,buf,size);
|
|
568 |
return;
|
|
569 |
} else {
|
|
570 |
if (size < 17)
|
|
571 |
goto wire_check;
|
|
572 |
|
|
573 |
for (i = 0; i < ether_num_bytes; i++) {
|
|
574 |
if (ether_bytes[i] != buf[16])
|
|
575 |
continue;
|
|
576 |
|
|
577 |
writepacket(dir,buf,size);
|
|
578 |
return;
|
|
579 |
}
|
|
580 |
}
|
|
581 |
|
554 |
582 |
/* LOSS */
|
555 |
583 |
/* Total packet loss */
|
|
584 |
wire_check:
|
556 |
585 |
if (min_wirevalue(markov_current,LOSS,dir) >= 100.0)
|
557 |
586 |
return;
|
558 |
587 |
/* probabilistic loss */
|
... | ... | |
1425 |
1454 |
"\t--pidfile pidfile\n"
|
1426 |
1455 |
"\t--blink blinksocket\n"
|
1427 |
1456 |
"\t--blinkid blink_id_string\n"
|
|
1457 |
"\t--ether ether_type<:byte><:byte>\n"
|
1428 |
1458 |
,progname);
|
1429 |
1459 |
exit (1);
|
1430 |
1460 |
}
|
... | ... | |
1436 |
1466 |
int option_index;
|
1437 |
1467 |
int mgmtindex=-1;
|
1438 |
1468 |
int consoleindex=-1;
|
|
1469 |
char *ptr;
|
1439 |
1470 |
static struct option long_options[] = {
|
1440 |
1471 |
{"help",0 , 0, 'h'},
|
1441 |
1472 |
{"rcfile", 1, 0, 'f'},
|
... | ... | |
1457 |
1488 |
{"pidfile", 1, 0, PIDFILEARG},
|
1458 |
1489 |
{"blink",1,0,LOGSOCKETARG},
|
1459 |
1490 |
{"blinkid",1,0,LOGIDARG},
|
|
1491 |
{"ether", 1, 0, 'e'},
|
1460 |
1492 |
{0,0,0,0}
|
1461 |
1493 |
};
|
1462 |
1494 |
progname=basename(argv[0]);
|
1463 |
1495 |
markov_resize(1);
|
1464 |
|
|
|
1496 |
|
1465 |
1497 |
setsighandlers();
|
1466 |
1498 |
atexit(cleanup);
|
1467 |
|
|
|
1499 |
ether_num_bytes = 0;
|
|
1500 |
memset(ether_bytes, 0, sizeof(ether_bytes));
|
|
1501 |
|
1468 |
1502 |
while(1) {
|
1469 |
1503 |
int c;
|
1470 |
|
c = GETOPT_LONG (argc, argv, "hl:n:d:M:D:m:b:s:c:v:L:f:",
|
|
1504 |
c = GETOPT_LONG (argc, argv, "hnl:d:M:D:m:b:s:c:v:L:f:e:",
|
1471 |
1505 |
long_options, &option_index);
|
1472 |
1506 |
if (c<0)
|
1473 |
1507 |
break;
|
... | ... | |
1511 |
1545 |
case 'N':
|
1512 |
1546 |
nofifo=1;
|
1513 |
1547 |
break;
|
|
1548 |
case 'e':
|
|
1549 |
sscanf(optarg,"%2hhx%2hhx", ðer_type[0], ðer_type[1]);
|
|
1550 |
ptr = optarg;
|
|
1551 |
for (n = 0; n < sizeof(ether_bytes); n++) {
|
|
1552 |
ptr = strchr(ptr, ':');
|
|
1553 |
if (!ptr)
|
|
1554 |
break;
|
|
1555 |
|
|
1556 |
ptr++;
|
|
1557 |
sscanf(ptr, "%hhx", ðer_bytes[n]);
|
|
1558 |
ether_num_bytes++;
|
|
1559 |
}
|
|
1560 |
break;
|
1514 |
1561 |
case 'v':
|
1515 |
1562 |
{
|
1516 |
1563 |
char *colon;
|