Back to index

natlog  0.91.0
computeshift.cc
Go to the documentation of this file.
00001 #include "pcap.ih"
00002 
00003 void Pcap::computeShift(char const *device)
00004 {
00005     // see the posting by user175104 on 
00006     // http://stackoverflow.com/questions/1779715/
00007     //              how-to-get-mac-address-of-your-machine-using-a-c-program 
00008 
00009     ifstream mac((string("/sys/class/net/") + device) + "/address");
00010 
00011     string address;
00012     d_shift = (mac >> address) ? 0 : PcapPacket::SIZEOF_ETHERNET_HEADER;
00013 
00014     if (d_shift == 0)
00015         imsg << "Device " << device << " has MAC address " << address << endl;
00016     else
00017         imsg << "Device " << device << " has no MAC address: packets lack "
00018                                     "Ethernet headers" << endl;
00019 }