Skip to content

Instantly share code, notes, and snippets.

@fser
Created November 25, 2013 19:01
Show Gist options
  • Save fser/7646738 to your computer and use it in GitHub Desktop.
Save fser/7646738 to your computer and use it in GitHub Desktop.
#ifdef __gnu_linux__
#define SPORT source
#define DPORT dest
#else
#define SPORT th_sport
#define DPORT th_dport
#endif
// ...
switch(ip_next)
{
case IPPROTO_TCP:
tcp_hdr = (struct tcphdr *)pkt_ptr;
sport = tcp_hdr->SPORT;
dport = tcp_hdr->DPORT;
break;
case IPPROTO_UDP:
udp_hdr = (struct udphdr *)pkt_ptr;
sport = udp_hdr->SPORT;
dport = udp_hdr->DPORT;
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment