From dcad8120d10bee18e1d2a27b9ea25ebbdbdaa6c4 Mon Sep 17 00:00:00 2001 From: Brett Gordon Date: Tue, 24 Jan 2017 11:21:46 -0500 Subject: [PATCH] netd: mark unused raw sockets with protocol no. 255 rather than 0 --- Applications/netd/uip.c | 8 ++++---- Applications/netd/uip.h | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Applications/netd/uip.c b/Applications/netd/uip.c index 5dca380c..ea4e377b 100644 --- a/Applications/netd/uip.c +++ b/Applications/netd/uip.c @@ -385,7 +385,7 @@ uip_init(void) #if UIP_RAW for(c = 0; c < UIP_RAW_CONNS; ++c) { - uip_raw_conns[c].proto = 0; + uip_raw_conns[c].proto = 255; } #endif /* UIP_RAW */ @@ -526,7 +526,7 @@ uip_raw_new(const uip_ipaddr_t *ripaddr, uint8_t proto) /* find an unused RAW connection */ conn = 0; for(c = 0; c < UIP_RAW_CONNS; ++c) { - if(uip_raw_conns[c].proto == 0) { + if(uip_raw_conns[c].proto == 255) { conn = &uip_raw_conns[c]; break; } @@ -871,7 +871,7 @@ uip_process(uint8_t flag) #if UIP_RAW if(flag == UIP_RAW_TIMER) { - if(uip_raw_conn->proto != 0) { + if(uip_raw_conn->proto != 255) { uip_conn = NULL; uip_sappdata = uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPH_LEN]; uip_len = uip_slen = 0; @@ -1038,7 +1038,7 @@ uip_process(uint8_t flag) for(uip_raw_conn = &uip_raw_conns[0]; uip_raw_conn < &uip_raw_conns[UIP_RAW_CONNS]; ++uip_raw_conn){ - if(uip_raw_conn->proto != 0 && + if(uip_raw_conn->proto != 255 && uip_raw_conn->proto == BUF->proto ){ uip_conn = NULL; uip_flags = UIP_NEWDATA; diff --git a/Applications/netd/uip.h b/Applications/netd/uip.h index f77c3d3b..e12ffacf 100644 --- a/Applications/netd/uip.h +++ b/Applications/netd/uip.h @@ -2240,15 +2240,16 @@ uint16_t uip_icmp6chksum(void); /* Support for RAW sockets here * BMG * - * - all packets matching protocol go to socket/connection - * - packets sent and received start at the protocol header (for now) - * + * - received packets get duplicated and sent to each matching socket + * - on write: send just level 4 + header + * - on read: uip will send level 3 (ip) header + * - you can send but not receive UDP/TCP packets via raw socks */ struct uip_raw_conn { uip_ipaddr_t ripaddr; /* IP address of remote peer */ uint8_t proto; /* IP protocol number */ - uint8_t ttl; /* defualt time-to-live */ + uint8_t ttl; /* default time-to-live */ uip_raw_appstate_t appstate; /* application's state */ }; @@ -2258,7 +2259,7 @@ extern struct uip_raw_conn uip_raw_conns[UIP_RAW_CONNS]; struct uip_raw_conn * uip_raw_new(const uip_ipaddr_t *ripaddr, uint8_t proto); -#define uip_raw_remove(conn) (conn)->proto = 0 +#define uip_raw_remove(conn) (conn)->proto = 255 #define uip_raw_send(len) uip_send((char *)uip_appdata, len) -- 2.34.1