Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. static void print_debug_skb(struct sk_buff *skb){
  2.   enum ip_conntrack_info ctinfo;
  3.   struct nf_conn *ct;
  4.   struct iphdr *iph;
  5.   struct udphdr *udh;
  6.   int sport,dport;
  7.   unsigned int ctmark, opackets, rpackets;
  8.   struct nf_conn_counter *acct = NULL;
  9.   int dir = 0;
  10.    
  11.   uint8 ipver;
  12.   ct = nf_ct_get( skb, &ctinfo );
  13.   if( ct )
  14.     acct = nf_conn_acct_find(ct);
  15.  
  16.   iph = ip_hdr(skb);
  17.   if( !iph ){
  18.     printk("IP header missing in print_debug_skb\n");
  19.     return;
  20.   }
  21.  
  22.   ipver = iph->version;
  23.  
  24.   if (ipver==4) //(1) //(out)
  25.   {
  26.     sport = dport = 0;
  27.     if( iph->protocol == 6 || iph->protocol == 17 ){
  28.         udh = udp_hdr(skb);
  29.         if( udh ){
  30.             sport = ntohs(udh->source);
  31.             dport = ntohs(udh->dest);
  32.         }
  33.     }
  34.  
  35.     ctmark = opackets = rpackets = 0;
  36.     if( ct && acct ){
  37.         ctmark = ct->mark;
  38.         opackets = acct[0].packets;
  39.         rpackets = acct[1].packets;
  40.     }
  41.    
  42.     dir = CTINFO2DIR(ctinfo);
  43.     printk(KERN_INFO "dir=%d src=%08x dst=%08x protocol=%d sport=%d dport=%d fwmark=%d ct=%x,ctmark=%d acct[0]=%llu acct[1]=%llu\n",
  44.             dir, htonl(iph->saddr), htonl(iph->daddr), iph->protocol, sport, dport, skb->mark, ct, ctmark, opackets, rpackets);
  45.   }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement