mirror of
https://github.com/nmap/nmap.git
synced 2026-01-21 05:39:14 +00:00
Merge r30175-176 from nmap-npingchanges: Add support for Node Information queries in print(). Also, add the ability to pass u64 to setNonce()
This commit is contained in:
@@ -225,6 +225,32 @@ int ICMPv6Header::print(FILE *output, int detail) const {
|
||||
fprintf(output, " id=%u seq=%u", this->getIdentifier(), this->getSequence());
|
||||
break;
|
||||
|
||||
case ICMPv6_NODEINFOQUERY:
|
||||
case ICMPv6_NODEINFORESP:
|
||||
if(this->getNodeInfoFlags()!=0){
|
||||
fprintf(output, " flags=");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_T)
|
||||
fprintf(output, "T");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_A)
|
||||
fprintf(output, "A");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_C)
|
||||
fprintf(output, "C");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_L)
|
||||
fprintf(output, "L");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_G)
|
||||
fprintf(output, "G");
|
||||
if(this->getNodeInfoFlags() & ICMPv6_NI_FLAG_S)
|
||||
fprintf(output, "S");
|
||||
}
|
||||
if(detail>=PRINT_DETAIL_HIGH){
|
||||
#ifdef WIN32
|
||||
fprintf(output, " nonce=%I64u", (long long unsigned int)this->getNonce());
|
||||
#else
|
||||
fprintf(output, " nonce=%llu", (long long unsigned int)this->getNonce());
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Print nothing */
|
||||
break;
|
||||
@@ -1046,12 +1072,19 @@ bool ICMPv6Header::getT() const {
|
||||
} /* End of getT() */
|
||||
|
||||
|
||||
/* Set the Nonce field. */
|
||||
int ICMPv6Header::setNonce(u64 nonce_value){
|
||||
this->h_ni->nonce=nonce_value;
|
||||
return OP_SUCCESS;
|
||||
} /* End of setNonce() */
|
||||
|
||||
|
||||
/* Set the Nonce field.
|
||||
* @warning: Supplied buffer must contain 8 bytes. */
|
||||
int ICMPv6Header::setNonce(const u8 *nonce){
|
||||
if(nonce==NULL)
|
||||
return OP_FAILURE;
|
||||
memcpy(this->h_ni->nonce, nonce, NI_NONCE_LEN);
|
||||
memcpy(&(this->h_ni->nonce), nonce, NI_NONCE_LEN);
|
||||
return OP_SUCCESS;
|
||||
} /* End of setNonce() */
|
||||
|
||||
@@ -1059,7 +1092,7 @@ int ICMPv6Header::setNonce(const u8 *nonce){
|
||||
/* Returns a pointer to the nonce buffer.
|
||||
* @warning: The returned pointer is guaranteed to point to an 8-byte buffer.
|
||||
* However, what comes after the 8th byte is unspecified. */
|
||||
u8 *ICMPv6Header::getNonce() const {
|
||||
u64 ICMPv6Header::getNonce() const {
|
||||
return this->h_ni->nonce;
|
||||
} /* End of getNonce() */
|
||||
|
||||
|
||||
@@ -270,6 +270,14 @@
|
||||
|
||||
|
||||
|
||||
/* Node Information flag bitmaks */
|
||||
#define ICMPv6_NI_FLAG_T 0x01
|
||||
#define ICMPv6_NI_FLAG_A 0x02
|
||||
#define ICMPv6_NI_FLAG_C 0x04
|
||||
#define ICMPv6_NI_FLAG_L 0x08
|
||||
#define ICMPv6_NI_FLAG_G 0x10
|
||||
#define ICMPv6_NI_FLAG_S 0x20
|
||||
|
||||
class ICMPv6Header : public ICMPHeader {
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -524,7 +532,7 @@ class ICMPv6Header : public ICMPHeader {
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Type | Code | Checksum |
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| Qtype | Flags |
|
||||
| Qtype | unused |G|S|L|C|A|T|
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
| |
|
||||
+ Nonce +
|
||||
@@ -537,7 +545,7 @@ class ICMPv6Header : public ICMPHeader {
|
||||
struct nodeinfo_msg{
|
||||
u16 qtype;
|
||||
u16 flags;
|
||||
u8 nonce[NI_NONCE_LEN];
|
||||
u64 nonce;
|
||||
//u8 data[?];
|
||||
}__attribute__((__packed__));
|
||||
typedef struct nodeinfo_msg nodeinfo_msg_t;
|
||||
@@ -676,8 +684,9 @@ class ICMPv6Header : public ICMPHeader {
|
||||
bool getA() const;
|
||||
int setT(bool flag_value=true);
|
||||
bool getT() const;
|
||||
int setNonce(u64 nonce_value);
|
||||
int setNonce(const u8 *nonce);
|
||||
u8 *getNonce() const;
|
||||
u64 getNonce() const;
|
||||
|
||||
/* Multicast Listener Discovery */
|
||||
int setMulticastAddress(struct in6_addr addr);
|
||||
|
||||
@@ -1263,7 +1263,7 @@ bool PacketParser::is_response(PacketElement *sent, PacketElement *rcvd){
|
||||
case ICMPv6_NODEINFORESP:
|
||||
if(sent_icmp6->getNodeInfoFlags() != inner_icmp6->getNodeInfoFlags() )
|
||||
return false;
|
||||
if( memcmp(sent_icmp6->getNonce(), inner_icmp6->getNonce(), NI_NONCE_LEN)!=0 )
|
||||
if(sent_icmp6->getNonce() != inner_icmp6->getNonce())
|
||||
return false;
|
||||
if(sent_icmp6->getQtype() != inner_icmp6->getQtype() )
|
||||
return false;
|
||||
@@ -1472,7 +1472,7 @@ bool PacketParser::is_response(PacketElement *sent, PacketElement *rcvd){
|
||||
* responses with the same Nonce value that we used in the query. */
|
||||
if(rcvd_icmp6->getType()!=ICMPv6_NODEINFORESP)
|
||||
return false;
|
||||
if( memcmp(sent_icmp6->getNonce(), rcvd_icmp6->getNonce(), NI_NONCE_LEN)!=0 )
|
||||
if(sent_icmp6->getNonce() != rcvd_icmp6->getNonce())
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user