~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to pdns/dnspcap.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Mohlmann, Matthijs Mohlmann, Christoph Haas
  • Date: 2007-04-15 23:23:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070415232339-5x3scc8gx04e50um
Tags: 2.9.21-1
[ Matthijs Mohlmann ]
* New upstream release. (Closes: #420294)
* Remove meta pdns package.
* Added new sqlite3 backend package.
* Months and minutes where mixed up. (Closes: #406462)
* Case sensitivity in bind backend caused PowerDNS to not serve a certain
  zone. (Closes: #406461)
* Bind backend forgot about zones on a notify. (Closes: #398213)

[ Christoph Haas ]
* Documented incorporated backend bind. (Closes: #415471)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  if(d_pfh.magic != 2712847316UL)
19
19
    throw runtime_error((format("PCAP file %s has bad magic %x, should be %x") % fname % d_pfh.magic % 2712847316UL).str());
20
20
  
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());
23
27
  
24
28
  d_runts = d_oversized = d_correctpackets = d_nonetheripudp = 0;
25
29
}
64
68
    }
65
69
 
66
70
    d_ether=reinterpret_cast<struct ether_header*>(d_buffer);
67
 
    d_ip=reinterpret_cast<struct ip*>(d_buffer + sizeof(struct ether_header));
68
 
 
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);
 
71
    d_lcc=reinterpret_cast<struct pdns_lcc_header*>(d_buffer);
 
72
 
 
73
    d_ip=reinterpret_cast<struct ip*>(d_buffer + d_skipMediaHeader);
 
74
 
 
75
    uint16_t contentCode=0;
 
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);
71
83
      d_payload = (unsigned char*)d_udp + sizeof(struct udphdr);
72
84
      d_len = ntohs(d_udp->uh_ulen) - sizeof(struct udphdr);
73
85
      d_correctpackets++;