Merge pull request #1390 from tsparber/fix-doxygen-whitespace
Cleanup some trailing spaces and convert tabs to spaces
This commit is contained in:
commit
41ea0308a3
29 changed files with 1001 additions and 1033 deletions
|
@ -64,17 +64,11 @@
|
|||
#define UIP_TCPH_LEN 20 /* Size of TCP header */
|
||||
#define UIP_ICMPH_LEN 4 /* Size of ICMP header */
|
||||
|
||||
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP +
|
||||
* UDP
|
||||
* header */
|
||||
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP +
|
||||
* TCP
|
||||
* header */
|
||||
#define UIP_IPUDPH_LEN (UIP_UDPH_LEN + UIP_IPH_LEN) /* Size of IP + UDP header */
|
||||
#define UIP_IPTCPH_LEN (UIP_TCPH_LEN + UIP_IPH_LEN) /* Size of IP + TCP header */
|
||||
#define UIP_TCPIP_HLEN UIP_IPTCPH_LEN
|
||||
#define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN) /* size of ICMP
|
||||
+ IP header */
|
||||
#define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* size of L2
|
||||
+ IP header */
|
||||
#define UIP_IPICMPH_LEN (UIP_IPH_LEN + UIP_ICMPH_LEN) /* Size of ICMP + IP header */
|
||||
#define UIP_LLIPH_LEN (UIP_LLH_LEN + UIP_IPH_LEN) /* Size of L2 + IP header */
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
/**
|
||||
* The sums below are quite used in ND. When used for uip_buf, we
|
||||
|
@ -99,12 +93,12 @@
|
|||
*
|
||||
*/
|
||||
typedef union uip_ip4addr_t {
|
||||
uint8_t u8[4]; /* Initializer, must come first. */
|
||||
uint8_t u8[4]; /* Initializer, must come first. */
|
||||
uint16_t u16[2];
|
||||
} uip_ip4addr_t;
|
||||
|
||||
typedef union uip_ip6addr_t {
|
||||
uint8_t u8[16]; /* Initializer, must come first. */
|
||||
uint8_t u8[16]; /* Initializer, must come first. */
|
||||
uint16_t u16[8];
|
||||
} uip_ip6addr_t;
|
||||
|
||||
|
@ -1057,7 +1051,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport);
|
|||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ip4addr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \
|
||||
(addr1)->u16[1] == (addr2)->u16[1])
|
||||
(addr1)->u16[1] == (addr2)->u16[1])
|
||||
#define uip_ip6addr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
|
||||
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
@ -1358,26 +1352,21 @@ struct uip_conn {
|
|||
|
||||
uint16_t lport; /**< The local TCP port, in network byte order. */
|
||||
uint16_t rport; /**< The local remote TCP port, in network byte
|
||||
order. */
|
||||
order. */
|
||||
|
||||
uint8_t rcv_nxt[4]; /**< The sequence number that we expect to
|
||||
receive next. */
|
||||
uint8_t snd_nxt[4]; /**< The sequence number that was last sent by
|
||||
us. */
|
||||
receive next. */
|
||||
uint8_t snd_nxt[4]; /**< The sequence number that was last sent by us. */
|
||||
uint16_t len; /**< Length of the data that was previously sent. */
|
||||
uint16_t mss; /**< Current maximum segment size for the
|
||||
connection. */
|
||||
uint16_t initialmss; /**< Initial maximum segment size for the
|
||||
connection. */
|
||||
uint8_t sa; /**< Retransmission time-out calculation state
|
||||
variable. */
|
||||
uint8_t sv; /**< Retransmission time-out calculation state
|
||||
variable. */
|
||||
uint16_t mss; /**< Current maximum segment size for the connection. */
|
||||
uint16_t initialmss; /**< Initial maximum segment size for the connection. */
|
||||
uint8_t sa; /**< Retransmission time-out calculation state variable. */
|
||||
uint8_t sv; /**< Retransmission time-out calculation state variable. */
|
||||
uint8_t rto; /**< Retransmission time-out. */
|
||||
uint8_t tcpstateflags; /**< TCP state and flags. */
|
||||
uint8_t timer; /**< The retransmission timer. */
|
||||
uint8_t nrtx; /**< The number of retransmissions for the last
|
||||
segment sent. */
|
||||
segment sent. */
|
||||
|
||||
/** The application state. */
|
||||
uip_tcp_appstate_t appstate;
|
||||
|
@ -1431,9 +1420,9 @@ struct uip_fallback_interface {
|
|||
void (*init)(void);
|
||||
/**
|
||||
* \retval >=0
|
||||
* in case of success
|
||||
* in case of success
|
||||
* \retval <0
|
||||
* in case of failure
|
||||
* in case of failure
|
||||
*/
|
||||
int (*output)(void);
|
||||
};
|
||||
|
@ -1464,51 +1453,43 @@ extern struct uip_stats uip_stat;
|
|||
*/
|
||||
struct uip_stats {
|
||||
struct {
|
||||
uip_stats_t recv; /**< Number of received packets at the IP
|
||||
layer. */
|
||||
uip_stats_t sent; /**< Number of sent packets at the IP
|
||||
layer. */
|
||||
uip_stats_t forwarded;/**< Number of forwarded packets at the IP
|
||||
layer. */
|
||||
uip_stats_t drop; /**< Number of dropped packets at the IP
|
||||
layer. */
|
||||
uip_stats_t recv; /**< Number of received packets at the IP layer. */
|
||||
uip_stats_t sent; /**< Number of sent packets at the IP layer. */
|
||||
uip_stats_t forwarded;/**< Number of forwarded packets at the IP layer. */
|
||||
uip_stats_t drop; /**< Number of dropped packets at the IP layer. */
|
||||
uip_stats_t vhlerr; /**< Number of packets dropped due to wrong
|
||||
IP version or header length. */
|
||||
IP version or header length. */
|
||||
uip_stats_t hblenerr; /**< Number of packets dropped due to wrong
|
||||
IP length, high byte. */
|
||||
IP length, high byte. */
|
||||
uip_stats_t lblenerr; /**< Number of packets dropped due to wrong
|
||||
IP length, low byte. */
|
||||
IP length, low byte. */
|
||||
uip_stats_t fragerr; /**< Number of packets dropped because they
|
||||
were IP fragments. */
|
||||
were IP fragments. */
|
||||
uip_stats_t chkerr; /**< Number of packets dropped due to IP
|
||||
checksum errors. */
|
||||
checksum errors. */
|
||||
uip_stats_t protoerr; /**< Number of packets dropped because they
|
||||
were neither ICMP, UDP nor TCP. */
|
||||
were neither ICMP, UDP nor TCP. */
|
||||
} ip; /**< IP statistics. */
|
||||
struct {
|
||||
uip_stats_t recv; /**< Number of received ICMP packets. */
|
||||
uip_stats_t sent; /**< Number of sent ICMP packets. */
|
||||
uip_stats_t drop; /**< Number of dropped ICMP packets. */
|
||||
uip_stats_t typeerr; /**< Number of ICMP packets with a wrong
|
||||
type. */
|
||||
uip_stats_t chkerr; /**< Number of ICMP packets with a bad
|
||||
checksum. */
|
||||
uip_stats_t typeerr; /**< Number of ICMP packets with a wrong type. */
|
||||
uip_stats_t chkerr; /**< Number of ICMP packets with a bad checksum. */
|
||||
} icmp; /**< ICMP statistics. */
|
||||
#if UIP_TCP
|
||||
struct {
|
||||
uip_stats_t recv; /**< Number of recived TCP segments. */
|
||||
uip_stats_t sent; /**< Number of sent TCP segments. */
|
||||
uip_stats_t drop; /**< Number of dropped TCP segments. */
|
||||
uip_stats_t chkerr; /**< Number of TCP segments with a bad
|
||||
checksum. */
|
||||
uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK
|
||||
number. */
|
||||
uip_stats_t chkerr; /**< Number of TCP segments with a bad checksum. */
|
||||
uip_stats_t ackerr; /**< Number of TCP segments with a bad ACK number. */
|
||||
uip_stats_t rst; /**< Number of received TCP RST (reset) segments. */
|
||||
uip_stats_t rexmit; /**< Number of retransmitted TCP segments. */
|
||||
uip_stats_t syndrop; /**< Number of dropped SYNs because too few
|
||||
connections were available. */
|
||||
connections were available. */
|
||||
uip_stats_t synrst; /**< Number of SYNs for closed ports,
|
||||
triggering a RST. */
|
||||
triggering a RST. */
|
||||
} tcp; /**< TCP statistics. */
|
||||
#endif
|
||||
#if UIP_UDP
|
||||
|
@ -1517,7 +1498,7 @@ struct uip_stats {
|
|||
uip_stats_t recv; /**< Number of recived UDP segments. */
|
||||
uip_stats_t sent; /**< Number of sent UDP segments. */
|
||||
uip_stats_t chkerr; /**< Number of UDP segments with a bad
|
||||
checksum. */
|
||||
checksum. */
|
||||
} udp; /**< UDP statistics. */
|
||||
#endif /* UIP_UDP */
|
||||
#if NETSTACK_CONF_WITH_IPV6
|
||||
|
@ -1554,33 +1535,33 @@ CCIF extern uint8_t uip_flags;
|
|||
functions/macros. */
|
||||
|
||||
#define UIP_ACKDATA 1 /* Signifies that the outstanding data was
|
||||
acked and the application should send
|
||||
out new data instead of retransmitting
|
||||
the last data. */
|
||||
acked and the application should send
|
||||
out new data instead of retransmitting
|
||||
the last data. */
|
||||
#define UIP_NEWDATA 2 /* Flags the fact that the peer has sent
|
||||
us new data. */
|
||||
us new data. */
|
||||
#define UIP_REXMIT 4 /* Tells the application to retransmit the
|
||||
data that was last sent. */
|
||||
data that was last sent. */
|
||||
#define UIP_POLL 8 /* Used for polling the application, to
|
||||
check if the application has data that
|
||||
it wants to send. */
|
||||
check if the application has data that
|
||||
it wants to send. */
|
||||
#define UIP_CLOSE 16 /* The remote host has closed the
|
||||
connection, thus the connection has
|
||||
gone away. Or the application signals
|
||||
that it wants to close the
|
||||
connection. */
|
||||
connection, thus the connection has
|
||||
gone away. Or the application signals
|
||||
that it wants to close the
|
||||
connection. */
|
||||
#define UIP_ABORT 32 /* The remote host has aborted the
|
||||
connection, thus the connection has
|
||||
gone away. Or the application signals
|
||||
that it wants to abort the
|
||||
connection. */
|
||||
connection, thus the connection has
|
||||
gone away. Or the application signals
|
||||
that it wants to abort the
|
||||
connection. */
|
||||
#define UIP_CONNECTED 64 /* We have got a connection from a remote
|
||||
host and have set up a new connection
|
||||
for it, or an active connection has
|
||||
been successfully established. */
|
||||
|
||||
#define UIP_TIMEDOUT 128 /* The connection has been aborted due to
|
||||
too many retransmissions. */
|
||||
too many retransmissions. */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1606,16 +1587,16 @@ void uip_process(uint8_t flag);
|
|||
the macros defined in this file. */
|
||||
|
||||
#define UIP_DATA 1 /* Tells uIP that there is incoming
|
||||
data in the uip_buf buffer. The
|
||||
length of the data is stored in the
|
||||
global variable uip_len. */
|
||||
data in the uip_buf buffer. The
|
||||
length of the data is stored in the
|
||||
global variable uip_len. */
|
||||
#define UIP_TIMER 2 /* Tells uIP that the periodic timer
|
||||
has fired. */
|
||||
has fired. */
|
||||
#define UIP_POLL_REQUEST 3 /* Tells uIP that a connection should
|
||||
be polled. */
|
||||
be polled. */
|
||||
#define UIP_UDP_SEND_CONN 4 /* Tells uIP that a UDP datagram
|
||||
should be constructed in the
|
||||
uip_buf buffer. */
|
||||
should be constructed in the
|
||||
uip_buf buffer. */
|
||||
#if UIP_UDP
|
||||
#define UIP_UDP_TIMER 5
|
||||
#endif /* UIP_UDP */
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
* FOR HC-06 COMPLIANCE TODO:
|
||||
* -Add compression options to UDP, currently only supports
|
||||
* both ports compressed or both ports elided
|
||||
*
|
||||
*
|
||||
* -Verify TC/FL compression works
|
||||
*
|
||||
*
|
||||
* -Add stateless multicast option
|
||||
*/
|
||||
|
||||
|
@ -317,7 +317,7 @@ set_packet_attrs()
|
|||
|
||||
/** Addresses contexts for IPHC. */
|
||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||
static struct sicslowpan_addr_context
|
||||
static struct sicslowpan_addr_context
|
||||
addr_contexts[SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS];
|
||||
#endif
|
||||
|
||||
|
@ -381,7 +381,7 @@ addr_context_lookup_by_prefix(uip_ipaddr_t *ipaddr)
|
|||
static struct sicslowpan_addr_context*
|
||||
addr_context_lookup_by_number(uint8_t number)
|
||||
{
|
||||
/* Remove code to avoid warnings and save flash if no context is used */
|
||||
/* Remove code to avoid warnings and save flash if no context is used */
|
||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||
int i;
|
||||
for(i = 0; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) {
|
||||
|
@ -540,11 +540,11 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
* We have to process both in the same time as the offset of traffic class
|
||||
* depends on the presence of version and flow label
|
||||
*/
|
||||
|
||||
|
||||
/* hc06 format of tc is ECN | DSCP , original is DSCP | ECN */
|
||||
tmp = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
|
||||
tmp = ((tmp & 0x03) << 6) | (tmp >> 2);
|
||||
|
||||
|
||||
if(((UIP_IP_BUF->tcflow & 0x0F) == 0) &&
|
||||
(UIP_IP_BUF->flow == 0)) {
|
||||
/* flow label can be compressed */
|
||||
|
@ -585,7 +585,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
iphc0 |= SICSLOWPAN_IPHC_NH_C;
|
||||
}
|
||||
#endif /*UIP_CONF_UDP*/
|
||||
#ifdef SICSLOWPAN_NH_COMPRESSOR
|
||||
#ifdef SICSLOWPAN_NH_COMPRESSOR
|
||||
if(SICSLOWPAN_NH_COMPRESSOR.is_compressable(UIP_IP_BUF->proto)) {
|
||||
iphc0 |= SICSLOWPAN_IPHC_NH_C;
|
||||
}
|
||||
|
@ -627,7 +627,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
!= NULL) {
|
||||
/* elide the prefix - indicate by CID and set context + SAC */
|
||||
PRINTF("IPHC: compressing src with context - setting CID & SAC ctx: %d\n",
|
||||
context->number);
|
||||
context->number);
|
||||
iphc1 |= SICSLOWPAN_IPHC_CID | SICSLOWPAN_IPHC_SAC;
|
||||
PACKETBUF_IPHC_BUF[2] |= context->number << 4;
|
||||
/* compession compare with this nodes address (source) */
|
||||
|
@ -636,9 +636,9 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
&UIP_IP_BUF->srcipaddr, &uip_lladdr);
|
||||
/* No context found for this address */
|
||||
} else if(uip_is_addr_linklocal(&UIP_IP_BUF->srcipaddr) &&
|
||||
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[3] == 0) {
|
||||
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[3] == 0) {
|
||||
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
|
||||
&UIP_IP_BUF->srcipaddr, &uip_lladdr);
|
||||
} else {
|
||||
|
@ -684,12 +684,13 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
/* compession compare with link adress (destination) */
|
||||
|
||||
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
|
||||
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)link_destaddr);
|
||||
&UIP_IP_BUF->destipaddr,
|
||||
(uip_lladdr_t *)link_destaddr);
|
||||
/* No context found for this address */
|
||||
} else if(uip_is_addr_linklocal(&UIP_IP_BUF->destipaddr) &&
|
||||
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[3] == 0) {
|
||||
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
|
||||
UIP_IP_BUF->destipaddr.u16[3] == 0) {
|
||||
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
|
||||
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)link_destaddr);
|
||||
} else {
|
||||
|
@ -706,7 +707,7 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
/* UDP header compression */
|
||||
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
|
||||
PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n",
|
||||
UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport));
|
||||
UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport));
|
||||
/* Mask out the last 4 bits can be used as a mask */
|
||||
if(((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) &&
|
||||
((UIP_HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) {
|
||||
|
@ -714,10 +715,10 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_11;
|
||||
PRINTF("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n");
|
||||
*(hc06_ptr + 1) =
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
|
||||
SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
|
||||
SICSLOWPAN_UDP_4_BIT_PORT_MIN));
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
|
||||
SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
|
||||
SICSLOWPAN_UDP_4_BIT_PORT_MIN));
|
||||
hc06_ptr += 2;
|
||||
} else if((UIP_HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
|
||||
/* we can compress 8 bits of dest, leave source. */
|
||||
|
@ -725,16 +726,16 @@ compress_hdr_hc06(linkaddr_t *link_destaddr)
|
|||
PRINTF("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n");
|
||||
memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 2);
|
||||
*(hc06_ptr + 3) =
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
|
||||
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->destport) -
|
||||
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
|
||||
hc06_ptr += 4;
|
||||
} else if((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) {
|
||||
/* we can compress 8 bits of src, leave dest. Copy compressed port */
|
||||
*hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_10;
|
||||
PRINTF("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr);
|
||||
*(hc06_ptr + 1) =
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
|
||||
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
|
||||
(uint8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) -
|
||||
SICSLOWPAN_UDP_8_BIT_PORT_MIN));
|
||||
memcpy(hc06_ptr + 2, &UIP_UDP_BUF->destport, 2);
|
||||
hc06_ptr += 4;
|
||||
} else {
|
||||
|
@ -811,13 +812,13 @@ uncompress_hdr_hc06(uint16_t ip_len)
|
|||
SICSLOWPAN_IP_BUF->vtc = 0x60 | ((tmp >> 2) & 0x0f);
|
||||
/* ECN rolled down two steps + lowest DSCP bits at top two bits */
|
||||
SICSLOWPAN_IP_BUF->tcflow = ((tmp >> 2) & 0x30) | (tmp << 6) |
|
||||
(SICSLOWPAN_IP_BUF->tcflow & 0x0f);
|
||||
(SICSLOWPAN_IP_BUF->tcflow & 0x0f);
|
||||
} else {
|
||||
/* Traffic class is compressed (set version and no TC)*/
|
||||
SICSLOWPAN_IP_BUF->vtc = 0x60;
|
||||
/* highest flow label bits + ECN bits */
|
||||
SICSLOWPAN_IP_BUF->tcflow = (*hc06_ptr & 0x0F) |
|
||||
((*hc06_ptr >> 2) & 0x30);
|
||||
((*hc06_ptr >> 2) & 0x30);
|
||||
memcpy(&SICSLOWPAN_IP_BUF->flow, hc06_ptr + 1, 2);
|
||||
hc06_ptr += 3;
|
||||
}
|
||||
|
@ -908,14 +909,13 @@ uncompress_hdr_hc06(uint16_t ip_len)
|
|||
/* no multicast */
|
||||
/* Context based */
|
||||
if(iphc1 & SICSLOWPAN_IPHC_DAC) {
|
||||
uint8_t dci = (iphc1 & SICSLOWPAN_IPHC_CID) ?
|
||||
PACKETBUF_IPHC_BUF[2] & 0x0f : 0;
|
||||
uint8_t dci = (iphc1 & SICSLOWPAN_IPHC_CID) ? PACKETBUF_IPHC_BUF[2] & 0x0f : 0;
|
||||
context = addr_context_lookup_by_number(dci);
|
||||
|
||||
/* all valid cases below need the context! */
|
||||
if(context == NULL) {
|
||||
PRINTF("sicslowpan uncompress_hdr: error context not found\n");
|
||||
return;
|
||||
PRINTF("sicslowpan uncompress_hdr: error context not found\n");
|
||||
return;
|
||||
}
|
||||
uncompress_addr(&SICSLOWPAN_IP_BUF->destipaddr, context->prefix,
|
||||
unc_ctxconf[tmp],
|
||||
|
@ -939,56 +939,56 @@ uncompress_hdr_hc06(uint16_t ip_len)
|
|||
PRINTF("IPHC: Incoming header value: %i\n", *hc06_ptr);
|
||||
switch(*hc06_ptr & SICSLOWPAN_NHC_UDP_CS_P_11) {
|
||||
case SICSLOWPAN_NHC_UDP_CS_P_00:
|
||||
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 3, 2);
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 5;
|
||||
break;
|
||||
/* 1 byte for NHC, 4 byte for ports, 2 bytes chksum */
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 3, 2);
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 5;
|
||||
break;
|
||||
|
||||
case SICSLOWPAN_NHC_UDP_CS_P_01:
|
||||
/* 1 byte for NHC + source 16bit inline, dest = 0xF0 + 8 bit inline */
|
||||
PRINTF("IPHC: Decompressing destination\n");
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
|
||||
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3)));
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 4;
|
||||
break;
|
||||
PRINTF("IPHC: Decompressing destination\n");
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2);
|
||||
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3)));
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 4;
|
||||
break;
|
||||
|
||||
case SICSLOWPAN_NHC_UDP_CS_P_10:
|
||||
/* 1 byte for NHC + source = 0xF0 + 8bit inline, dest = 16 bit inline*/
|
||||
PRINTF("IPHC: Decompressing source\n");
|
||||
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN +
|
||||
(*(hc06_ptr + 1)));
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 2, 2);
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 4;
|
||||
break;
|
||||
PRINTF("IPHC: Decompressing source\n");
|
||||
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN +
|
||||
(*(hc06_ptr + 1)));
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 2, 2);
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 4;
|
||||
break;
|
||||
|
||||
case SICSLOWPAN_NHC_UDP_CS_P_11:
|
||||
/* 1 byte for NHC, 1 byte for ports */
|
||||
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
|
||||
(*(hc06_ptr + 1) >> 4));
|
||||
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
|
||||
((*(hc06_ptr + 1)) & 0x0F));
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 2;
|
||||
break;
|
||||
/* 1 byte for NHC, 1 byte for ports */
|
||||
SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
|
||||
(*(hc06_ptr + 1) >> 4));
|
||||
SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN +
|
||||
((*(hc06_ptr + 1)) & 0x0F));
|
||||
PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n",
|
||||
UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport));
|
||||
hc06_ptr += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
|
||||
return;
|
||||
PRINTF("sicslowpan uncompress_hdr: error unsupported UDP compression\n");
|
||||
return;
|
||||
}
|
||||
if(!checksum_compressed) { /* has_checksum, default */
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr, 2);
|
||||
hc06_ptr += 2;
|
||||
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum included\n");
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, hc06_ptr, 2);
|
||||
hc06_ptr += 2;
|
||||
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum included\n");
|
||||
} else {
|
||||
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n");
|
||||
PRINTF("IPHC: sicslowpan uncompress_hdr: checksum *NOT* included\n");
|
||||
}
|
||||
uncomp_hdr_len += UIP_UDPH_LEN;
|
||||
}
|
||||
|
@ -1000,7 +1000,7 @@ uncompress_hdr_hc06(uint16_t ip_len)
|
|||
}
|
||||
|
||||
packetbuf_hdr_len = hc06_ptr - packetbuf_ptr;
|
||||
|
||||
|
||||
/* IP length field. */
|
||||
if(ip_len == 0) {
|
||||
int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
|
||||
|
@ -1012,7 +1012,7 @@ uncompress_hdr_hc06(uint16_t ip_len)
|
|||
SICSLOWPAN_IP_BUF->len[0] = (ip_len - UIP_IPH_LEN) >> 8;
|
||||
SICSLOWPAN_IP_BUF->len[1] = (ip_len - UIP_IPH_LEN) & 0x00FF;
|
||||
}
|
||||
|
||||
|
||||
/* length field in UDP header */
|
||||
if(SICSLOWPAN_IP_BUF->proto == UIP_PROTO_UDP) {
|
||||
memcpy(&SICSLOWPAN_UDP_BUF->udplen, &SICSLOWPAN_IP_BUF->len[0], 2);
|
||||
|
@ -1144,7 +1144,7 @@ compress_hdr_hc1(linkaddr_t *link_destaddr)
|
|||
UIP_HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) {
|
||||
/* HC1 encoding */
|
||||
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_HC1_ENCODING] = 0xFB;
|
||||
|
||||
|
||||
/* HC_UDP encoding, ttl, src and dest ports, checksum */
|
||||
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_UDP_ENCODING] = 0xE0;
|
||||
PACKETBUF_HC1_HC_UDP_PTR[PACKETBUF_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl;
|
||||
|
@ -1192,17 +1192,17 @@ uncompress_hdr_hc1(uint16_t ip_len)
|
|||
SICSLOWPAN_IP_BUF->vtc = 0x60;
|
||||
SICSLOWPAN_IP_BUF->tcflow = 0;
|
||||
SICSLOWPAN_IP_BUF->flow = 0;
|
||||
|
||||
|
||||
/* src and dest ip addresses */
|
||||
uip_ip6addr(&SICSLOWPAN_IP_BUF->srcipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->srcipaddr,
|
||||
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_SENDER));
|
||||
uip_ip6addr(&SICSLOWPAN_IP_BUF->destipaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
|
||||
uip_ds6_set_addr_iid(&SICSLOWPAN_IP_BUF->destipaddr,
|
||||
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
|
||||
(uip_lladdr_t *)packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
|
||||
|
||||
uncomp_hdr_len += UIP_IPH_LEN;
|
||||
|
||||
|
||||
/* Next header field */
|
||||
switch(PACKETBUF_HC1_PTR[PACKETBUF_HC1_ENCODING] & 0x06) {
|
||||
case SICSLOWPAN_HC1_NH_ICMP6:
|
||||
|
@ -1248,7 +1248,7 @@ uncompress_hdr_hc1(uint16_t ip_len)
|
|||
/* this shouldn't happen, drop */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* IP length field. */
|
||||
if(ip_len == 0) {
|
||||
int len = packetbuf_datalen() - packetbuf_hdr_len + uncomp_hdr_len - UIP_IPH_LEN;
|
||||
|
@ -1412,7 +1412,7 @@ output(const uip_lladdr_t *localdest)
|
|||
} else {
|
||||
linkaddr_copy(&dest, (const linkaddr_t *)localdest);
|
||||
}
|
||||
|
||||
|
||||
PRINTFO("sicslowpan output: sending packet len %d\n", uip_len);
|
||||
|
||||
if(uip_len >= COMPRESSION_THRESHOLD) {
|
||||
|
@ -1512,7 +1512,7 @@ output(const uip_lladdr_t *localdest)
|
|||
|
||||
/* set processed_ip_out_len to what we already sent from the IP payload*/
|
||||
processed_ip_out_len = packetbuf_payload_len + uncomp_hdr_len;
|
||||
|
||||
|
||||
/*
|
||||
* Create following fragments
|
||||
* Datagram tag is already in the buffer, we need to set the
|
||||
|
@ -1527,7 +1527,7 @@ output(const uip_lladdr_t *localdest)
|
|||
while(processed_ip_out_len < uip_len) {
|
||||
PRINTFO("sicslowpan output: fragment ");
|
||||
PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET] = processed_ip_out_len >> 3;
|
||||
|
||||
|
||||
/* Copy payload and send */
|
||||
if(uip_len - processed_ip_out_len < packetbuf_payload_len) {
|
||||
/* last fragment */
|
||||
|
@ -1759,8 +1759,8 @@ input(void)
|
|||
PACKETBUF_HC1_PTR[PACKETBUF_HC1_DISPATCH]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if SICSLOWPAN_CONF_FRAG
|
||||
copypayload:
|
||||
#endif /*SICSLOWPAN_CONF_FRAG*/
|
||||
|
@ -1791,7 +1791,7 @@ input(void)
|
|||
}
|
||||
|
||||
memcpy((uint8_t *)SICSLOWPAN_IP_BUF + uncomp_hdr_len + (uint16_t)(frag_offset << 3), packetbuf_ptr + packetbuf_hdr_len, packetbuf_payload_len);
|
||||
|
||||
|
||||
/* update processed_ip_in_len if fragment, sicslowpan_len otherwise */
|
||||
|
||||
#if SICSLOWPAN_CONF_FRAG
|
||||
|
@ -1873,13 +1873,13 @@ sicslowpan_init(void)
|
|||
* The platform contiki-conf.h file can override this using e.g.
|
||||
* #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xbb;addr_contexts[0].prefix[1]=0xbb;}
|
||||
*/
|
||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||
#if SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0
|
||||
addr_contexts[0].used = 1;
|
||||
addr_contexts[0].number = 0;
|
||||
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_0
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_0;
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_0;
|
||||
#else
|
||||
addr_contexts[0].prefix[0] = 0xaa;
|
||||
addr_contexts[0].prefix[0] = 0xaa;
|
||||
addr_contexts[0].prefix[1] = 0xaa;
|
||||
#endif
|
||||
#endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 0 */
|
||||
|
@ -1889,23 +1889,22 @@ sicslowpan_init(void)
|
|||
int i;
|
||||
for(i = 1; i < SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS; i++) {
|
||||
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_1
|
||||
if (i==1) {
|
||||
addr_contexts[1].used = 1;
|
||||
addr_contexts[1].number = 1;
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_1;
|
||||
if (i==1) {
|
||||
addr_contexts[1].used = 1;
|
||||
addr_contexts[1].number = 1;
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_1;
|
||||
#ifdef SICSLOWPAN_CONF_ADDR_CONTEXT_2
|
||||
} else if (i==2) {
|
||||
addr_contexts[2].used = 1;
|
||||
addr_contexts[2].number = 2;
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_2;
|
||||
addr_contexts[2].used = 1;
|
||||
addr_contexts[2].number = 2;
|
||||
SICSLOWPAN_CONF_ADDR_CONTEXT_2;
|
||||
#endif
|
||||
} else {
|
||||
addr_contexts[i].used = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
addr_contexts[i].used = 0;
|
||||
#endif /* SICSLOWPAN_CONF_ADDR_CONTEXT_1 */
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS > 1 */
|
||||
|
|
|
@ -203,18 +203,18 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
|
|||
#if UIP_DS6_LL_NUD
|
||||
/* From RFC4861, page 72, last paragraph of section 7.3.3:
|
||||
*
|
||||
* "In some cases, link-specific information may indicate that a path to
|
||||
* a neighbor has failed (e.g., the resetting of a virtual circuit). In
|
||||
* such cases, link-specific information may be used to purge Neighbor
|
||||
* Cache entries before the Neighbor Unreachability Detection would do
|
||||
* so. However, link-specific information MUST NOT be used to confirm
|
||||
* the reachability of a neighbor; such information does not provide
|
||||
* end-to-end confirmation between neighboring IP layers."
|
||||
* "In some cases, link-specific information may indicate that a path to
|
||||
* a neighbor has failed (e.g., the resetting of a virtual circuit). In
|
||||
* such cases, link-specific information may be used to purge Neighbor
|
||||
* Cache entries before the Neighbor Unreachability Detection would do
|
||||
* so. However, link-specific information MUST NOT be used to confirm
|
||||
* the reachability of a neighbor; such information does not provide
|
||||
* end-to-end confirmation between neighboring IP layers."
|
||||
*
|
||||
* However, we assume that receiving a link layer ack ensures the delivery
|
||||
* of the transmitted packed to the IP stack of the neighbour. This is a
|
||||
* fair assumption and allows battery powered nodes save some battery by
|
||||
* not re-testing the state of a neighbour periodically if it
|
||||
* of the transmitted packed to the IP stack of the neighbour. This is a
|
||||
* fair assumption and allows battery powered nodes save some battery by
|
||||
* not re-testing the state of a neighbour periodically if it
|
||||
* acknowledges link packets. */
|
||||
if(status == MAC_TX_OK) {
|
||||
uip_ds6_nbr_t *nbr;
|
||||
|
|
|
@ -297,9 +297,9 @@ uip_ds6_prefix_t *
|
|||
uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen)
|
||||
{
|
||||
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_prefix_list,
|
||||
UIP_DS6_PREFIX_NB, sizeof(uip_ds6_prefix_t),
|
||||
ipaddr, ipaddrlen,
|
||||
(uip_ds6_element_t **)&locprefix) == FOUND) {
|
||||
UIP_DS6_PREFIX_NB, sizeof(uip_ds6_prefix_t),
|
||||
ipaddr, ipaddrlen,
|
||||
(uip_ds6_element_t **)&locprefix) == FOUND) {
|
||||
return locprefix;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -489,8 +489,8 @@ uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr)
|
|||
{
|
||||
#if UIP_DS6_AADDR_NB
|
||||
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_if.aaddr_list,
|
||||
UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128,
|
||||
(uip_ds6_element_t **)&locaaddr) == FOUND) {
|
||||
UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128,
|
||||
(uip_ds6_element_t **)&locaaddr) == FOUND) {
|
||||
return locaaddr;
|
||||
}
|
||||
#endif /* UIP_DS6_AADDR_NB */
|
||||
|
|
|
@ -93,7 +93,7 @@ void uip_log(char *msg);
|
|||
/** \name Pointers to the header structures.
|
||||
* All pointers except UIP_IP_BUF depend on uip_ext_len, which at
|
||||
* packet reception, is the total length of the extension headers.
|
||||
*
|
||||
*
|
||||
* The pointer to ND6 options header also depends on nd6_opt_offset,
|
||||
* which we set in each function.
|
||||
*
|
||||
|
@ -143,7 +143,7 @@ extract_lladdr_aligned(uip_lladdr_t *dest) {
|
|||
}
|
||||
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
/*------------------------------------------------------------------*/
|
||||
/* create a llao */
|
||||
/* create a llao */
|
||||
static void
|
||||
create_llao(uint8_t *llao, uint8_t type) {
|
||||
llao[UIP_ND6_OPT_TYPE_OFFSET] = type;
|
||||
|
@ -361,7 +361,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
|
|||
UIP_IP_BUF->len[0] = 0; /* length will not be more than 255 */
|
||||
/*
|
||||
* check if we add a SLLAO option: for DAD, MUST NOT, for NUD, MAY
|
||||
* (here yes), for Address resolution , MUST
|
||||
* (here yes), for Address resolution , MUST
|
||||
*/
|
||||
if(!(uip_ds6_is_my_addr(tgt))) {
|
||||
if(src != NULL) {
|
||||
|
@ -378,7 +378,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
|
|||
UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN;
|
||||
|
||||
create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_NS_LEN],
|
||||
UIP_ND6_OPT_SLLAO);
|
||||
UIP_ND6_OPT_SLLAO);
|
||||
|
||||
uip_len =
|
||||
UIP_IPH_LEN + UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN;
|
||||
|
@ -437,9 +437,9 @@ na_input(void)
|
|||
PRINTF("\n");
|
||||
UIP_STAT(++uip_stat.nd6.recv);
|
||||
|
||||
/*
|
||||
/*
|
||||
* booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20
|
||||
* but it works. Be careful though, do not use tests such as is_router == 1
|
||||
* but it works. Be careful though, do not use tests such as is_router == 1
|
||||
*/
|
||||
is_llchange = 0;
|
||||
is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));
|
||||
|
@ -505,7 +505,7 @@ na_input(void)
|
|||
goto discard;
|
||||
}
|
||||
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
||||
UIP_LLADDR_LEN);
|
||||
UIP_LLADDR_LEN);
|
||||
if(is_solicited) {
|
||||
nbr->state = NBR_REACHABLE;
|
||||
nbr->nscount = 0;
|
||||
|
@ -528,7 +528,7 @@ na_input(void)
|
|||
|| nd6_opt_llao == 0) {
|
||||
if(nd6_opt_llao != 0) {
|
||||
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
||||
UIP_LLADDR_LEN);
|
||||
UIP_LLADDR_LEN);
|
||||
}
|
||||
if(is_solicited) {
|
||||
nbr->state = NBR_REACHABLE;
|
||||
|
@ -564,7 +564,7 @@ na_input(void)
|
|||
uip_packetqueue_free(&nbr->packethandle);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#endif /*UIP_CONF_IPV6_QUEUE_PKT */
|
||||
|
||||
discard:
|
||||
|
@ -590,7 +590,7 @@ rs_input(void)
|
|||
|
||||
#if UIP_CONF_IPV6_CHECKS
|
||||
/*
|
||||
* Check hop limit / icmp code
|
||||
* Check hop limit / icmp code
|
||||
* target address must not be multicast
|
||||
* if the NA is solicited, dest must not be multicast
|
||||
*/
|
||||
|
@ -796,7 +796,7 @@ uip_nd6_rs_output(void)
|
|||
UIP_ICMPH_LEN + UIP_ND6_RS_LEN + UIP_ND6_OPT_LLAO_LEN;
|
||||
|
||||
create_llao(&uip_buf[uip_l2_l3_icmp_hdr_len + UIP_ND6_RS_LEN],
|
||||
UIP_ND6_OPT_SLLAO);
|
||||
UIP_ND6_OPT_SLLAO);
|
||||
}
|
||||
|
||||
UIP_ICMP_BUF->icmpchksum = 0;
|
||||
|
@ -877,9 +877,9 @@ ra_input(void)
|
|||
nbr->state = NBR_STALE;
|
||||
}
|
||||
if(memcmp(&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
||||
lladdr, UIP_LLADDR_LEN) != 0) {
|
||||
lladdr, UIP_LLADDR_LEN) != 0) {
|
||||
memcpy(lladdr, &nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET],
|
||||
UIP_LLADDR_LEN);
|
||||
UIP_LLADDR_LEN);
|
||||
nbr->state = NBR_STALE;
|
||||
}
|
||||
nbr->isrouter = 1;
|
||||
|
@ -937,7 +937,7 @@ ra_input(void)
|
|||
if((nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_AUTONOMOUS)
|
||||
&& (nd6_opt_prefix_info->validlt != 0)
|
||||
&& (nd6_opt_prefix_info->preflen == UIP_DEFAULT_PREFIX_LEN)) {
|
||||
|
||||
|
||||
uip_ipaddr_copy(&ipaddr, &nd6_opt_prefix_info->prefix);
|
||||
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
||||
addr = uip_ds6_addr_lookup(&ipaddr);
|
||||
|
|
|
@ -128,9 +128,9 @@
|
|||
#endif
|
||||
|
||||
#ifdef UIP_CONF_ND6_RETRANS_TIMER
|
||||
#define UIP_ND6_RETRANS_TIMER UIP_CONF_ND6_RETRANS_TIMER
|
||||
#define UIP_ND6_RETRANS_TIMER UIP_CONF_ND6_RETRANS_TIMER
|
||||
#else
|
||||
#define UIP_ND6_RETRANS_TIMER 1000
|
||||
#define UIP_ND6_RETRANS_TIMER 1000
|
||||
#endif
|
||||
|
||||
#define UIP_ND6_DELAY_FIRST_PROBE_TIME 5
|
||||
|
|
|
@ -103,7 +103,7 @@ void uip_log(char *msg);
|
|||
#if UIP_STATISTICS == 1
|
||||
struct uip_stats uip_stat;
|
||||
#endif /* UIP_STATISTICS == 1 */
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -299,15 +299,15 @@ uip_add32(uint8_t *op32, uint16_t op16)
|
|||
uip_acc32[2] = op32[2] + (op16 >> 8);
|
||||
uip_acc32[1] = op32[1];
|
||||
uip_acc32[0] = op32[0];
|
||||
|
||||
|
||||
if(uip_acc32[2] < (op16 >> 8)) {
|
||||
++uip_acc32[1];
|
||||
if(uip_acc32[1] == 0) {
|
||||
++uip_acc32[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(uip_acc32[3] < (op16 & 0xff)) {
|
||||
++uip_acc32[2];
|
||||
if(uip_acc32[2] == 0) {
|
||||
|
@ -332,7 +332,7 @@ chksum(uint16_t sum, const uint8_t *data, uint16_t len)
|
|||
|
||||
dataptr = data;
|
||||
last_byte = data + len - 1;
|
||||
|
||||
|
||||
while(dataptr < last_byte) { /* At least two more bytes */
|
||||
t = (dataptr[0] << 8) + dataptr[1];
|
||||
sum += t;
|
||||
|
@ -341,7 +341,7 @@ chksum(uint16_t sum, const uint8_t *data, uint16_t len)
|
|||
}
|
||||
dataptr += 2;
|
||||
}
|
||||
|
||||
|
||||
if(dataptr == last_byte) {
|
||||
t = (dataptr[0] << 8) + 0;
|
||||
sum += t;
|
||||
|
@ -386,11 +386,11 @@ upper_layer_chksum(uint8_t proto)
|
|||
*/
|
||||
volatile uint16_t upper_layer_len;
|
||||
uint16_t sum;
|
||||
|
||||
|
||||
upper_layer_len = (((uint16_t)(UIP_IP_BUF->len[0]) << 8) + UIP_IP_BUF->len[1] - uip_ext_len);
|
||||
|
||||
|
||||
PRINTF("Upper layer checksum len: %d from: %d\n", upper_layer_len,
|
||||
UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len);
|
||||
UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len);
|
||||
|
||||
/* First sum pseudoheader. */
|
||||
/* IP protocol and length fields. This addition cannot carry. */
|
||||
|
@ -401,7 +401,7 @@ upper_layer_chksum(uint8_t proto)
|
|||
/* Sum TCP header and data. */
|
||||
sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len],
|
||||
upper_layer_len);
|
||||
|
||||
|
||||
return (sum == 0) ? 0xffff : uip_htons(sum);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -409,7 +409,7 @@ uint16_t
|
|||
uip_icmp6chksum(void)
|
||||
{
|
||||
return upper_layer_chksum(UIP_PROTO_ICMP6);
|
||||
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_TCP
|
||||
|
@ -432,7 +432,7 @@ uip_udpchksum(void)
|
|||
void
|
||||
uip_init(void)
|
||||
{
|
||||
|
||||
|
||||
uip_ds6_init();
|
||||
uip_icmp6_init();
|
||||
uip_nd6_init();
|
||||
|
@ -466,7 +466,7 @@ struct uip_conn *
|
|||
uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||
{
|
||||
register struct uip_conn *conn, *cconn;
|
||||
|
||||
|
||||
/* Find an unused local port. */
|
||||
again:
|
||||
++lastport;
|
||||
|
@ -503,7 +503,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
if(conn == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
conn->tcpstateflags = UIP_SYN_SENT;
|
||||
|
||||
conn->snd_nxt[0] = iss[0];
|
||||
|
@ -517,7 +517,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
conn->rcv_nxt[3] = 0;
|
||||
|
||||
conn->initialmss = conn->mss = UIP_TCP_MSS;
|
||||
|
||||
|
||||
conn->len = 1; /* TCP length of the SYN is one. */
|
||||
conn->nrtx = 0;
|
||||
conn->timer = 1; /* Send the SYN next time around. */
|
||||
|
@ -527,7 +527,7 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
conn->lport = uip_htons(lastport);
|
||||
conn->rport = rport;
|
||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
|
||||
|
||||
return conn;
|
||||
}
|
||||
#endif /* UIP_TCP && UIP_ACTIVE_OPEN */
|
||||
|
@ -538,14 +538,14 @@ remove_ext_hdr(void)
|
|||
/* Remove ext header before TCP/UDP processing. */
|
||||
if(uip_ext_len > 0) {
|
||||
PRINTF("Cutting ext-header before processing (extlen: %d, uiplen: %d)\n",
|
||||
uip_ext_len, uip_len);
|
||||
uip_ext_len, uip_len);
|
||||
if(uip_len < UIP_IPH_LEN + uip_ext_len) {
|
||||
PRINTF("ERROR: uip_len too short compared to ext len\n");
|
||||
uip_clear_buf();
|
||||
return;
|
||||
}
|
||||
memmove(((uint8_t *)UIP_TCP_BUF), (uint8_t *)UIP_TCP_BUF + uip_ext_len,
|
||||
uip_len - UIP_IPH_LEN - uip_ext_len);
|
||||
uip_len - UIP_IPH_LEN - uip_ext_len);
|
||||
|
||||
uip_len -= uip_ext_len;
|
||||
|
||||
|
@ -561,7 +561,7 @@ struct uip_udp_conn *
|
|||
uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||
{
|
||||
register struct uip_udp_conn *conn;
|
||||
|
||||
|
||||
/* Find an unused local port. */
|
||||
again:
|
||||
++lastport;
|
||||
|
@ -569,7 +569,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
if(lastport >= 32000) {
|
||||
lastport = 4096;
|
||||
}
|
||||
|
||||
|
||||
for(c = 0; c < UIP_UDP_CONNS; ++c) {
|
||||
if(uip_udp_conns[c].lport == uip_htons(lastport)) {
|
||||
goto again;
|
||||
|
@ -587,7 +587,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
if(conn == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
conn->lport = UIP_HTONS(lastport);
|
||||
conn->rport = rport;
|
||||
if(ripaddr == NULL) {
|
||||
|
@ -596,7 +596,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
|||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
}
|
||||
conn->ttl = uip_ds6_if.cur_hop_limit;
|
||||
|
||||
|
||||
return conn;
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
@ -668,7 +668,7 @@ uip_reass(void)
|
|||
uint16_t offset=0;
|
||||
uint16_t len;
|
||||
uint16_t i;
|
||||
|
||||
|
||||
/* If ip_reasstmr is zero, no packet is present in the buffer */
|
||||
/* We first write the unfragmentable part of IP header into the reassembly
|
||||
buffer. The reset the other reassembly variables. */
|
||||
|
@ -710,9 +710,9 @@ uip_reass(void)
|
|||
PRINTF("dest ");
|
||||
PRINT6ADDR(&FBUF->destipaddr);
|
||||
PRINTF("next %d\n", UIP_IP_BUF->proto);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* If the offset or the offset + fragment length overflows the
|
||||
reassembly buffer, we discard the entire packet. */
|
||||
if(offset > UIP_REASS_BUFSIZE ||
|
||||
|
@ -744,12 +744,12 @@ uip_reass(void)
|
|||
return uip_len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Copy the fragment into the reassembly buffer, at the right
|
||||
offset. */
|
||||
memcpy((uint8_t *)FBUF + UIP_IPH_LEN + uip_ext_len + offset,
|
||||
(uint8_t *)UIP_FRAG_BUF + UIP_FRAGH_LEN, len);
|
||||
|
||||
|
||||
/* Update the bitmap. */
|
||||
if(offset >> 6 == (offset + len) >> 6) {
|
||||
uip_reassbitmap[offset >> 6] |=
|
||||
|
@ -760,18 +760,18 @@ uip_reass(void)
|
|||
bytes in the endpoints and fill the stuff inbetween with
|
||||
0xff. */
|
||||
uip_reassbitmap[offset >> 6] |= bitmap_bits[(offset >> 3) & 7];
|
||||
|
||||
|
||||
for(i = (1 + (offset >> 6)); i < ((offset + len) >> 6); ++i) {
|
||||
uip_reassbitmap[i] = 0xff;
|
||||
}
|
||||
uip_reassbitmap[(offset + len) >> 6] |=
|
||||
~bitmap_bits[((offset + len) >> 3) & 7];
|
||||
}
|
||||
|
||||
|
||||
/* Finally, we check if we have a full packet in the buffer. We do
|
||||
this by checking if we have the last fragment and if all bits
|
||||
in the bitmap are set. */
|
||||
|
||||
|
||||
if(uip_reassflags & UIP_REASS_FLAG_LASTFRAG) {
|
||||
/* Check all bytes up to and including all but the last byte in
|
||||
the bitmap. */
|
||||
|
@ -798,9 +798,9 @@ uip_reass(void)
|
|||
UIP_IP_BUF->len[1] = ((uip_reasslen - UIP_IPH_LEN) & 0xff);
|
||||
PRINTF("REASSEMBLED PAQUET %d (%d)\n", uip_reasslen,
|
||||
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
|
||||
|
||||
|
||||
return uip_reasslen;
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
PRINTF("Already reassembling another paquet\n");
|
||||
|
@ -831,7 +831,7 @@ uip_reass_over(void)
|
|||
memcpy(UIP_IP_BUF, FBUF, UIP_IPH_LEN); /* copy the header for src
|
||||
and dest address*/
|
||||
uip_icmp6_error_output(ICMP6_TIME_EXCEEDED, ICMP6_TIME_EXCEED_REASSEMBLY, 0);
|
||||
|
||||
|
||||
UIP_STAT(++uip_stat.ip.sent);
|
||||
uip_flags = 0;
|
||||
}
|
||||
|
@ -881,14 +881,14 @@ ext_hdr_options_process(void)
|
|||
uip_ext_opt_offset += UIP_EXT_HDR_OPT_PADN_BUF->opt_len + 2;
|
||||
break;
|
||||
case UIP_EXT_HDR_OPT_RPL:
|
||||
/* Fixes situation when a node that is not using RPL
|
||||
* joins a network which does. The received packages will include the
|
||||
* RPL header and processed by the "default" case of the switch
|
||||
* (0x63 & 0xC0 = 0x40). Hence, the packet is discarded as the header
|
||||
* is considered invalid.
|
||||
* Using this fix, the header is ignored, and the next header (if
|
||||
* present) is processed.
|
||||
*/
|
||||
/* Fixes situation when a node that is not using RPL
|
||||
* joins a network which does. The received packages will include the
|
||||
* RPL header and processed by the "default" case of the switch
|
||||
* (0x63 & 0xC0 = 0x40). Hence, the packet is discarded as the header
|
||||
* is considered invalid.
|
||||
* Using this fix, the header is ignored, and the next header (if
|
||||
* present) is processed.
|
||||
*/
|
||||
#if UIP_CONF_IPV6_RPL
|
||||
PRINTF("Processing RPL option\n");
|
||||
if(rpl_verify_header(uip_ext_opt_offset)) {
|
||||
|
@ -949,7 +949,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
#endif /* UIP_UDP */
|
||||
uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];
|
||||
|
||||
|
||||
/* Check if we were invoked because of a poll request for a
|
||||
particular connection. */
|
||||
if(flag == UIP_POLL_REQUEST) {
|
||||
|
@ -974,7 +974,7 @@ uip_process(uint8_t flag)
|
|||
#if UIP_TCP
|
||||
uip_clear_buf();
|
||||
uip_slen = 0;
|
||||
|
||||
|
||||
/* Increase the initial sequence number. */
|
||||
if(++iss[3] == 0) {
|
||||
if(++iss[2] == 0) {
|
||||
|
@ -983,7 +983,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if the connection is in a state in which we simply wait
|
||||
* for the connection to time out. If so, we increase the
|
||||
|
@ -1009,7 +1009,7 @@ uip_process(uint8_t flag)
|
|||
uip_connr->tcpstateflags == UIP_SYN_RCVD) &&
|
||||
uip_connr->nrtx == UIP_MAXSYNRTX)) {
|
||||
uip_connr->tcpstateflags = UIP_CLOSED;
|
||||
|
||||
|
||||
/*
|
||||
* We call UIP_APPCALL() with uip_flags set to
|
||||
* UIP_TIMEDOUT to inform the application that the
|
||||
|
@ -1017,18 +1017,18 @@ uip_process(uint8_t flag)
|
|||
*/
|
||||
uip_flags = UIP_TIMEDOUT;
|
||||
UIP_APPCALL();
|
||||
|
||||
|
||||
/* We also send a reset packet to the remote host. */
|
||||
UIP_TCP_BUF->flags = TCP_RST | TCP_ACK;
|
||||
goto tcp_send_nodata;
|
||||
}
|
||||
|
||||
|
||||
/* Exponential backoff. */
|
||||
uip_connr->timer = UIP_RTO << (uip_connr->nrtx > 4?
|
||||
4:
|
||||
uip_connr->nrtx);
|
||||
++(uip_connr->nrtx);
|
||||
|
||||
|
||||
/*
|
||||
* Ok, so we need to retransmit. We do this differently
|
||||
* depending on which state we are in. In ESTABLISHED, we
|
||||
|
@ -1042,14 +1042,14 @@ uip_process(uint8_t flag)
|
|||
case UIP_SYN_RCVD:
|
||||
/* In the SYN_RCVD state, we should retransmit our SYNACK. */
|
||||
goto tcp_send_synack;
|
||||
|
||||
|
||||
#if UIP_ACTIVE_OPEN
|
||||
case UIP_SYN_SENT:
|
||||
/* In the SYN_SENT state, we retransmit out SYN. */
|
||||
UIP_TCP_BUF->flags = 0;
|
||||
goto tcp_send_syn;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
/*
|
||||
* In the ESTABLISHED state, we call upon the application
|
||||
|
@ -1060,7 +1060,7 @@ uip_process(uint8_t flag)
|
|||
uip_flags = UIP_REXMIT;
|
||||
UIP_APPCALL();
|
||||
goto apprexmit;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
case UIP_CLOSING:
|
||||
case UIP_LAST_ACK:
|
||||
|
@ -1096,12 +1096,12 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
|
||||
|
||||
/* This is where the input processing starts. */
|
||||
UIP_STAT(++uip_stat.ip.recv);
|
||||
|
||||
|
||||
/* Start of IP input header processing code. */
|
||||
|
||||
|
||||
/* Check validity of the IP header. */
|
||||
if((UIP_IP_BUF->vtc & 0xf0) != 0x60) { /* IP version and header length. */
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
|
@ -1117,7 +1117,7 @@ uip_process(uint8_t flag)
|
|||
* the packet has been padded and we set uip_len to the correct
|
||||
* value..
|
||||
*/
|
||||
|
||||
|
||||
if((UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] <= uip_len) {
|
||||
uip_len = (UIP_IP_BUF->len[0] << 8) + UIP_IP_BUF->len[1] + UIP_IPH_LEN;
|
||||
/*
|
||||
|
@ -1135,7 +1135,7 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("ip: packet shorter than reported in IP header.");
|
||||
goto drop;
|
||||
}
|
||||
|
||||
|
||||
PRINTF("IPv6 packet received from ");
|
||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||
PRINTF(" to ");
|
||||
|
@ -1168,11 +1168,11 @@ uip_process(uint8_t flag)
|
|||
uip_ext_len += (UIP_EXT_BUF->len << 3) + 8;
|
||||
break;
|
||||
case 1:
|
||||
PRINTF("Dropping packet after extension header processing\n");
|
||||
PRINTF("Dropping packet after extension header processing\n");
|
||||
/* silently discard */
|
||||
goto drop;
|
||||
case 2:
|
||||
PRINTF("Sending error message after extension header processing\n");
|
||||
PRINTF("Sending error message after extension header processing\n");
|
||||
/* send icmp error message (created in ext_hdr_options_process)
|
||||
* and discard*/
|
||||
goto send;
|
||||
|
@ -1417,7 +1417,7 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("ip6: unrecognized header");
|
||||
goto send;
|
||||
/* End of headers processing */
|
||||
|
||||
|
||||
icmp6_input:
|
||||
/* This is IPv6 ICMPv6 processing code. */
|
||||
PRINTF("icmp6_input: length %d type: %d \n", uip_len, UIP_ICMP_BUF->type);
|
||||
|
@ -1459,14 +1459,14 @@ uip_process(uint8_t flag)
|
|||
UIP_LOG("icmp6: unknown ICMPv6 message.");
|
||||
uip_clear_buf();
|
||||
}
|
||||
|
||||
|
||||
if(uip_len > 0) {
|
||||
goto send;
|
||||
} else {
|
||||
goto drop;
|
||||
}
|
||||
/* End of IPv6 ICMP processing. */
|
||||
|
||||
|
||||
|
||||
#if UIP_UDP
|
||||
/* UDP input processing. */
|
||||
|
@ -1475,7 +1475,7 @@ uip_process(uint8_t flag)
|
|||
remove_ext_hdr();
|
||||
|
||||
PRINTF("Receiving UDP packet\n");
|
||||
|
||||
|
||||
/* UDP processing is really just a hack. We don't do anything to the
|
||||
UDP/IP headers, but let the UDP application do all the hard
|
||||
work. If the application sets uip_slen, it has a packet to
|
||||
|
@ -1538,7 +1538,7 @@ uip_process(uint8_t flag)
|
|||
udp_found:
|
||||
PRINTF("In udp_found\n");
|
||||
UIP_STAT(++uip_stat.udp.recv);
|
||||
|
||||
|
||||
uip_conn = NULL;
|
||||
uip_flags = UIP_NEWDATA;
|
||||
uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN];
|
||||
|
@ -1597,7 +1597,7 @@ uip_process(uint8_t flag)
|
|||
UIP_STAT(++uip_stat.tcp.recv);
|
||||
PRINTF("Receiving TCP packet\n");
|
||||
/* Start of TCP input header processing code. */
|
||||
|
||||
|
||||
if(uip_tcpchksum() != 0xffff) { /* Compute and check the TCP
|
||||
checksum. */
|
||||
UIP_STAT(++uip_stat.tcp.drop);
|
||||
|
@ -1632,7 +1632,7 @@ uip_process(uint8_t flag)
|
|||
if((UIP_TCP_BUF->flags & TCP_CTL) != TCP_SYN) {
|
||||
goto reset;
|
||||
}
|
||||
|
||||
|
||||
tmp16 = UIP_TCP_BUF->destport;
|
||||
/* Next, check listening connections. */
|
||||
for(c = 0; c < UIP_LISTENPORTS; ++c) {
|
||||
|
@ -1640,7 +1640,7 @@ uip_process(uint8_t flag)
|
|||
goto found_listen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* No matching connection found, so we send a RST packet. */
|
||||
UIP_STAT(++uip_stat.tcp.synrst);
|
||||
|
||||
|
@ -1652,7 +1652,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
|
||||
UIP_STAT(++uip_stat.tcp.rst);
|
||||
|
||||
|
||||
UIP_TCP_BUF->flags = TCP_RST | TCP_ACK;
|
||||
uip_len = UIP_IPTCPH_LEN;
|
||||
UIP_TCP_BUF->tcpoffset = 5 << 4;
|
||||
|
@ -1661,15 +1661,15 @@ uip_process(uint8_t flag)
|
|||
c = UIP_TCP_BUF->seqno[3];
|
||||
UIP_TCP_BUF->seqno[3] = UIP_TCP_BUF->ackno[3];
|
||||
UIP_TCP_BUF->ackno[3] = c;
|
||||
|
||||
|
||||
c = UIP_TCP_BUF->seqno[2];
|
||||
UIP_TCP_BUF->seqno[2] = UIP_TCP_BUF->ackno[2];
|
||||
UIP_TCP_BUF->ackno[2] = c;
|
||||
|
||||
|
||||
c = UIP_TCP_BUF->seqno[1];
|
||||
UIP_TCP_BUF->seqno[1] = UIP_TCP_BUF->ackno[1];
|
||||
UIP_TCP_BUF->ackno[1] = c;
|
||||
|
||||
|
||||
c = UIP_TCP_BUF->seqno[0];
|
||||
UIP_TCP_BUF->seqno[0] = UIP_TCP_BUF->ackno[0];
|
||||
UIP_TCP_BUF->ackno[0] = c;
|
||||
|
@ -1684,12 +1684,12 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Swap port numbers. */
|
||||
tmp16 = UIP_TCP_BUF->srcport;
|
||||
UIP_TCP_BUF->srcport = UIP_TCP_BUF->destport;
|
||||
UIP_TCP_BUF->destport = tmp16;
|
||||
|
||||
|
||||
/* Swap IP addresses. */
|
||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &UIP_IP_BUF->srcipaddr);
|
||||
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||
|
@ -1730,7 +1730,7 @@ uip_process(uint8_t flag)
|
|||
goto drop;
|
||||
}
|
||||
uip_conn = uip_connr;
|
||||
|
||||
|
||||
/* Fill in the necessary fields for the new connection. */
|
||||
uip_connr->rto = uip_connr->timer = UIP_RTO;
|
||||
uip_connr->sa = 0;
|
||||
|
@ -1771,7 +1771,7 @@ uip_process(uint8_t flag)
|
|||
(uint16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c];
|
||||
uip_connr->initialmss = uip_connr->mss =
|
||||
tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16;
|
||||
|
||||
|
||||
/* And we are done processing options. */
|
||||
break;
|
||||
} else {
|
||||
|
@ -1786,19 +1786,19 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Our response will be a SYNACK. */
|
||||
#if UIP_ACTIVE_OPEN
|
||||
tcp_send_synack:
|
||||
UIP_TCP_BUF->flags = TCP_ACK;
|
||||
|
||||
|
||||
tcp_send_syn:
|
||||
UIP_TCP_BUF->flags |= TCP_SYN;
|
||||
#else /* UIP_ACTIVE_OPEN */
|
||||
tcp_send_synack:
|
||||
UIP_TCP_BUF->flags = TCP_SYN | TCP_ACK;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
/* We send out the TCP Maximum Segment Size option with our
|
||||
SYNACK. */
|
||||
UIP_TCP_BUF->optdata[0] = TCP_OPT_MSS;
|
||||
|
@ -1839,9 +1839,9 @@ uip_process(uint8_t flag)
|
|||
receive a SYN, in which case we should retransmit our SYNACK
|
||||
(which is done futher down). */
|
||||
if(!((((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) &&
|
||||
((UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) ||
|
||||
((UIP_TCP_BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) ||
|
||||
(((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) &&
|
||||
((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN)))) {
|
||||
((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN)))) {
|
||||
if((uip_len > 0 || ((UIP_TCP_BUF->flags & (TCP_SYN | TCP_FIN)) != 0)) &&
|
||||
(UIP_TCP_BUF->seqno[0] != uip_connr->rcv_nxt[0] ||
|
||||
UIP_TCP_BUF->seqno[1] != uip_connr->rcv_nxt[1] ||
|
||||
|
@ -1875,7 +1875,7 @@ uip_process(uint8_t flag)
|
|||
uip_connr->snd_nxt[1] = uip_acc32[1];
|
||||
uip_connr->snd_nxt[2] = uip_acc32[2];
|
||||
uip_connr->snd_nxt[3] = uip_acc32[3];
|
||||
|
||||
|
||||
/* Do RTT estimation, unless we have done retransmissions. */
|
||||
if(uip_connr->nrtx == 0) {
|
||||
signed char m;
|
||||
|
@ -1899,7 +1899,7 @@ uip_process(uint8_t flag)
|
|||
/* Reset length of outstanding data. */
|
||||
uip_connr->len = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Do different things depending on in what state the connection is. */
|
||||
|
@ -1927,7 +1927,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
/* We need to retransmit the SYNACK */
|
||||
if((UIP_TCP_BUF->flags & TCP_CTL) == TCP_SYN) {
|
||||
goto tcp_send_synack;
|
||||
goto tcp_send_synack;
|
||||
}
|
||||
goto drop;
|
||||
#if UIP_ACTIVE_OPEN
|
||||
|
@ -1991,7 +1991,7 @@ uip_process(uint8_t flag)
|
|||
uip_conn->tcpstateflags = UIP_CLOSED;
|
||||
goto reset;
|
||||
#endif /* UIP_ACTIVE_OPEN */
|
||||
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
/* In the ESTABLISHED state, we call upon the application to feed
|
||||
data into the uip_buf. If the UIP_ACKDATA flag is set, the
|
||||
|
@ -2093,7 +2093,7 @@ uip_process(uint8_t flag)
|
|||
UIP_APPCALL();
|
||||
|
||||
appsend:
|
||||
|
||||
|
||||
if(uip_flags & UIP_ABORT) {
|
||||
uip_slen = 0;
|
||||
uip_connr->tcpstateflags = UIP_CLOSED;
|
||||
|
@ -2145,7 +2145,7 @@ uip_process(uint8_t flag)
|
|||
uip_connr->nrtx = 0;
|
||||
apprexmit:
|
||||
uip_appdata = uip_sappdata;
|
||||
|
||||
|
||||
/* If the application has data to be sent, or if the incoming
|
||||
packet had new data in it, we must send out a packet. */
|
||||
if(uip_slen > 0 && uip_connr->len > 0) {
|
||||
|
@ -2174,7 +2174,7 @@ uip_process(uint8_t flag)
|
|||
UIP_APPCALL();
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
/* The application has closed the connection, but the remote host
|
||||
hasn't closed its end yet. Thus we do nothing but wait for a
|
||||
|
@ -2203,7 +2203,7 @@ uip_process(uint8_t flag)
|
|||
goto tcp_send_ack;
|
||||
}
|
||||
goto drop;
|
||||
|
||||
|
||||
case UIP_FIN_WAIT_2:
|
||||
if(uip_len > 0) {
|
||||
uip_add_rcv_nxt(uip_len);
|
||||
|
@ -2223,7 +2223,7 @@ uip_process(uint8_t flag)
|
|||
|
||||
case UIP_TIME_WAIT:
|
||||
goto tcp_send_ack;
|
||||
|
||||
|
||||
case UIP_CLOSING:
|
||||
if(uip_flags & UIP_ACKDATA) {
|
||||
uip_connr->tcpstateflags = UIP_TIME_WAIT;
|
||||
|
@ -2231,7 +2231,7 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
}
|
||||
goto drop;
|
||||
|
||||
|
||||
/* We jump here when we are ready to send the packet, and just want
|
||||
to set the appropriate TCP sequence numbers in the TCP header. */
|
||||
tcp_send_ack:
|
||||
|
@ -2249,12 +2249,12 @@ uip_process(uint8_t flag)
|
|||
packet. */
|
||||
tcp_send:
|
||||
PRINTF("In tcp_send\n");
|
||||
|
||||
|
||||
UIP_TCP_BUF->ackno[0] = uip_connr->rcv_nxt[0];
|
||||
UIP_TCP_BUF->ackno[1] = uip_connr->rcv_nxt[1];
|
||||
UIP_TCP_BUF->ackno[2] = uip_connr->rcv_nxt[2];
|
||||
UIP_TCP_BUF->ackno[3] = uip_connr->rcv_nxt[3];
|
||||
|
||||
|
||||
UIP_TCP_BUF->seqno[0] = uip_connr->snd_nxt[0];
|
||||
UIP_TCP_BUF->seqno[1] = uip_connr->snd_nxt[1];
|
||||
UIP_TCP_BUF->seqno[2] = uip_connr->snd_nxt[2];
|
||||
|
@ -2288,7 +2288,7 @@ uip_process(uint8_t flag)
|
|||
UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
|
||||
|
||||
UIP_TCP_BUF->urgp[0] = UIP_TCP_BUF->urgp[1] = 0;
|
||||
|
||||
|
||||
/* Calculate TCP checksum. */
|
||||
UIP_TCP_BUF->tcpchksum = 0;
|
||||
UIP_TCP_BUF->tcpchksum = ~(uip_tcpchksum());
|
||||
|
@ -2304,7 +2304,7 @@ uip_process(uint8_t flag)
|
|||
send:
|
||||
PRINTF("Sending packet with length %d (%d)\n", uip_len,
|
||||
(UIP_IP_BUF->len[0] << 8) | UIP_IP_BUF->len[1]);
|
||||
|
||||
|
||||
UIP_STAT(++uip_stat.ip.sent);
|
||||
/* Return and let the caller do the actual transmission. */
|
||||
uip_flags = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue