41 #include "contiki-lib.h" 43 #include "lib/assert.h" 44 #include "net/nbr-table.h" 50 #define LOG_MODULE "6top" 51 #define LOG_LEVEL LOG_LEVEL_6TOP 60 typedef struct sixp_nbr {
61 struct sixp_nbr *next;
76 return (
sixp_nbr_t *)nbr_table_get_from_lladdr(sixp_nbrs, addr);
86 LOG_ERR(
"6P-nbr: sixp_nbr_alloc() fails because of invalid argument\n");
91 LOG_ERR(
"6P-nbr: sixp_nbr_alloc() fails because of duplication [peer_addr:");
92 LOG_ERR_LLADDR((
const linkaddr_t *)addr);
97 if((nbr = (
sixp_nbr_t *)nbr_table_add_lladdr(sixp_nbrs,
99 NBR_TABLE_REASON_SIXTOP,
101 LOG_ERR(
"6P-nbr: sixp_nbr_alloc() fails to add nbr because of no memory\n");
116 (void)nbr_table_remove(sixp_nbrs, nbr);
125 LOG_ERR(
"6P-nbr: sixp_nbr_get_next_seqno() fails because of invalid arg\n");
128 return nbr->next_seqno;
136 LOG_ERR(
"6P-nbr: sixp_nbr_set_next_seqno() fails because of invalid arg\n");
139 nbr->next_seqno = seqno;
148 LOG_ERR(
"6P-nbr: sixp_nbr_clear_next_seqno() fails; invalid arg\n");
160 LOG_ERR(
"6P-nbr: sixp_nbr_increment_next_seqno() fails; invalid arg\n");
164 if(nbr->next_seqno == 0) {
178 if(nbr_table_is_registered(sixp_nbrs) == 0) {
179 nbr_table_register(sixp_nbrs, NULL);
182 nbr = (
sixp_nbr_t *)nbr_table_head(sixp_nbrs);
184 next_nbr = (
sixp_nbr_t *)nbr_table_next(sixp_nbrs, nbr);
struct sixp_nbr sixp_nbr_t
6P Neighbor Data Structure (for internal use)
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
#define SIXP_INITIAL_SEQUENCE_NUMBER
The initial sequence number used for 6P request.
int sixp_nbr_reset_next_seqno(sixp_nbr_t *nbr)
Reset the next sequence number of a neighbor to zero.
int sixp_nbr_increment_next_seqno(sixp_nbr_t *nbr)
Increment the next sequence number of a neighbor.
void sixp_nbr_free(sixp_nbr_t *nbr)
Free a neighbor.
void linkaddr_copy(linkaddr_t *dest, const linkaddr_t *src)
Copy a link-layer address.
sixp_nbr_t * sixp_nbr_alloc(const linkaddr_t *addr)
Allocate a neighbor.
int sixp_nbr_init(void)
Initialize 6p Neighbor Table.
int sixp_nbr_get_next_seqno(sixp_nbr_t *nbr)
Get the next sequence number of a neighbor.
sixp_nbr_t * sixp_nbr_find(const linkaddr_t *addr)
Find a neighbor.
int sixp_nbr_set_next_seqno(sixp_nbr_t *nbr, uint16_t seqno)
Set the specified value to the next sequence number of a neighbor.
Header file for the logging system