mirror of
https://github.com/nmap/nmap.git
synced 2026-07-01 05:33:21 +00:00
Assertions for TCP and IP header length field
This commit is contained in:
parent
3fa8d201fa
commit
4651a54b4b
2 changed files with 4 additions and 4 deletions
|
|
@ -234,12 +234,14 @@ u8 IPv4Header::getVersion() const {
|
|||
|
||||
|
||||
int IPv4Header::setHeaderLength(){
|
||||
assert(ipoptlen <= 40);
|
||||
h.ip_hl = 5 + (ipoptlen/4);
|
||||
return OP_SUCCESS;
|
||||
} /* End of setHeaderLength() */
|
||||
|
||||
|
||||
int IPv4Header::setHeaderLength(u8 l){
|
||||
assert(l <= 0x0f);
|
||||
h.ip_hl = l;
|
||||
return OP_SUCCESS;
|
||||
} /* End of setHeaderLength() */
|
||||
|
|
|
|||
|
|
@ -260,17 +260,15 @@ u32 TCPHeader::getAck() const {
|
|||
} /* End of getAck() */
|
||||
|
||||
|
||||
/* TODO: Test this method. It may not work becuasse th_off is supposed to
|
||||
* be 4 bits long and arg o is 8.
|
||||
* UPDATE: It seems to work just fine. However, let's keep this note just
|
||||
* in case problems arise. */
|
||||
int TCPHeader::setOffset(u8 o){
|
||||
assert(o <= 0x0f);
|
||||
h.th_off = o;
|
||||
return OP_SUCCESS;
|
||||
} /* End of setOffset() */
|
||||
|
||||
|
||||
int TCPHeader::setOffset(){
|
||||
assert(tcpoptlen <= 40);
|
||||
h.th_off = 5 + tcpoptlen/4;
|
||||
return OP_SUCCESS;
|
||||
} /* End of setOffset() */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue