remove wrong htonl; don't hard-code ip packet size
This commit is contained in:
parent
95f074e202
commit
32060fe9dc
|
@ -100,12 +100,12 @@ proc parseEthernetPacket*(input: string): IpPacket =
|
|||
proc serialize*(packet: IpPacket): string =
|
||||
case packet.protocol
|
||||
of tcp:
|
||||
let srcIp = InAddr(s_addr: htonl(cast[uint32](packet.tcpIpSrc.address_v4)))
|
||||
let dstIp = InAddr(s_addr: htonl(cast[uint32](packet.tcpIpDst.address_v4)))
|
||||
let srcIp = InAddr(s_addr: cast[uint32](packet.tcpIpSrc.address_v4))
|
||||
let dstIp = InAddr(s_addr: cast[uint32](packet.tcpIpDst.address_v4))
|
||||
var ipHeader = Ip(ip_hl: 5,
|
||||
ip_v: 4,
|
||||
ip_tos: 0,
|
||||
ip_len: htons(40),
|
||||
ip_len: sizeof(Ip).uint16 + sizeof(TcpHdr).uint16,
|
||||
ip_id: htons(54321), # FIXME: random number
|
||||
ip_off: 0,
|
||||
ip_ttl: 64,
|
||||
|
|
Loading…
Reference in New Issue