Merge pull request #215 from joakimeriksson/contrib/uipbuf
Uipbuf attributes and moving in transmission number into uipbuf attribute.
This commit is contained in:
commit
76d549fc00
|
@ -200,18 +200,18 @@ platform_init_stage_three(void)
|
||||||
cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
|
cc2420_set_pan_addr(IEEE802154_PANID, shortaddr, longaddr);
|
||||||
|
|
||||||
if(node_id > 0) {
|
if(node_id > 0) {
|
||||||
LOG_INFO("Node id is set to %u.\n", node_id);
|
LOG_INFO("Node id: %u\n", node_id);
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Node id is not set.\n");
|
LOG_INFO("Node id: N/A\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
LOG_INFO("%s, radio channel %u, CCA threshold %i\n",
|
LOG_INFO("%s, rf channel %u, CCA threshold %i\n",
|
||||||
NETSTACK_MAC.name,
|
NETSTACK_MAC.name,
|
||||||
CC2420_CONF_CHANNEL,
|
CC2420_CONF_CHANNEL,
|
||||||
CC2420_CONF_CCA_THRESH);
|
CC2420_CONF_CCA_THRESH);
|
||||||
#else /* NETSTACK_CONF_WITH_IPV6 */
|
#else /* NETSTACK_CONF_WITH_IPV6 */
|
||||||
LOG_INFO("%s, radio channel %u\n",
|
LOG_INFO("%s, rf channel %u\n",
|
||||||
NETSTACK_MAC.name, CC2420_CONF_CHANNEL);
|
NETSTACK_MAC.name, CC2420_CONF_CHANNEL);
|
||||||
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
#endif /* NETSTACK_CONF_WITH_IPV6 */
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ udp_rx_callback(struct simple_udp_connection *c,
|
||||||
uint16_t datalen)
|
uint16_t datalen)
|
||||||
{
|
{
|
||||||
unsigned count = *(unsigned *)data;
|
unsigned count = *(unsigned *)data;
|
||||||
LOG_INFO("Received response %u from ", count);
|
/* If tagging of traffic class is enabled tc will print number of
|
||||||
|
transmission - otherwise it will be 0 */
|
||||||
|
LOG_INFO("Received response %u (tc:%d) from ", count,
|
||||||
|
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||||
LOG_INFO_6ADDR(sender_addr);
|
LOG_INFO_6ADDR(sender_addr);
|
||||||
LOG_INFO_("\n");
|
LOG_INFO_("\n");
|
||||||
}
|
}
|
||||||
|
@ -61,6 +64,12 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||||
LOG_INFO("Sending request %u to ", count);
|
LOG_INFO("Sending request %u to ", count);
|
||||||
LOG_INFO_6ADDR(&dag->dag_id);
|
LOG_INFO_6ADDR(&dag->dag_id);
|
||||||
LOG_INFO_("\n");
|
LOG_INFO_("\n");
|
||||||
|
/* Set the number of transmissions to use for this packet -
|
||||||
|
this can be used to create more reliable transmissions or
|
||||||
|
less reliable than the default. Works end-to-end if
|
||||||
|
UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1.
|
||||||
|
*/
|
||||||
|
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5);
|
||||||
simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id);
|
simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,10 +86,8 @@ main(void)
|
||||||
|
|
||||||
LOG_INFO("Starting " CONTIKI_VERSION_STRING "\n");
|
LOG_INFO("Starting " CONTIKI_VERSION_STRING "\n");
|
||||||
|
|
||||||
LOG_INFO(" Net: ");
|
LOG_INFO(" Net: %s\n", NETSTACK_NETWORK.name);
|
||||||
LOG_INFO_("%s\n", NETSTACK_NETWORK.name);
|
LOG_INFO(" MAC: %s\n", NETSTACK_MAC.name);
|
||||||
LOG_INFO(" MAC: ");
|
|
||||||
LOG_INFO_("%s\n", NETSTACK_MAC.name);
|
|
||||||
|
|
||||||
netstack_init();
|
netstack_init();
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "net/ipv6/tcpip.h"
|
#include "net/ipv6/tcpip.h"
|
||||||
#include "net/ipv6/uip.h"
|
#include "net/ipv6/uip.h"
|
||||||
#include "net/ipv6/uip-ds6.h"
|
#include "net/ipv6/uip-ds6.h"
|
||||||
|
#include "net/ipv6/uipbuf.h"
|
||||||
#include "net/ipv6/sicslowpan.h"
|
#include "net/ipv6/sicslowpan.h"
|
||||||
#include "net/netstack.h"
|
#include "net/netstack.h"
|
||||||
#include "net/packetbuf.h"
|
#include "net/packetbuf.h"
|
||||||
|
@ -1504,17 +1505,6 @@ output(const linkaddr_t *localdest)
|
||||||
set_packet_attrs();
|
set_packet_attrs();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
{
|
|
||||||
uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
|
|
||||||
if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) {
|
|
||||||
uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK;
|
|
||||||
/* propagate the MAC transmission limit to lower layers */
|
|
||||||
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The destination address will be tagged to each outbound
|
* The destination address will be tagged to each outbound
|
||||||
* packet. If the argument localdest is NULL, we are sending a
|
* packet. If the argument localdest is NULL, we are sending a
|
||||||
|
@ -1528,6 +1518,10 @@ output(const linkaddr_t *localdest)
|
||||||
|
|
||||||
LOG_INFO("output: sending packet len %d\n", uip_len);
|
LOG_INFO("output: sending packet len %d\n", uip_len);
|
||||||
|
|
||||||
|
/* copy over the retransmission count from uipbuf attributes */
|
||||||
|
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||||
|
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||||
|
|
||||||
/* Try to compress the headers */
|
/* Try to compress the headers */
|
||||||
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6
|
#if SICSLOWPAN_COMPRESSION == SICSLOWPAN_COMPRESSION_IPV6
|
||||||
compress_hdr_ipv6(&dest);
|
compress_hdr_ipv6(&dest);
|
||||||
|
|
|
@ -121,6 +121,19 @@ uint8_t
|
||||||
tcpip_output(const uip_lladdr_t *a)
|
tcpip_output(const uip_lladdr_t *a)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* Tag Traffic Class if we are using TC for variable retrans */
|
||||||
|
#if UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||||
|
if(uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS) !=
|
||||||
|
UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
||||||
|
LOG_INFO("Tagging TC with retrans: %d\n", uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS));
|
||||||
|
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
||||||
|
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
||||||
|
UIP_IP_BUF->tcflow =
|
||||||
|
uipbuf_get_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS) << 4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if(netstack_process_ip_callback(NETSTACK_IP_OUTPUT, (const linkaddr_t *)a) ==
|
if(netstack_process_ip_callback(NETSTACK_IP_OUTPUT, (const linkaddr_t *)a) ==
|
||||||
NETSTACK_IP_PROCESS) {
|
NETSTACK_IP_PROCESS) {
|
||||||
ret = NETSTACK_NETWORK.output((const linkaddr_t *) a);
|
ret = NETSTACK_NETWORK.output((const linkaddr_t *) a);
|
||||||
|
@ -167,6 +180,19 @@ packet_input(void)
|
||||||
{
|
{
|
||||||
if(uip_len > 0) {
|
if(uip_len > 0) {
|
||||||
check_for_tcp_syn();
|
check_for_tcp_syn();
|
||||||
|
|
||||||
|
#if UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||||
|
{
|
||||||
|
uint8_t traffic_class = (UIP_IP_BUF->vtc << 4) | (UIP_IP_BUF->tcflow >> 4);
|
||||||
|
if(traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_BIT) {
|
||||||
|
uint8_t max_mac_transmissions = traffic_class & UIP_TC_MAC_TRANSMISSION_COUNTER_MASK;
|
||||||
|
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, max_mac_transmissions);
|
||||||
|
LOG_INFO("Received packet tagged with TC retrans: %d (%x)",
|
||||||
|
max_mac_transmissions, traffic_class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS */
|
||||||
|
|
||||||
uip_input();
|
uip_input();
|
||||||
if(uip_len > 0) {
|
if(uip_len > 0) {
|
||||||
tcpip_ipv6_output();
|
tcpip_ipv6_output();
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "net/ipv6/uipopt.h"
|
#include "net/ipv6/uipopt.h"
|
||||||
|
#include "net/ipv6/uipbuf.h"
|
||||||
|
|
||||||
/* For memcmp */
|
/* For memcmp */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -820,18 +821,6 @@ CCIF void uip_send(const void *data, int len);
|
||||||
*/
|
*/
|
||||||
#define uip_mss() (uip_conn->mss)
|
#define uip_mss() (uip_conn->mss)
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the maximal number of MAC transmissions.
|
|
||||||
*
|
|
||||||
* \hideinitializer
|
|
||||||
*/
|
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
#define uip_set_max_mac_transmissions(conn, value) ((conn)->max_mac_transmissions = (value))
|
|
||||||
#else
|
|
||||||
#define uip_set_max_mac_transmissions(conn, value)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up a new UDP connection.
|
* Set up a new UDP connection.
|
||||||
*
|
*
|
||||||
|
@ -1328,10 +1317,12 @@ extern uint16_t uip_urglen, uip_surglen;
|
||||||
#define uip_clear_buf() { \
|
#define uip_clear_buf() { \
|
||||||
uip_len = 0; \
|
uip_len = 0; \
|
||||||
uip_ext_len = 0; \
|
uip_ext_len = 0; \
|
||||||
|
uipbuf_clear_attr();\
|
||||||
}
|
}
|
||||||
#else /*NETSTACK_CONF_WITH_IPV6*/
|
#else /*NETSTACK_CONF_WITH_IPV6*/
|
||||||
#define uip_clear_buf() { \
|
#define uip_clear_buf() { \
|
||||||
uip_len = 0; \
|
uip_len = 0; \
|
||||||
|
uipbuf_clear_attr();\
|
||||||
}
|
}
|
||||||
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
#endif /*NETSTACK_CONF_WITH_IPV6*/
|
||||||
|
|
||||||
|
@ -1365,10 +1356,6 @@ struct uip_conn {
|
||||||
uint8_t timer; /**< The retransmission timer. */
|
uint8_t timer; /**< The retransmission timer. */
|
||||||
uint8_t nrtx; /**< The number of retransmissions for the last
|
uint8_t nrtx; /**< The number of retransmissions for the last
|
||||||
segment sent. */
|
segment sent. */
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uip_tcp_appstate_t appstate; /** The application state. */
|
uip_tcp_appstate_t appstate; /** The application state. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1405,10 +1392,6 @@ struct uip_udp_conn {
|
||||||
uint16_t lport; /**< The local port number in network byte order. */
|
uint16_t lport; /**< The local port number in network byte order. */
|
||||||
uint16_t rport; /**< The remote port number in network byte order. */
|
uint16_t rport; /**< The remote port number in network byte order. */
|
||||||
uint8_t ttl; /**< Default time-to-live. */
|
uint8_t ttl; /**< Default time-to-live. */
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
uint8_t max_mac_transmissions; /**< Number of max MAC-layer transmissions. */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** The application state. */
|
/** The application state. */
|
||||||
uip_udp_appstate_t appstate;
|
uip_udp_appstate_t appstate;
|
||||||
};
|
};
|
||||||
|
|
|
@ -508,9 +508,6 @@ uip_connect(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||||
conn->rto = UIP_RTO;
|
conn->rto = UIP_RTO;
|
||||||
conn->sa = 0;
|
conn->sa = 0;
|
||||||
conn->sv = 16; /* Initial value of the RTT variance. */
|
conn->sv = 16; /* Initial value of the RTT variance. */
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
|
|
||||||
#endif
|
|
||||||
conn->lport = uip_htons(lastport);
|
conn->lport = uip_htons(lastport);
|
||||||
conn->rport = rport;
|
conn->rport = rport;
|
||||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||||
|
@ -584,9 +581,6 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, uint16_t rport)
|
||||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||||
}
|
}
|
||||||
conn->ttl = uip_ds6_if.cur_hop_limit;
|
conn->ttl = uip_ds6_if.cur_hop_limit;
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
conn->max_mac_transmissions = UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
@ -1578,14 +1572,6 @@ uip_process(uint8_t flag)
|
||||||
|
|
||||||
UIP_IP_BUF->vtc = 0x60;
|
UIP_IP_BUF->vtc = 0x60;
|
||||||
UIP_IP_BUF->tcflow = 0x00;
|
UIP_IP_BUF->tcflow = 0x00;
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
if(uip_udp_conn->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
|
||||||
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
|
||||||
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
|
||||||
UIP_IP_BUF->tcflow = uip_udp_conn->max_mac_transmissions << 4;
|
|
||||||
}
|
|
||||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
|
||||||
|
|
||||||
UIP_IP_BUF->ttl = uip_udp_conn->ttl;
|
UIP_IP_BUF->ttl = uip_udp_conn->ttl;
|
||||||
UIP_IP_BUF->proto = UIP_PROTO_UDP;
|
UIP_IP_BUF->proto = UIP_PROTO_UDP;
|
||||||
|
|
||||||
|
@ -2292,13 +2278,6 @@ uip_process(uint8_t flag)
|
||||||
|
|
||||||
UIP_IP_BUF->vtc = 0x60;
|
UIP_IP_BUF->vtc = 0x60;
|
||||||
UIP_IP_BUF->tcflow = 0x00;
|
UIP_IP_BUF->tcflow = 0x00;
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
if(uip_connr->max_mac_transmissions != UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED) {
|
|
||||||
/* Encapsulate the MAC transmission limit in the Traffic Class field */
|
|
||||||
UIP_IP_BUF->vtc = 0x60 | (UIP_TC_MAC_TRANSMISSION_COUNTER_BIT >> 4);
|
|
||||||
UIP_IP_BUF->tcflow = uip_connr->max_mac_transmissions << 4;
|
|
||||||
}
|
|
||||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
|
||||||
|
|
||||||
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr);
|
uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &uip_connr->ripaddr);
|
||||||
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, RISE SICS
|
* Copyright (c) 2017, RISE SICS, Yanzi Networks
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -31,7 +31,14 @@
|
||||||
*/
|
*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "uip.h"
|
#include "uip.h"
|
||||||
|
#include "net/ipv6/uipbuf.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static uint16_t uipbuf_attrs[UIPBUF_ATTR_MAX];
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Get the next header given the buffer - start indicates that this is
|
/* Get the next header given the buffer - start indicates that this is
|
||||||
start of the IPv6 header - needs to be set to 0 when in an ext hdr */
|
start of the IPv6 header - needs to be set to 0 when in an ext hdr */
|
||||||
uint8_t*
|
uint8_t*
|
||||||
|
@ -54,7 +61,7 @@ uipbuf_get_next_header(uint8_t *buffer, uint16_t size, uint8_t *protocol, uint8_
|
||||||
return buffer + ext_len;
|
return buffer + ext_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Get the final header given the buffer - that is assumed to be at start
|
/* Get the final header given the buffer - that is assumed to be at start
|
||||||
of an IPv6 header */
|
of an IPv6 header */
|
||||||
uint8_t*
|
uint8_t*
|
||||||
|
@ -69,3 +76,58 @@ uipbuf_get_last_header(uint8_t *buffer, uint16_t size, uint8_t *protocol)
|
||||||
}
|
}
|
||||||
return nbuf;
|
return nbuf;
|
||||||
}
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* Common functions for uipbuf (attributes, etc).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uint16_t
|
||||||
|
uipbuf_get_attr(uint8_t type)
|
||||||
|
{
|
||||||
|
if(type < UIPBUF_ATTR_MAX) {
|
||||||
|
return uipbuf_attrs[type];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
|
uipbuf_set_attr(uint8_t type, uint16_t value)
|
||||||
|
{
|
||||||
|
if(type < UIPBUF_ATTR_MAX) {
|
||||||
|
uipbuf_attrs[type] = value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
uipbuf_clear_attr(void)
|
||||||
|
{
|
||||||
|
/* set everything to "zero" */
|
||||||
|
memset(uipbuf_attrs, 0, sizeof(uipbuf_attrs));
|
||||||
|
|
||||||
|
/* And initialize anything that should be initialized */
|
||||||
|
uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||||
|
UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
uipbuf_set_attr_flag(uint16_t flag)
|
||||||
|
{
|
||||||
|
/* Assume only 16-bits for flags now */
|
||||||
|
uipbuf_attrs[UIPBUF_ATTR_FLAGS] |= flag;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
uipbuf_clr_attr_flag(uint16_t flag)
|
||||||
|
{
|
||||||
|
uipbuf_attrs[UIPBUF_ATTR_FLAGS] &= ~flag;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
uint16_t
|
||||||
|
uipbuf_is_attr_flag(uint16_t flag)
|
||||||
|
{
|
||||||
|
return (uipbuf_attrs[UIPBUF_ATTR_FLAGS] & flag) > 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, RISE SICS
|
* Copyright (c) 2017, RISE SICS, Yanzi Networks
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -30,6 +30,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef UIPBUF_H_
|
||||||
|
#define UIPBUF_H_
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
|
||||||
/* Get the next header given the buffer - start indicates that this is
|
/* Get the next header given the buffer - start indicates that this is
|
||||||
|
@ -39,3 +42,27 @@ uint8_t* uipbuf_get_next_header(uint8_t *buffer, uint16_t size, uint8_t *protoco
|
||||||
/* Get the final header given the buffer - that is assumed to be at start
|
/* Get the final header given the buffer - that is assumed to be at start
|
||||||
of an IPv6 header */
|
of an IPv6 header */
|
||||||
uint8_t* uipbuf_get_last_header(uint8_t *buffer, uint16_t size, uint8_t *protocol);
|
uint8_t* uipbuf_get_last_header(uint8_t *buffer, uint16_t size, uint8_t *protocol);
|
||||||
|
|
||||||
|
/* Attributes relating to the current packet in uipbuf */
|
||||||
|
uint16_t uipbuf_get_attr(uint8_t type);
|
||||||
|
void uipbuf_set_attr_flag(uint16_t flag);
|
||||||
|
void uipbuf_clr_attr_flag(uint16_t flag);
|
||||||
|
uint16_t uipbuf_is_attr_flag(uint16_t flag);
|
||||||
|
int uipbuf_set_attr(uint8_t type, uint16_t value);
|
||||||
|
void uipbuf_clear_attr(void);
|
||||||
|
|
||||||
|
/* These flags will be used for being */
|
||||||
|
#define UIPBUF_ATTR_FLAGS_6LOWPAN_NO_NHC_COMPRESSION 0x01
|
||||||
|
#define UIPBUF_ATTR_FLAGS_6LOWPAN_NO_PREFIX_COMPRESSION 0x02
|
||||||
|
|
||||||
|
enum {
|
||||||
|
UIPBUF_ATTR_LLSEC_LEVEL,
|
||||||
|
UIPBUF_ATTR_LLSEC_KEY_ID,
|
||||||
|
UIPBUF_ATTR_INTERFACE_ID,
|
||||||
|
UIPBUF_ATTR_PHYSICAL_NETWORK_ID,
|
||||||
|
UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||||
|
UIPBUF_ATTR_FLAGS,
|
||||||
|
UIPBUF_ATTR_MAX
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* UIPBUF_H_ */
|
||||||
|
|
|
@ -518,22 +518,6 @@ void uip_log(char *msg);
|
||||||
|
|
||||||
#define UIP_DEFAULT_PREFIX_LEN 64
|
#define UIP_DEFAULT_PREFIX_LEN 64
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables selection of maximal MAC-layer transmission count at application layer
|
|
||||||
*/
|
|
||||||
#ifdef UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
#define UIP_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
#else
|
|
||||||
#define UIP_WITH_VARIABLE_RETRANSMISSIONS 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the default value of MAC-layer transmissons for uIPv6
|
|
||||||
*
|
|
||||||
* It means that the limit is selected by the MAC protocol instead of uIPv6.
|
|
||||||
*/
|
|
||||||
#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The MAC-layer transmissons limit is encapslated in "Traffic Class" field
|
* The MAC-layer transmissons limit is encapslated in "Traffic Class" field
|
||||||
*
|
*
|
||||||
|
@ -547,6 +531,19 @@ void uip_log(char *msg);
|
||||||
*/
|
*/
|
||||||
#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
|
#define UIP_TC_MAC_TRANSMISSION_COUNTER_MASK 0x3F
|
||||||
|
|
||||||
|
#ifdef UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||||
|
#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS
|
||||||
|
#else
|
||||||
|
#define UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the default value of MAC-layer transmissons for uIPv6
|
||||||
|
*
|
||||||
|
* It means that the limit is selected by the MAC protocol instead of uIPv6.
|
||||||
|
*/
|
||||||
|
#define UIP_MAX_MAC_TRANSMISSIONS_UNDEFINED 0
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -506,15 +506,11 @@ csma_output_packet(mac_callback_t sent, void *ptr)
|
||||||
if(q->buf != NULL) {
|
if(q->buf != NULL) {
|
||||||
struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr;
|
struct qbuf_metadata *metadata = (struct qbuf_metadata *)q->ptr;
|
||||||
/* Neighbor and packet successfully allocated */
|
/* Neighbor and packet successfully allocated */
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
metadata->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
metadata->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
||||||
if(metadata->max_transmissions == 0) {
|
if(metadata->max_transmissions == 0) {
|
||||||
/* If not set by the application, use the default CSMA value */
|
/* If not set by the application, use the default CSMA value */
|
||||||
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
|
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
metadata->max_transmissions = CSMA_MAX_FRAME_RETRIES + 1;
|
|
||||||
#endif
|
|
||||||
metadata->sent = sent;
|
metadata->sent = sent;
|
||||||
metadata->cptr = ptr;
|
metadata->cptr = ptr;
|
||||||
list_add(n->packet_queue, q);
|
list_add(n->packet_queue, q);
|
||||||
|
|
|
@ -1007,9 +1007,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||||
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
|
||||||
#endif
|
|
||||||
if(max_transmissions == 0) {
|
if(max_transmissions == 0) {
|
||||||
/* If not set by the application, use the default TSCH value */
|
/* If not set by the application, use the default TSCH value */
|
||||||
max_transmissions = TSCH_MAC_MAX_FRAME_RETRIES + 1;
|
max_transmissions = TSCH_MAC_MAX_FRAME_RETRIES + 1;
|
||||||
|
|
|
@ -217,9 +217,7 @@ enum {
|
||||||
PACKETBUF_ATTR_LINK_QUALITY,
|
PACKETBUF_ATTR_LINK_QUALITY,
|
||||||
PACKETBUF_ATTR_RSSI,
|
PACKETBUF_ATTR_RSSI,
|
||||||
PACKETBUF_ATTR_TIMESTAMP,
|
PACKETBUF_ATTR_TIMESTAMP,
|
||||||
#if UIP_WITH_VARIABLE_RETRANSMISSIONS
|
|
||||||
PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
|
||||||
#endif /* UIP_WITH_VARIABLE_RETRANSMISSIONS */
|
|
||||||
PACKETBUF_ATTR_MAC_SEQNO,
|
PACKETBUF_ATTR_MAC_SEQNO,
|
||||||
PACKETBUF_ATTR_MAC_ACK,
|
PACKETBUF_ATTR_MAC_ACK,
|
||||||
PACKETBUF_ATTR_MAC_METADATA,
|
PACKETBUF_ATTR_MAC_METADATA,
|
||||||
|
|
Loading…
Reference in New Issue