mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
export various protocol header info functions
This commit is contained in:
parent
013a93ce0a
commit
4ea1c703de
2 changed files with 19 additions and 19 deletions
|
|
@ -441,6 +441,16 @@ char *format_ip_options(const u8* ipopt, int ipoptlen);
|
|||
#define MEDIUM_DETAIL 2
|
||||
#define HIGH_DETAIL 3
|
||||
const char *ippackethdrinfo(const u8 *packet, u32 len, int detail);
|
||||
const char *tcphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *udphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *sctphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *icmphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *icmp6hdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
|
||||
|
||||
/* Takes an IPv4 destination address (dst) and tries to determine the
|
||||
|
|
|
|||
|
|
@ -478,16 +478,6 @@ static int tcpflagsinfo (char *buf, int len, u8 f) {
|
|||
return (p - buf);
|
||||
}
|
||||
|
||||
const char *tcphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *udphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *sctphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *icmphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
const char *icmp6hdrinfo (const u8 *data, unsigned int datalen, int detail,
|
||||
int frag_off, const char *srchost, const char *dsthost);
|
||||
/* Returns a buffer of ASCII information about an IP packet that may
|
||||
* look like "TCP 127.0.0.1:50923 > 127.0.0.1:3 S ttl=61 id=39516
|
||||
* iplen=40 seq=625950769" or "ICMP PING (0/1) ttl=61 id=39516 iplen=40".
|
||||
|
|
@ -692,7 +682,7 @@ const char *tcphdrinfo (const u8 *data, unsigned int datalen, int detail,
|
|||
* either the fragment belongs to somewhere past that or the IP contains
|
||||
* less than 8 bytes. This also includes empty IP packets that say they
|
||||
* contain a TCP packet. */
|
||||
if (frag_off > 8 || datalen < 8) {
|
||||
if (frag_off > 8 || datalen < 8 || (frag_off % 8 != 0)) {
|
||||
Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? ?? (incomplete)",
|
||||
srchost, dsthost);
|
||||
}
|
||||
|
|
@ -1177,7 +1167,11 @@ const char *icmp6hdrinfo (const u8 *data, unsigned int datalen, int detail,
|
|||
if (dsthost == NULL)
|
||||
dsthost = "??";
|
||||
static char protoinfo[512] = "";
|
||||
if (datalen > sizeof(struct icmpv6_hdr)) {
|
||||
if (frag_off || datalen < sizeof(struct icmpv6_hdr)) {
|
||||
Snprintf(protoinfo, sizeof(protoinfo), "ICMPv6 %s > %s (type=?/code=?)",
|
||||
srchost, dsthost);
|
||||
}
|
||||
else {
|
||||
const struct icmpv6_hdr *icmpv6;
|
||||
|
||||
icmpv6 = (struct icmpv6_hdr *) data;
|
||||
|
|
@ -1185,10 +1179,6 @@ const char *icmp6hdrinfo (const u8 *data, unsigned int datalen, int detail,
|
|||
srchost, dsthost,
|
||||
icmpv6->icmpv6_type, icmpv6->icmpv6_code);
|
||||
}
|
||||
else {
|
||||
Snprintf(protoinfo, sizeof(protoinfo), "ICMPv6 %s > %s (type=?/code=?)",
|
||||
srchost, dsthost);
|
||||
}
|
||||
return protoinfo;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue