Implementation of the servreg-hack application
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/ip/uip.h"
#include "net/ipv6/uip-ds6.h"
#include "servreg-hack.h"
#include <stdio.h>
Data Structures | |
struct | servreg_hack_registration |
Macros | |
#define | LIFETIME 10 * 60 * CLOCK_SECOND |
#define | MAX_BUFSIZE 2 + 80 |
#define | MAX_REGISTRATIONS 16 |
#define | MSG_ADDRS_LEN 20 |
#define | MSG_ADDRS_OFFSET 2 |
#define | MSG_FLAGS_OFFSET 1 |
#define | MSG_IPADDR_SUBOFFSET 0 |
#define | MSG_NUMREGS_OFFSET 0 |
#define | MSG_REGS_SUBOFFSET 16 |
#define | MSG_SEQNO_SUBOFFSET 19 |
#define | NEW_REG_TIME 10 * CLOCK_SECOND |
#define | PERIOD_TIME 40 * CLOCK_SECOND |
#define | SEQNO_LT(a, b) ((signed char)((a) - (b)) < 0) |
#define | UDP_PORT 61616 |
Functions | |
static void | handle_incoming_reg (const uip_ipaddr_t *owner, servreg_hack_id_t id, uint8_t seqno) |
LIST (others_services) | |
LIST (own_services) | |
MEMB (registrations, struct servreg_hack_registration, MAX_REGISTRATIONS) | |
static void | parse_incoming_packet (const uint8_t *buf, int len) |
PROCESS (servreg_hack_process,"Service regstry hack") | |
PROCESS_THREAD (servreg_hack_process, ev, data) | |
static void | purge_registrations (void) |
static void | send_udp_packet (struct uip_udp_conn *conn) |
void | servreg_hack_init (void) |
Initialize and start the servreg-hack application. More... | |
uip_ipaddr_t * | servreg_hack_item_address (servreg_hack_item_t *item) |
Get the IP address for a list item. More... | |
servreg_hack_id_t | servreg_hack_item_id (servreg_hack_item_t *item) |
Get the service ID for a list item. More... | |
servreg_hack_item_t * | servreg_hack_list_head (void) |
Obtain the list of services provided by neighbors. More... | |
uip_ipaddr_t * | servreg_hack_lookup (servreg_hack_id_t service_id) |
Get the IP address of a node offering a service. More... | |
void | servreg_hack_register (servreg_hack_id_t service_id, const uip_ipaddr_t *addr) |
Register that this node provides a service. More... | |
Variables | |
static struct etimer | sendtimer |
static uint8_t | started = 0 |