Skip to content

Commit 38036c3

Browse files
committed
chg: [pibs] added option to bypass synseen logic
1 parent 347d6e4 commit 38036c3

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

bin/synseen.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -145,35 +145,37 @@ void synseen_process_frame(pibs_t *pibs, wtap *wth, uint8_t* eth,
145145
uint32_t ip;
146146
struct pcap_pkthdr pchdr;
147147
memcpy(&ip, &ipv4->ip_src, 4);
148-
// Record only source ips where syn flag is set
149-
// TODO check other connection establishment alternatives
150-
if (tcp->th_flags == 2 ){
151-
insert_ip(pibs, ip, wth->rec.ts.secs);
152-
return;
153-
}
148+
if (!pibs->bypass) {
149+
// Record only source ips where syn flag is set
150+
// TODO check other connection establishment alternatives
151+
if (tcp->th_flags == 2 ){
152+
insert_ip(pibs, ip, wth->rec.ts.secs);
153+
return;
154+
}
154155

155-
lastseen = get_last_timestamp(pibs, ip);
156+
lastseen = get_last_timestamp(pibs, ip);
156157

157-
if (lastseen > 0){
158-
HDBG("IP %x %s was already seen before at %ld. Time difference %ld.\n"
159-
, ip, inet_ntoa(ipv4->ip_src), lastseen, wth->rec.ts.secs-lastseen);
160-
return;
161-
}
162-
// TODO keep these IPs in a hashtable and rank them
163-
if (pibs->show_backscatter) {
164-
printf("%ld,%s,%d,%d\n",
165-
wth->rec.ts.secs, inet_ntoa(ipv4->ip_src), tcp->th_flags,
166-
ntohs(tcp->th_sport));
167-
}
168-
//TODO relative time
169-
//Purge old ips?
170-
if (pibs->should_writepcap) {
171-
pchdr.ts.tv_sec = wth->rec.ts.secs;
172-
//TODO other part of the timestamp
173-
pchdr.ts.tv_usec = wth->rec.ts.nsecs / 1000;
174-
pchdr.caplen = wth->rec.rec_header.packet_header.caplen;
175-
pchdr.len = wth->rec.rec_header.packet_header.len;
176-
pcap_dump((u_char*)pibs->dumper, &pchdr, eth);
158+
if (lastseen > 0){
159+
HDBG("IP %x %s was already seen before at %ld. Time difference %ld.\n"
160+
, ip, inet_ntoa(ipv4->ip_src), lastseen, wth->rec.ts.secs-lastseen);
161+
return;
162+
}
163+
// TODO keep these IPs in a hashtable and rank them
164+
if (pibs->show_backscatter) {
165+
printf("%ld,%s,%d,%d\n",
166+
wth->rec.ts.secs, inet_ntoa(ipv4->ip_src), tcp->th_flags,
167+
ntohs(tcp->th_sport));
168+
}
169+
//TODO relative time
170+
//Purge old ips?
171+
if (pibs->should_writepcap) {
172+
pchdr.ts.tv_sec = wth->rec.ts.secs;
173+
//TODO other part of the timestamp
174+
pchdr.ts.tv_usec = wth->rec.ts.nsecs / 1000;
175+
pchdr.caplen = wth->rec.rec_header.packet_header.caplen;
176+
pchdr.len = wth->rec.rec_header.packet_header.len;
177+
pcap_dump((u_char*)pibs->dumper, &pchdr, eth);
178+
}
177179
}
178180
if (pibs->synseen_callback) {
179181
synseen_callback = pibs->synseen_callback;

0 commit comments

Comments
 (0)