Changeset 840

Show
Ignore:
Timestamp:
05/23/06 12:02:28 (7 years ago)
Author:
ahu
Message:

add linux 'cooked' packet support to dnsscope, dnsreplay, dnslog etc

Location:
trunk/pdns/pdns
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/dnspcap.cc

    r431 r840  
    1919    throw runtime_error((format("PCAP file %s has bad magic %x, should be %x") % fname % d_pfh.magic % 2712847316UL).str()); 
    2020   
    21   if( d_pfh.linktype!=1) 
    22     throw runtime_error((format("Unsupported link type %d") % d_pfh.linktype).str()); 
     21  if( d_pfh.linktype==1) { 
     22    d_skipMediaHeader=sizeof(struct ether_header); 
     23  } else if(d_pfh.linktype==113) { 
     24    d_skipMediaHeader=16; 
     25  } 
     26  else throw runtime_error((format("Unsupported link type %d") % d_pfh.linktype).str()); 
    2327   
    2428  d_runts = d_oversized = d_correctpackets = d_nonetheripudp = 0; 
     
    6569 
    6670    d_ether=reinterpret_cast<struct ether_header*>(d_buffer); 
    67     d_ip=reinterpret_cast<struct ip*>(d_buffer + sizeof(struct ether_header)); 
     71    d_lcc=reinterpret_cast<struct pdns_lcc_header*>(d_buffer); 
    6872 
    69     if(ntohs(d_ether->ether_type)==0x0800 && d_ip->ip_p==17) { // udp 
    70       d_udp=reinterpret_cast<const struct udphdr*>(d_buffer + sizeof(struct ether_header) + 4 * d_ip->ip_hl); 
     73    d_ip=reinterpret_cast<struct ip*>(d_buffer + d_skipMediaHeader); 
     74 
     75    uint16_t contentCode; 
     76    if(d_pfh.linktype==1)  
     77      contentCode=ntohs(d_ether->ether_type); 
     78    else if(d_pfh.linktype==113) 
     79      contentCode=ntohs(d_lcc->lcc_protocol); 
     80 
     81    if(contentCode==0x0800 && d_ip->ip_p==17) { // udp 
     82      d_udp=reinterpret_cast<const struct udphdr*>(d_buffer + d_skipMediaHeader + 4 * d_ip->ip_hl); 
    7183      d_payload = (unsigned char*)d_udp + sizeof(struct udphdr); 
    7284      d_len = ntohs(d_udp->uh_ulen) - sizeof(struct udphdr); 
  • trunk/pdns/pdns/dnspcap.hh

    r527 r840  
    3333}; 
    3434 
     35struct pdns_lcc_header { 
     36  uint16_t lcc_pkttype;/* packet type */ 
     37  uint16_t lcc_hatype;/* link-layer address type */ 
     38  uint16_t lcc_halen;/* link-layer address length */ 
     39  uint8_t lcc_addr[8];/* link-layer address */ 
     40  uint16_t lcc_protocol;/* protocol */ 
     41}; 
     42 
    3543class PcapPacketReader 
    3644{ 
     
    5866  bool getUDPPacket(); 
    5967 
     68  struct pdns_lcc_header* d_lcc; 
    6069  struct ether_header* d_ether; 
    6170  struct ip *d_ip; 
     
    7281  FILE* d_fp; 
    7382  string d_fname; 
     83  int d_skipMediaHeader; 
    7484}; 
    7585 
  • trunk/pdns/pdns/dnsscope.cc

    r564 r840  
    5656    if((ntohs(pr.d_udp->uh_dport)==5300 || ntohs(pr.d_udp->uh_sport)==5300 || 
    5757        ntohs(pr.d_udp->uh_dport)==53   || ntohs(pr.d_udp->uh_sport)==53) && 
    58         pr.d_len > sizeof(HEADER)) { 
     58        pr.d_len > 12) { 
    5959      try { 
    6060        MOADNSParser mdp((const char*)pr.d_payload, pr.d_len); 
  • trunk/pdns/pdns/docs/pdns.sgml

    r838 r840  
    248248              <para> 
    249249                Some operators may want to follow RFC 2181 paragraph 5.2 and 5.4. This harms performance and does not solve any real problem, 
    250                 but does make PowerDNS more compliant. If you want this, enable <command>auth-can-lower-ttl</command>. Implemented in c839, which is 
     250                but does make PowerDNS more compliant. If you want this, enable <command>auth-can-lower-ttl</command>. Implemented in c838, which is 
    251251                post 3.1-pre2. 
    252252              </para>