Show link_structs.h syntax highlighted
/* -*- Mode: C; tab-width: 8; c-basic-indent: 2; indent-tabs-mode: nil -*- */
/* ex: set tabstop=8 expandtab shiftwidth=2 softtabstop=2: */
/*
*
* Copyright (c) 2003 The Regents of the University of California. All
* rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* link_structs.h -- Structures defining the link interface
*
* $Id: link_structs.h,v 1.44 2006/07/04 00:42:24 girod Exp $
*/
#ifndef __LINK_STRUCTS_H__
#define __LINK_STRUCTS_H__
/****************** packet and interface struct formats ******************/
typedef uint8_t link_mac_ctrl_type_t;
typedef enum link_mac_ctrl_enum {
MAC_CTRL_RECEIPT = 1,
MAC_CTRL_SYNC = 2,
MAC_CTRL_ACK = 3,
} link_mac_ctrl_enum_t;
typedef uint8_t link_pkt_type_t;
typedef enum link_pkt_enum {
PKT_TYPE_ALL = 0, /* do not use!! */
PKT_TYPE_PING = 1, /* ping request/response protocol */
PKT_TYPE_HB = 2, /* heartbeats for neighbor discovery */
PKT_TYPE_FRAGD = 3, /* fragmentation and reassembly */
PKT_TYPE_FLOOD = 4, /* flooding algorithm wrapper */
PKT_TYPE_LINK_STATS = 5, /* link stats wrapper */
PKT_TYPE_DIFFUSION = 6, /* directed diffusion */
PKT_TYPE_STATESYNC = 7, /* state sync service */
PKT_TYPE_SINKTREE = 8, /* sink tree routing */
PKT_TYPE_EMPROXY = 9, /* emproxy protocol */
PKT_TYPE_CENTROUTE_DATA = 19, /* raw centroute data pkts */
PKT_TYPE_ASCENT = 20, /* ascent control packets */
PKT_TYPE_ASCENT_APP = 21, /* ascent application packets (can this be a user type?) */
PKT_TYPE_CONNTEST_DATA = 22, /* connectivity data packets */
PKT_TYPE_CONNTEST_CTL = 23, /* connectivity control packets */
PKT_TYPE_CONNTEST = 24, /* connectivity data packets (old) */
PKT_TYPE_LINK_STATS2 = 25, /* new link stats wrapper */
PKT_TYPE_LQE = 26, /* improved link quality estimator */
PKT_TYPE_HBH = 27, /* hop by hop reliable scheme */
PKT_TYPE_COMPRESSED_PROXY = 28, /* debugging info compressed */
PKT_TYPE_SCALE = 29, /* scale application packets */
PKT_TYPE_GLS = 30, /* Geo-Linkstate Routing */
PKT_TYPE_FLOOD_GLS = 31,
PKT_TYPE_RNP = 32, /* Min RNP Routing */
PKT_TYPE_TIMESYNC = 100, /* time synchronization (syncd) */
PKT_TYPE_GSYNC = 101, /* global timesync flooding app */
PKT_TYPE_RANGE = 102, /* range notify flooding app */
PKT_TYPE_RANGE_TRIG = 103, /* range trigger flooding app */
PKT_TYPE_ACOUSTIC_EVENT = 104,/* acoustic event trigger flooding app */
PKT_TYPE_IP = 220, /* IP packets */
PKT_TYPE_ETH = 221, /* Ethernet Frames */
PKT_TYPE_TOS = 222, /* tos messages */
PKT_TYPE_MAC_CTRL = 223, /* MAC control messages (sync etc) */
PKT_TYPE_USER0 = 224, /* user-defined types */
/* DO NOT USE NUMBERS GREATER THAN 224!! */
} link_pkt_enum_t;
/* NOTE: When adding a new packet type, consider adding an entry to
* liblink/link_type_names.c */
extern char *pkt_type_names[];
/* 32 Uncoordinated user-defined packet types... */
#define PKT_TYPE_USER(x) ((x)+PKT_TYPE_USER0)
/*
* For link interfaces that support receipts, an application may
* set the sender field. If filled, this field will be copied in the
* return receipt so that the sender can match them up. If not filled,
* no receipt is generated.
*
* The receipt contains a retval with the following meanings:
* 0: Success
* EHOSTUNREACH: Unicast, No Ack
* ENOENT: SMAC, no neighbor present
* ETIMEDOUT: No response from MAC layer..
*/
typedef struct link_sender_id {
pid_t pid;
void *sender_info;
} link_sender_id_t;
/*
* This is the "universal" link interface header -- the header used to
* speak to almost any kind of packet-transport interface in the
* system. The over-the-air format will be different depending on the
* type of network; this is just the struct used to talk to the driver.
*/
typedef struct link_pkt {
union {
if_id_t id; /* source interface address */
loc_t loc;
} src;
union {
if_id_t id; /* destination interface address */
loc_t loc;
} dst;
union {
if_id_t id; /* previous hop interface address */
loc_t loc; /* (when applicable) */
} prev_hop;
/*
* time this packet was received. if_rcv_time is the raw timeval
* generated by the network interface, e.g. the mote clock.
* rcv_time is that time, after conversion (using the timesync
* service) to a plain local-clock timeval. If timesync is not
* available, rcv_time is an inaccurate best guess - a
* gettimeofday() at the time the packet arrived.
*/
struct timeval rcv_time;
remote_ts_t if_rcv_time;
link_pkt_type_t type:8; /* protocol number (8 bits) */
uint8_t max_hops; /* max number of hops, if routed */
uint8_t seqno; /* sequence number */
uint8_t ext_type; /* sub type (e.g. for TOS messages) */
uint8_t retval; /* return value for reciepts */
uint8_t rssi; /* RSSI value for this packet, if available */
uint8_t lqi; /* Link Quality Indicator value for this packet, if available */
uint8_t link_index; /* Index of link that this came in from */
uint8_t ext_group; /* for tos_group */
uint8_t numTx; /* For SMAC */
uint8_t numRx; /* For SMAC */
uint8_t smac_state; /* For SMAC */
uint8_t smac_sendtype; /* For SMAC */
uint8_t retx; /* Set this to enable N link-layer retransmissions,
* for links that support this function. */
uint8_t reserved[2]; /* */
/*
* Future plans for reorganizing this structure..
* - We are starting to see more link-specific fields. might be better
* to put those in unions
* - some fields are really logically the same? (lqi/rssi)?
*/
float rnp; /* metric for routing using lqe */
link_sender_id_t sender; /* identifies application sender for receipt */
/* pointer to the data that follows */
uint8_t data[0] __attribute__ ((aligned(4))); // this will take care of
// nasty aligns
} link_pkt_t; // this SHOULD NOT be packed!!
/* *** Should some of those fields be in packets e.g. retval -> receipt packet?? *** */
/* can be used in dst.id */
#define LINK_BROADCAST ((if_id_t) 0xFFFFFFFF)
/*
* Link sub-device names
*/
#define LINK_DATA_SUBDEV "data"
#define LINK_STATUS_SUBDEV "status"
#define LINK_ERRORS_SUBDEV "errors"
#define LINK_COMMAND_SUBDEV "command"
#define LINK_NEIGHBORS_SUBDEV "neighbors"
#define LINK_LINKSTAT_SUBDEV "linkstats"
#define LINK_ROUTING_SUBDEV "routes"
#define LINK_CONNTEST_SUBDEV "conntest"
#define LINK_LQE_SUBDEV "lqe"
/*
* Link device classes
* roughly corresponds to the 'layer' at which they operate
*/
#define LINK_CLASS_NONE "none"
#define LINK_CLASS_RAW "raw"
#define LINK_CLASS_LINK "link"
#define LINK_CLASS_NETWORK "network"
/*
* Link command strings
*/
#define LINK_CMD_POWER "power"
#define LINK_CMD_IFID "ifid"
#define LINK_CMD_ACTIVE "active"
#define LINK_CMD_RESET "reset"
#define LINK_CMD_LPL_TX "lpl_tx"
#define LINK_CMD_LPL_RX "lpl_rx"
/****
* link "status" structure -- a struct giving the characteristics of a
* link and its current state. using LINK_GET_STATUS ioctl, apps can
* query a link and get this struct back.
****/
#define LINK_DESCLEN 63
typedef struct link_status {
char root[LINK_DESCLEN+1];
char top[LINK_DESCLEN+1];
char trace[LINK_DESCLEN+1];
if_id_t if_id; // interface address
uint8_t channel_id; // channel id
uint16_t MTU; // MTU
/* statistics */
int packets_rx;
int packets_tx;
int bytes_rx;
int bytes_tx;
int errors_tx;
int errors_rx;
int active; // is the radio on (can send/receive) or off?
int promisc; // in promiscuous listening mode?
int POT; // potentiomter, if applicable
} link_status_t;
#endif
See more files for this project here