1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 00:49:01 +00:00

Merge r28016 from nmap-npingchanges: Add method to set IP options from a binary buffer than can be inserted right away into the IP header.

This commit is contained in:
luis
2013-03-29 16:48:53 +00:00
parent a3f84c2c87
commit 347badd7f3
2 changed files with 15 additions and 4 deletions

View File

@@ -93,6 +93,7 @@
/* This code was originally part of the Nping tool. */
#include "IPv4Header.h"
#include <assert.h>
/******************************************************************************/
/* CONTRUCTORS, DESTRUCTORS AND INITIALIZATION METHODS */
@@ -623,15 +624,24 @@ int IPv4Header::setOpts(const char *txt){
return OP_FAILURE;
}else{
/* Copy options to our IP header */
memcpy(h.options, buffer, ret);
this->ipoptlen=ret;
this->length += ret;
this->setHeaderLength();
this->setOpts(buffer, ret);
}
return OP_SUCCESS;
} /* End of setOpts() */
int IPv4Header::setOpts(u8 *opts_buff, u32 opts_len){
if(opts_buff==NULL || opts_len==0)
return OP_FAILURE;
assert(opts_len<=MAX_IP_OPTIONS_LEN); /* Max lenght for IP options */
memcpy(this->h.options, opts_buff, opts_len);
this->ipoptlen=opts_len;
this->length += opts_len;
this->setHeaderLength();
return OP_SUCCESS;
} /* End of setOpts() */
const u8 *IPv4Header::getOpts() const {
return h.options;
} /* End of getOpts() */