-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
44 lines (36 loc) · 888 Bytes
/
main.c
File metadata and controls
44 lines (36 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "oam.h"
#include "logmsg.h"
#include <stdio.h>
#include <sys/queue.h>
#include <pcap.h>
int test(void)
{
char errbuf[256] = "";
pcap_t* pcap = pcap_open_live("enp12s0", 1500, 1, 0, errbuf);
pcap_set_promisc(pcap, 1);
if( !pcap ){
std_errmsg("pcap_open_live failed");
return -1;
}
while( 1 ){
oam_frame_t* frame;
struct pcap_pkthdr hdr;
uint8_t* pkt = pcap_next(pcap, &hdr);
oampdu_parse(&frame, pkt, hdr.len);
if( frame ){
char buf[65536] = "";
if( frame->pdu.hdr.opcode ){
oampdu_dump(frame, buf, sizeof(buf) - 1);
printf("%s\n", buf);
}
oampdu_free_frame(&frame);
}
}
//pcap_loop(pcap, 0, pcap_cb, NULL);
pcap_close(pcap);
return 0;
}
int main(int argc, char *argv[])
{
test();
}