summaryrefslogtreecommitdiff
path: root/io/sockets/headers/bsd/bsd.factor
blob: 06634c28c853330177e2e31c0b4d363ffe3328d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
! Copyright (C) 2007 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.syntax byte-arrays io
kernel math prettyprint ;
IN: io.sockets.headers.bsd

C-STRUCT: bpfh
    { "timeval" "timestamp" }
    { "ulong" "caplen" }
    { "ulong" "datalen" }
    { "ushort" "hdrlen" } ;

: bpfh. ( bpfh -- )
    [
        bpfh-timestamp "Timestamp: " write
        "timeval" heap-size memory>byte-array .
    ] keep
    [ bpfh-caplen "caplen: " write . ] keep
    [ bpfh-datalen "datalen: " write . ] keep
    [ bpfh-hdrlen "hdrlen: " write . ] keep
    drop ;