~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
cvs/emstar/link/include/link_structs.h


  1 /* -*- Mode: C; tab-width: 8; c-basic-indent: 2; indent-tabs-mode: nil -*- */
  2 /* ex: set tabstop=8 expandtab shiftwidth=2 softtabstop=2: */
  3 
  4 
  5 /*
  6  *
  7  * Copyright (c) 2003 The Regents of the University of California.  All 
  8  * rights reserved.
  9  *
 10  * Redistribution and use in source and binary forms, with or without
 11  * modification, are permitted provided that the following conditions
 12  * are met:
 13  *
 14  * - Redistributions of source code must retain the above copyright
 15  *   notice, this list of conditions and the following disclaimer.
 16  *
 17  * - Neither the name of the University nor the names of its
 18  *   contributors may be used to endorse or promote products derived
 19  *   from this software without specific prior written permission.
 20  *
 21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 24  * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 29  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  */
 34  
 35 
 36 /*
 37  * link_structs.h -- Structures defining the link interface
 38  *
 39  * $Id: link_structs.h,v 1.45 2007-06-12 11:35:20 thanos Exp $
 40  */
 41 
 42 #ifndef __LINK_STRUCTS_H__
 43 #define __LINK_STRUCTS_H__
 44 
 45 
 46 /****************** packet and interface struct formats ******************/
 47 
 48 typedef uint8_t link_mac_ctrl_type_t;
 49 typedef enum link_mac_ctrl_enum {
 50   MAC_CTRL_RECEIPT = 1,
 51   MAC_CTRL_SYNC = 2,
 52   MAC_CTRL_ACK = 3,
 53 } link_mac_ctrl_enum_t;
 54 
 55 typedef uint8_t link_pkt_type_t;
 56 typedef enum link_pkt_enum {
 57   PKT_TYPE_ALL = 0,             /* do not use!! */
 58   PKT_TYPE_PING = 1,            /* ping request/response protocol */
 59   PKT_TYPE_HB = 2,              /* heartbeats for neighbor discovery */
 60   PKT_TYPE_FRAGD = 3,           /* fragmentation and reassembly */
 61   PKT_TYPE_FLOOD = 4,           /* flooding algorithm wrapper */
 62   PKT_TYPE_LINK_STATS = 5,      /* link stats wrapper */
 63   PKT_TYPE_DIFFUSION = 6,       /* directed diffusion */
 64   PKT_TYPE_STATESYNC = 7,       /* state sync service */
 65   PKT_TYPE_SINKTREE = 8,        /* sink tree routing */
 66   PKT_TYPE_EMPROXY = 9,         /* emproxy protocol */
 67   PKT_TYPE_DSR = 18,            /* DSR routing protocol */
 68   PKT_TYPE_CENTROUTE_DATA = 19, /* raw centroute data pkts */
 69 
 70   PKT_TYPE_ASCENT = 20,         /* ascent control packets */
 71   PKT_TYPE_ASCENT_APP = 21,     /* ascent application packets (can this be a user type?) */
 72   PKT_TYPE_CONNTEST_DATA = 22,  /* connectivity data packets */
 73   PKT_TYPE_CONNTEST_CTL = 23,   /* connectivity control packets */
 74   PKT_TYPE_CONNTEST = 24,       /* connectivity data packets (old) */
 75   PKT_TYPE_LINK_STATS2 = 25,    /* new link stats wrapper */
 76   PKT_TYPE_LQE = 26,            /* improved link quality estimator */
 77   PKT_TYPE_HBH = 27,            /* hop by hop reliable scheme */
 78   PKT_TYPE_COMPRESSED_PROXY = 28,  /* debugging info compressed */
 79   PKT_TYPE_SCALE = 29,          /* scale application packets */
 80 
 81   PKT_TYPE_GLS = 30,            /* Geo-Linkstate Routing */
 82   PKT_TYPE_FLOOD_GLS = 31,
 83   PKT_TYPE_RNP = 32,            /* Min RNP Routing */
 84 
 85   PKT_TYPE_TIMESYNC = 100,      /* time synchronization (syncd) */
 86   PKT_TYPE_GSYNC = 101,         /* global timesync flooding app */
 87   PKT_TYPE_RANGE = 102,         /* range notify flooding app */
 88   PKT_TYPE_RANGE_TRIG = 103,    /* range trigger flooding app */
 89   PKT_TYPE_ACOUSTIC_EVENT = 104,/* acoustic event trigger flooding app */
 90 
 91   PKT_TYPE_IP = 220,            /* IP packets */
 92   PKT_TYPE_ETH = 221,           /* Ethernet Frames */
 93 
 94   PKT_TYPE_TOS = 222,           /* tos  messages */
 95   PKT_TYPE_MAC_CTRL = 223,      /* MAC control messages (sync etc) */
 96 
 97   PKT_TYPE_USER0 = 224,          /* user-defined types */
 98   /* DO NOT USE NUMBERS GREATER THAN 224!! */
 99 } link_pkt_enum_t;
100 
101 /* NOTE: When adding a new packet type, consider adding an entry to
102  * liblink/link_type_names.c */
103 extern char *pkt_type_names[];
104 
105 /* 32 Uncoordinated user-defined packet types... */
106 #define PKT_TYPE_USER(x) ((x)+PKT_TYPE_USER0)
107 
108 /*
109  *  For link interfaces that support receipts, an application may 
110  *  set the sender field.  If filled, this field will be copied in the
111  *  return receipt so that the sender can match them up.  If not filled,
112  *  no receipt is generated.
113  *
114  *  The receipt contains a retval with the following meanings:
115  *    0:            Success
116  *    EHOSTUNREACH: Unicast, No Ack
117  *    ENOENT:       SMAC, no neighbor present
118  *    ETIMEDOUT:    No response from MAC layer..
119  */
120 
121 typedef struct link_sender_id {
122   pid_t pid;
123   void *sender_info;
124 } link_sender_id_t;
125 
126 
127 /*
128  * This is the "universal" link interface header -- the header used to
129  * speak to almost any kind of packet-transport interface in the
130  * system.  The over-the-air format will be different depending on the
131  * type of network; this is just the struct used to talk to the driver.
132  */
133 typedef struct link_pkt {
134   union {
135     if_id_t id;                 /* source interface address */
136     loc_t loc;
137   } src;
138   union {
139     if_id_t id;                 /* destination interface address */
140     loc_t loc;
141   } dst;
142   union {
143     if_id_t id;                 /* previous hop interface address */
144     loc_t loc;                  /* (when applicable) */
145   } prev_hop;
146 
147   /*
148    * time this packet was received.  if_rcv_time is the raw timeval
149    * generated by the network interface, e.g. the mote clock.
150    * rcv_time is that time, after conversion (using the timesync
151    * service) to a plain local-clock timeval.  If timesync is not
152    * available, rcv_time is an inaccurate best guess - a
153    * gettimeofday() at the time the packet arrived.
154    */
155   struct timeval rcv_time;
156   remote_ts_t if_rcv_time;
157 
158   link_pkt_type_t type:8;       /* protocol number (8 bits) */
159   uint8_t max_hops;             /* max number of hops, if routed */
160   uint8_t seqno;                /* sequence number */
161   uint8_t ext_type;             /* sub type (e.g. for TOS messages) */
162   uint8_t retval;               /* return value for reciepts */
163   uint8_t rssi;                 /* RSSI value for this packet, if available */
164   uint8_t lqi;                  /* Link Quality Indicator value for this packet, if available */
165   uint8_t link_index;           /* Index of link that this came in from */
166   
167   uint8_t ext_group;            /* for tos_group */
168 
169   uint8_t numTx;                /* For SMAC */
170   uint8_t numRx;                /* For SMAC */
171   uint8_t smac_state;           /* For SMAC */
172   uint8_t smac_sendtype;        /* For SMAC */
173 
174   uint8_t retx;                 /* Set this to enable N link-layer retransmissions, 
175                                  * for links that support this function. */
176 
177   uint8_t reserved[2];          /* */
178 
179   /* 
180    *  Future plans for reorganizing this structure..
181    *   - We are starting to see more link-specific fields.  might be better
182    *     to put those in unions
183    *   - some fields are really logically the same?  (lqi/rssi)?
184    */
185 
186   float rnp;                    /* metric for routing using lqe */
187   link_sender_id_t sender;      /* identifies application sender for receipt */
188                                 /* pointer to the data that follows */
189 
190   uint8_t data[0] __attribute__ ((aligned(4)));   // this will take care of 
191                                                   // nasty aligns
192 } link_pkt_t; // this SHOULD NOT be packed!!
193 
194 /*  *** Should some of those fields be in packets e.g. retval -> receipt packet?? *** */
195 
196 /* can be used in dst.id */
197 #define LINK_BROADCAST ((if_id_t) 0xFFFFFFFF)
198 
199 /*
200  *  Link sub-device names
201  */
202 
203 #define LINK_DATA_SUBDEV      "data"
204 #define LINK_STATUS_SUBDEV    "status"
205 #define LINK_ERRORS_SUBDEV    "errors"
206 #define LINK_COMMAND_SUBDEV   "command"
207 #define LINK_NEIGHBORS_SUBDEV "neighbors"
208 #define LINK_LINKSTAT_SUBDEV  "linkstats"
209 #define LINK_ROUTING_SUBDEV   "routes"
210 #define LINK_CONNTEST_SUBDEV  "conntest"
211 #define LINK_LQE_SUBDEV       "lqe"
212 
213 /*
214  *  Link device classes
215  *  roughly corresponds to the 'layer' at which they operate
216  */
217 
218 #define LINK_CLASS_NONE        "none"
219 #define LINK_CLASS_RAW         "raw"
220 #define LINK_CLASS_LINK        "link"
221 #define LINK_CLASS_NETWORK     "network"
222 
223 /*
224  *  Link command strings
225  */
226 
227 #define LINK_CMD_POWER         "power"
228 #define LINK_CMD_IFID          "ifid"
229 #define LINK_CMD_ACTIVE        "active"
230 #define LINK_CMD_RESET         "reset"
231 #define LINK_CMD_LPL_TX        "lpl_tx"
232 #define LINK_CMD_LPL_RX        "lpl_rx"
233 
234 
235 /**** 
236  * link "status" structure -- a struct giving the characteristics of a
237  * link and its current state.  using LINK_GET_STATUS ioctl, apps can
238  * query a link and get this struct back.
239  ****/
240 
241 #define LINK_DESCLEN 63
242 
243 typedef struct link_status {
244   char root[LINK_DESCLEN+1];
245   char top[LINK_DESCLEN+1];
246   char trace[LINK_DESCLEN+1];
247 
248   if_id_t if_id;                // interface address
249   uint8_t channel_id;           // channel id
250   uint16_t MTU;                 // MTU
251 
252   /* statistics */
253   int packets_rx;
254   int packets_tx;
255   int bytes_rx;
256   int bytes_tx;
257   int errors_tx;
258   int errors_rx;
259 
260   int active;                   // is the radio on (can send/receive) or off?
261   int promisc;                  // in promiscuous listening mode?
262   int POT;                      // potentiomter, if applicable
263 } link_status_t;
264 
265 #endif
266 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.