mirror of
https://github.com/nmap/nmap.git
synced 2026-11-20 08:15:52 +08:00
Assertions for TCP and IP header length field
This commit is contained in:
@@ -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() */
|
||||
|
||||
Reference in New Issue
Block a user