mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
Avoid copying link-layer header; point instead
This commit is contained in:
@@ -237,7 +237,7 @@ typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype;
|
|||||||
struct link_header {
|
struct link_header {
|
||||||
int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */
|
int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */
|
||||||
int headerlen; /* 0 if header was too big or unavailaable */
|
int headerlen; /* 0 if header was too big or unavailaable */
|
||||||
u8 header[MAX_LINK_HEADERSZ];
|
const u8 *header;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Relevant (to Nmap) information about an interface */
|
/* Relevant (to Nmap) information about an interface */
|
||||||
|
|||||||
3
tcpip.cc
3
tcpip.cc
@@ -1554,8 +1554,7 @@ const u8 *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec,
|
|||||||
if (offset && linknfo) {
|
if (offset && linknfo) {
|
||||||
linknfo->datalinktype = datalink;
|
linknfo->datalinktype = datalink;
|
||||||
linknfo->headerlen = offset;
|
linknfo->headerlen = offset;
|
||||||
assert(offset <= MAX_LINK_HEADERSZ);
|
linknfo->header = p;
|
||||||
memcpy(linknfo->header, p - offset, MIN(sizeof(linknfo->header), offset));
|
|
||||||
}
|
}
|
||||||
if (rcvdtime)
|
if (rcvdtime)
|
||||||
PacketTrace::trace(PacketTrace::RCVD, (u8 *) p, *len,
|
PacketTrace::trace(PacketTrace::RCVD, (u8 *) p, *len,
|
||||||
|
|||||||
Reference in New Issue
Block a user