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_NEIGHBOR_H_
00036 #define _MESH_NEIGHBOR_H_
00037
00038 #include <netinet/in.h>
00039 #include "sensor_self.h"
00040 #include "mesh_ipc.h"
00041
00042
00043 #define MESH_N_COMM_PORT 1010
00044
00047 typedef struct _neighbor_entry {
00048 unsigned int node_id;
00049 char address[MAC_ADDR_LEN];
00050 double bearing;
00051 double distance;
00052
00053 double lat, lon, alt;
00054 struct sockaddr_in ip;
00055
00056 struct _neighbor_entry *next;
00057 } neighbor_entry_t;
00058
00059 void init_n_entry(self_t *self, neighbor_entry_t *entry);
00060 neighbor_entry_t *new_n_entry(self_t *self);
00061
00062 int add_n_entry(self_t *self, unsigned int id, neighbor_entry_t *entry);
00063 int remove_n_entry(self_t *self, unsigned int id, neighbor_entry_t *entry);
00064 neighbor_entry_t *retrieve_n_entry(self_t *self, unsigned int id);
00065 neighbor_entry_t *iterate_n_entries(self_t *self);
00066 unsigned int num_n_entries(self_t *self);
00067 void empty_n_entries(self_t *self);
00068
00069 int neighbor_address(self_t *self, char *addr,
00070 double bearing, double distance);
00071 int neighbor_position(self_t *self, double *bearing, double *distance,
00072 char *addr);
00073 neighbor_entry_t *neighbor_by_position(self_t *self,
00074 double bearing, double distance);
00075 neighbor_entry_t *neighbor_by_ip(self_t *self, struct sockaddr_in *ip);
00076
00077 int find_neighbors(self_t *self);
00078 int neighbor_discovery(self_t *self);
00079
00080
00081 #endif // _MESH_NEIGHBOR_H_