N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/Vaike/linux/system-addons/networking/mesh_protocol.h

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
00033  */
00034 
00035 #ifndef _MESH_PROTOCOL_H_
00036 #define _MESH_PROTOCOL_H_
00037 
00038 #include <netinet/in.h>
00039 #include <pthread.h>
00040 #include "avl.h"
00041 
00042 struct _self;
00043 struct _db;
00044 
00045 #define PROTO_NAMELEN        64
00046 
00047 
00048 typedef struct _protocol {
00049   char name[PROTO_NAMELEN];
00050   unsigned short unique_id;
00051   unsigned int timeout; // in seconds
00052   unsigned char proactive;
00053   unsigned char reactive;
00054 
00055   struct avltree network;
00056   struct avlnode *iterator;
00057   unsigned int db_altered;
00058 
00059   int queue_sd;
00060   unsigned int sendqueue_size;
00061   u_int64_t queue_timeout;
00062   unsigned int mtu;
00063   size_t ctl_size;
00064 
00065   void *lib_handle;
00066   void (*mesh_init_discovery)(struct _protocol *proto, u_int32_t dest);
00067   int (*mesh_route_send)(struct _protocol *proto, int sd, int flags);
00068   int (*mesh_route_recv)(struct _protocol *proto, int sd, int num_links);
00069 
00070   struct _self *sensor;
00071   struct _protocol *next;
00072   pthread_t discover_thread;
00073 } protocol_t;
00074 
00075 
00076 u_int64_t get_current_time(void);  // in milliseconds;
00077 
00078 int add_protocol(struct _self *self, char *name, int id, char *path,
00079                  unsigned int tmo, unsigned char pro, unsigned char re,
00080                  char *discovery_fctn, char *route_send_fctn,
00081                  char *route_recv_fctn, char *socket_mod_fctn);
00082 int delete_protocol(struct _self *self, char *string);
00083 protocol_t *protocol_by_string(struct _self *self, char *string);
00084 protocol_t *protocol_by_id(struct _self *self, int id);
00085 
00086 int recv_mesh_discovery(protocol_t *proto, int sd, int num_links);
00087 
00088 ssize_t send_routes(struct _self *self, int sd,
00089                     struct _db *db, unsigned int num_links,
00090                     struct sockaddr_in *to);
00091 ssize_t receive_routes(int sd, struct _db *db, unsigned int num_links,
00092                        struct sockaddr_in *from, struct msghdr *msg_header,
00093                        size_t ctl_msg_size);
00094 
00095 
00096 #endif  //  _MESH_PROTOCOL_H_


© 2007, Los Alamos National Security, LLC.