1
votes

I have a question about the openflow packets programming. I set up an openflow network , captured the packets between controller and switch by wireshark and save it in a pcap file. Now I want to read this file in a C program and analyze the openflow controlling packet headers. I think one solution is to read the file byte by byte and separate the openflow packets, but it doesn't seem a useful way. so my question is: is there any special library (like pcap) in C language to offer some facilities to read the openflow packet's header and work with them? for more resolution in my question, for example, I can find easily the MAC address of a packet with these instructions using libpcap,

.........
#include "pcap.h"
.........
pcap_t* descr;
const u_char *packet;
struct pcap_pkthdr hdr;     /* pcap.h */
struct ether_header *eptr;  /* net/ethernet.h */
u_char* args = NULL;
u_char *ptr; /* printing out hardware header info */
..........
..........
/* grab a device to peak into... */
dev = pcap_lookupdev(errbuf);

descr = pcap_open_live(dev,BUFSIZ,0,-1,errbuf);
// we will get the packet here from the interface
packet = pcap_next(descr,&hdr);
if(packet == NULL)
{
    printf("Didn't grab packet\n");
    exit(1);
}
 eptr = (struct ether_header *) packet;
ptr = eptr->ether_dhost;
i = ETHER_ADDR_LEN;
printf(" Source Address:  ");
do{
    printf("%s%x",(i == ETHER_ADDR_LEN) ? " " : ":",*ptr++);
}while(--i>0);

so I want to know, is there a way like this to find the Openflow packet headers?

1

1 Answers

0
votes

I used pcap library to get some headers information to make some decisions about where to route my packets. If you really want to dissect your Openflow messages, I recommend you to download the Openflow Wireshark Dissector. You could also find the source code, where you could adapt to your requirements.