diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-24 11:11:43 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-24 11:11:43 +0200 |
commit | 88a183c6c9a2b86b52f67e87bbc8b7edd32670c6 (patch) | |
tree | b1348b71e69f9ed0d919a4792549026c9e31b092 /sysdep/unix/io.c | |
parent | f8fefde318c6248ad94e7b6d60155deed9ab8eed (diff) |
Integrated IP functions.
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r-- | sysdep/unix/io.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 164038ec..04f0fe50 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -764,6 +764,29 @@ sk_set_tos6(sock *s, int tos) return 0; } +static inline byte * +sk_skip_ip_header(byte *pkt, int *len) +{ + if ((*len < 20) || ((*pkt & 0xf0) != 0x40)) + return NULL; + + int hlen = (*pkt & 0x0f) * 4; + if ((hlen < 20) || (hlen > *len)) + return NULL; + + *len -= hlen; + return pkt + hlen; +} + +byte * +sk_rx_buffer(sock *s, int *len) +{ + if (sk_is_ipv4(s) && (s->type == SK_IP)) + return sk_skip_ip_header(s->rbuf, len); + else + return s->rbuf; +} + /* * Public socket functions |