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
|
... | ... | |
524 |
527 |
|
525 |
528 |
void handle_packet(int dir,const unsigned char *buf,int size)
|
526 |
529 |
{
|
|
530 |
int i;
|
|
531 |
|
527 |
532 |
/* MTU */
|
528 |
533 |
/* if the packet is incosistent with the MTU of the line just drop it */
|
529 |
534 |
if (min_wirevalue(markov_current,MTU,dir) > 0 && size > min_wirevalue(markov_current,MTU,dir))
|
530 |
535 |
return;
|
531 |
536 |
|
|
537 |
/* if the packet has the whitelisted ethertype or etherbytes just send it */
|
|
538 |
if ((ether_type[0] == 0 && ether_type[1] == 0) || (size < 16))
|
|
539 |
goto wire_check;
|
|
540 |
|
|
541 |
if ((ether_type[0] != buf[14]) || (ether_type[1] != buf[15]))
|
|
542 |
goto wire_check;
|
|
543 |
|
|
544 |
if (ether_num_bytes == 0) {
|
|
545 |
writepacket(dir,buf,size);
|
|
546 |
return;
|
|
547 |
} else {
|
|
548 |
if (size < 17)
|
|
549 |
goto wire_check;
|
|
550 |
|
|
551 |
for (i = 0; i < ether_num_bytes; i++) {
|
|
552 |
if (ether_bytes[i] != buf[16])
|
|
553 |
continue;
|
|
554 |
|
|
555 |
writepacket(dir,buf,size);
|
|
556 |
return;
|
|
557 |
}
|
|
558 |
}
|
|
559 |
|
532 |
560 |
/* LOSS */
|
533 |
561 |
/* Total packet loss */
|
|
562 |
wire_check:
|
534 |
563 |
if (min_wirevalue(markov_current,LOSS,dir) >= 100.0)
|
535 |
564 |
return;
|
536 |
565 |
/* probabilistic loss */
|
... | ... | |
1391 |
1420 |
"\t--pidfile pidfile\n"
|
1392 |
1421 |
"\t--blink blinksocket\n"
|
1393 |
1422 |
"\t--blinkid blink_id_string\n"
|
|
1423 |
"\t--ether ether_type<:byte><:byte>\n"
|
1394 |
1424 |
,progname);
|
1395 |
1425 |
exit (1);
|
1396 |
1426 |
}
|
... | ... | |
1402 |
1432 |
int option_index;
|
1403 |
1433 |
int mgmtindex=-1;
|
1404 |
1434 |
int consoleindex=-1;
|
|
1435 |
char *ptr;
|
1405 |
1436 |
static struct option long_options[] = {
|
1406 |
1437 |
{"help",0 , 0, 'h'},
|
1407 |
1438 |
{"rcfile", 1, 0, 'f'},
|
... | ... | |
1421 |
1452 |
{"daemon",0 , 0, DAEMONIZEARG},
|
1422 |
1453 |
{"pidfile", 1, 0, PIDFILEARG},
|
1423 |
1454 |
{"blink",1,0,LOGSOCKETARG},
|
1424 |
|
{"blinkid",1,0,LOGIDARG}
|
|
1455 |
{"blinkid",1,0,LOGIDARG},
|
|
1456 |
{"ether", 1, 0, 'e'},
|
1425 |
1457 |
};
|
1426 |
1458 |
progname=basename(argv[0]);
|
1427 |
1459 |
markov_resize(1);
|
1428 |
1460 |
|
1429 |
1461 |
setsighandlers();
|
1430 |
1462 |
atexit(cleanup);
|
|
1463 |
ether_num_bytes = 0;
|
|
1464 |
memset(ether_bytes, 0, sizeof(ether_bytes));
|
1431 |
1465 |
|
1432 |
1466 |
while(1) {
|
1433 |
1467 |
int c;
|
1434 |
|
c = GETOPT_LONG (argc, argv, "hnl:d:M:D:m:b:s:c:v:L:f:",
|
|
1468 |
c = GETOPT_LONG (argc, argv, "hnl:d:M:D:m:b:s:c:v:L:f:e:",
|
1435 |
1469 |
long_options, &option_index);
|
1436 |
1470 |
if (c<0)
|
1437 |
1471 |
break;
|
... | ... | |
1475 |
1509 |
case 'N':
|
1476 |
1510 |
nofifo=1;
|
1477 |
1511 |
break;
|
|
1512 |
case 'e':
|
|
1513 |
sscanf(optarg,"%2hhx%2hhx", ðer_type[0], ðer_type[1]);
|
|
1514 |
ptr = optarg;
|
|
1515 |
for (n = 0; n < sizeof(ether_bytes); n++) {
|
|
1516 |
ptr = strchr(ptr, ':');
|
|
1517 |
if (!ptr)
|
|
1518 |
break;
|
|
1519 |
|
|
1520 |
ptr++;
|
|
1521 |
sscanf(ptr, "%hhx", ðer_bytes[n]);
|
|
1522 |
ether_num_bytes++;
|
|
1523 |
}
|
|
1524 |
break;
|
1478 |
1525 |
case 'v':
|
1479 |
1526 |
{
|
1480 |
1527 |
char *colon;
|