adjust struct definitions to glibc headers

master
Christian Ulrich 2020-07-10 00:28:17 +02:00
parent 17f8388d0d
commit d97a0eaed7
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 20 additions and 20 deletions

View File

@ -4,23 +4,23 @@ from posix import InAddr, inet_ntoa
type
Ether_header {.importc: "struct ether_header", pure, final,
header: "<netinet/if_ether.h>".} = object
ether_dhost: array[6, cuchar]
ether_shost: array[6, cuchar]
ether_dhost: array[6, uint8]
ether_shost: array[6, uint8]
ether_type: cushort
Ip {.importc: "struct ip", pure, final,
header: "<netinet/ip.h>".} = object
when cpuEndian == littleEndian:
ip_hl {.bitsize:4.}: cuchar # header length
ip_v {.bitsize:4.}: cuchar # version
ip_hl {.bitsize:4.}: uint # header length
ip_v {.bitsize:4.}: uint # version
else:
ip_v {.bitsize:4.}: cuchar # version
ip_hl {.bitsize:4.}: cuchar # header length
ip_tos: cuchar # type of service
ip_len: cshort # total length
ip_v {.bitsize:4.}: uint # version
ip_hl {.bitsize:4.}: uint # header length
ip_tos: uint8 # type of service
ip_len: cushort # total length
ip_id: cushort # identification
ip_off: cshort # fragment offset field
ip_ttl: cuchar # time to live
ip_off: cushort # fragment offset field
ip_ttl: uint8 # time to live
ip_p: cuchar # protocol
ip_sum: cushort # checksum
ip_src: InAddr # source address
@ -28,20 +28,20 @@ type
Tcphdr {.importc: "struct tcphdr", pure, final,
header: "<netinet/tcp.h>".} = object
th_sport: cushort # source port
th_dport: cushort # destination port
th_sport: uint16 # source port
th_dport: uint16 # destination port
th_seq: uint32 # sequence number
th_ack: uint32 # ackkowledgment number
when cpuEndian == littleEndian:
th_x2 {.bitsize:4.}: cuchar # (unused)
th_off {.bitsize:4.}: cuchar # data offset
th_x2 {.bitsize:4.}: uint8 # (unused)
th_off {.bitsize:4.}: uint8 # data offset
else:
th_off {.bitsize:4.}: cuchar # (unused)
th_x2 {.bitsize:4.}: cuchar # data offset
th_flags: cuchar # flags
th_win: cushort # window
th_sum: cushort # checksum
th_urp: cushort # urgent pointer
th_off {.bitsize:4.}: uint8 # (unused)
th_x2 {.bitsize:4.}: uint8 # data offset
th_flags: uint8 # flags
th_win: uint16 # window
th_sum: uint16 # checksum
th_urp: uint16 # urgent pointer
Protocol* = enum
tcp