462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
+
|
* Header length is usually 20, or 5 32-bit words */
ip_header_length = payload[0] & 0x0F;
header_size = ip_header_length * 4;
/* We're not handling IPV6 packets yet. I'll probably rewrite
* this whole damned thing in C++ first. */
if (version != 4) {
DEBUG(2, "IPV6 packet received and ignored.");
return -1;
}
/* IP Address Bytes 13 - 16 of IP header */
ip->b1 = payload[12];
ip->b2 = payload[13];
ip->b3 = payload[14];
|
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
-
+
-
+
-
+
-
+
|
if (conf.queueno < 0) {
conf.queueno = 1;
fprintf(stderr, "queueno negative - using default");
}
config_setting = config_lookup(config, "blacklistbl");
if (config_setting != NULL) {
parse_config_bl_list(config_setting, 1);
parse_config_bl_list(config_setting, TYPE_BLACKLISTBL);
}
config_setting = config_lookup(config, "whitelistbl");
if (config_setting != NULL) {
parse_config_bl_list(config_setting, 2);
parse_config_bl_list(config_setting, TYPE_WHITELISTBL);
}
config_setting = config_lookup(config, "blacklist");
if (config_setting != NULL) {
parse_config_bl_list(config_setting, 3);
parse_config_bl_list(config_setting, TYPE_BLACKLIST);
}
config_setting = config_lookup(config, "whitelist");
if (config_setting != NULL) {
parse_config_bl_list(config_setting, 4);
parse_config_bl_list(config_setting, TYPE_WHITELIST);
}
}
parse_config_bl_list(config_setting_t *c, int type) {
struct config_entry *ce, *tmp;
int i = 0, len = 0;
|
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
|
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
|
-
+
-
+
-
+
-
+
|
ce->string[blacklistlen - 1] = '\0';
}
#endif
i++;
switch (type) {
case 1:
case TYPE_BLACKLISTBL:
if (conf.blacklistbl == NULL) {
conf.blacklistbl = ce;
continue;
} else {
tmp = conf.blacklistbl;
}
break;
case 2:
case TYPE_WHITELISTBL:
if (conf.whitelistbl == NULL) {
conf.whitelistbl = ce;
continue;
} else {
tmp = conf.whitelistbl;
}
case 3:
case TYPE_BLACKLIST:
fprintf(stderr, "got %s for blacklist\n", ce->string);
if (parse_cidr(ce) == -1) {
fprintf(stderr, "Error parsing CIDR in %s, ignoring\n", ce->string);
free(ce->string);
free(ce);
continue;
}
if (conf.blacklist == NULL) {
conf.blacklist = ce;
continue;
} else {
tmp = conf.blacklist;
}
break;
case 4:
case TYPE_WHITELIST:
if (parse_cidr(ce) == -1) {
fprintf(stderr, "Error parsing CIDR in %s, ignoring\n", ce->string);
free(ce->string);
free(ce);
continue;
}
if (conf.whitelist == NULL) {
|