00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef _OBAMP_OBAMP_H
00044 #define _OBAMP_OBAMP_H
00045
00046 #include "common/list.h"
00047
00048 #include "plugin.h"
00049
00050 #include "parser.h"
00051
00052 #define MESSAGE_TYPE 133 //TODO: check if this number is ok
00053 #define PARSER_TYPE MESSAGE_TYPE
00054 #define EMISSION_INTERVAL 10
00055 #define EMISSION_JITTER 25
00056 #define OBAMP_VALID_TIME 1800
00057
00058
00059 #define PLUGIN_NAME "OLSRD OBAMP plugin"
00060 #define PLUGIN_NAME_SHORT "OLSRD OBAMP"
00061 #define PLUGIN_VERSION "1.0.0 (" __DATE__ " " __TIME__ ")"
00062 #define PLUGIN_COPYRIGHT " (C) Ninux.org"
00063 #define PLUGIN_AUTHOR " Saverio Proto (zioproto@gmail.com)"
00064 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
00065 #define PLUGIN_INTERFACE_VERSION 5
00066
00067 #define PLUGIN_DESCR "OBAMP"
00068
00069 #define OBAMP_JITTER 25
00070 #define OBAMP_ALIVE_EIVAL 3
00071 #define OBAMP_MESH_CREATE_IVAL 1 //Seconds
00072 #define OBAMP_TREE_CREATE_IVAL 2 //seconds
00073 #define TREE_HEARTBEAT 5 //seconds
00074 #define OBAMP_OUTER_TREE_CREATE_IVAL 6 //seconds
00075 #define _MESH_LOCK_ 3 //seconds
00076
00077 #define _Texpire_ 18 //time in seconds before expire a neighbor
00078 #define _Texpire_timer_ 1 //time in seconds to parse the list decrement and purge
00079
00080 #define _TREE_REQUEST_DELAY_ 5
00081
00082
00083
00084 #define OBAMP_DATA 0
00085 #define OBAMP_HELLO 1
00086 #define OBAMP_TREECREATE 2
00087 #define OBAMP_ALIVE 3
00088 #define OBAMP_TREE_REQ 4
00089 #define OBAMP_TREE_ACK 5
00090 #define OBAMP_TREE_DESTROY 6
00091
00092 #define OBAMP_SIGNALLING_PORT 6226
00093
00094
00095
00096 extern struct ObampNodeState *myState;
00097
00098
00099 struct interface;
00100
00101 union olsr_ip_addr *MainAddressOf(union olsr_ip_addr *ip);
00102
00103 void ObampSignalling(int sd, void *x, unsigned int y);
00104
00105
00106 void EncapFlowInObamp(int sd, void *x, unsigned int y);
00107
00108
00109 int AddObampSniffingIf(const char *ifName, void *data, set_plugin_parameter_addon addon);
00110
00111
00112 int InitOBAMP(void);
00113 int PreInitOBAMP(void);
00114 void CloseOBAMP(void);
00115
00116 void olsr_obamp_gen(void *packet, int len);
00117
00118 void obamp_hello_gen(void *para);
00119 void obamp_alive_gen(void *para);
00120 void purge_nodes(void *para);
00121 void mesh_create(void *para);
00122 void tree_create(void *para);
00123 void outer_tree_create(void *para);
00124 void unsolicited_tree_destroy(void *para);
00125
00126 int addObampNode4(struct in_addr *ipv4, u_int8_t status);
00127
00128
00129
00130 void olsr_parser(struct olsr_message *, struct interface *, union olsr_ip_addr *, enum duplicate_status);
00131
00132
00133 struct ObampNode {
00134
00135 union olsr_ip_addr neighbor_ip_addr;
00136
00137 int isMesh;
00138 int wasMesh;
00139 int outerTreeLink;
00140 int isTree;
00141 int MeshLock;
00142
00143 u_int8_t status;
00144
00145 int Texpire;
00146
00147 u_int8_t DataSeqNumber;
00148
00149 struct list_entity list;
00150 };
00151
00152
00153 struct ObampSniffingIf {
00154
00155 int skd;
00156 char ifName[16];
00157 struct list_entity list;
00158
00159 };
00160
00161
00162
00163 struct ObampNodeState {
00164
00165 union olsr_ip_addr myipaddr;
00166 union olsr_ip_addr CoreAddress;
00167
00168 int iamcore;
00169
00170 u_int8_t TreeCreateSequenceNumber;
00171 u_int8_t tree_req_sn;
00172 u_int8_t DataSequenceNumber;
00173
00174 union olsr_ip_addr ParentId;
00175 union olsr_ip_addr OldParentId;
00176
00177
00178
00179
00180
00181
00182 int TreeHeartBeat;
00183 int TreeRequestDelay;
00184 };
00185
00186
00187
00188
00189 struct OBAMP_data_message4 {
00190
00191 u_int8_t MessageID;
00192 u_int32_t router_id;
00193 u_int32_t last_hop;
00194 u_int16_t SequenceNumber;
00195 u_int32_t CoreAddress;
00196 u_int16_t datalen;
00197 unsigned char data[1471];
00198
00199 } __attribute__((__packed__));
00200
00201 struct OBAMP_data_message6 {
00202
00203
00204
00205 };
00206
00207
00208
00209 struct OBAMP_tree_destroy {
00210
00211 u_int8_t MessageID;
00212 union olsr_ip_addr router_id;
00213 u_int8_t SequenceNumber;
00214 union olsr_ip_addr CoreAddress;
00215
00216 };
00217
00218 struct OBAMP_tree_create {
00219
00220 u_int8_t MessageID;
00221 union olsr_ip_addr router_id;
00222 u_int8_t SequenceNumber;
00223 union olsr_ip_addr CoreAddress;
00224
00225 };
00226
00227 struct OBAMP_tree_link_req {
00228
00229 u_int8_t MessageID;
00230 union olsr_ip_addr router_id;
00231 u_int8_t SequenceNumber;
00232 union olsr_ip_addr CoreAddress;
00233 };
00234
00235 struct OBAMP_tree_link_ack {
00236
00237 u_int8_t MessageID;
00238 union olsr_ip_addr router_id;
00239 u_int8_t SequenceNumber;
00240 union olsr_ip_addr CoreAddress;
00241 };
00242
00243
00244 struct OBAMP_hello {
00245
00246 u_int8_t MessageID;
00247 union olsr_ip_addr router_id;
00248 u_int8_t HelloSequenceNumber;
00249 union olsr_ip_addr CoreAddress;
00250
00251 };
00252
00253 struct OBAMP_alive {
00254
00255 u_int8_t MessageID;
00256 u_int8_t status;
00257 u_int32_t CoreAddress;
00258
00259
00260 };
00261
00262 #endif