00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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;
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);
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_