Adding the first implementation of the OBAMP plugin. See README file for documentation.
4 Written by Saverio Proto <zioproto@gmail.com> and Claudio Pisa <clauz@ninux.org>.
6 This file is part of OLSR OBAMP PLUGIN.
8 The OLSR OBAMP PLUGIN is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 The OLSR OBAMP PLUGIN is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the OLSR OBAMP PLUGIN. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _OBAMP_OBAMP_H
25 #define _OBAMP_OBAMP_H
29 #include "plugin.h" /* union set_plugin_parameter_addon */
33 #define MESSAGE_TYPE 133 //TODO: check if this number is ok
34 #define PARSER_TYPE MESSAGE_TYPE
35 #define EMISSION_INTERVAL 10 /* seconds */
36 #define EMISSION_JITTER 25 /* percent */
37 #define OBAMP_VALID_TIME 1800 /* seconds */
39 /* OBAMP plugin data */
40 #define PLUGIN_NAME "OLSRD OBAMP plugin"
41 #define PLUGIN_NAME_SHORT "OLSRD OBAMP"
42 #define PLUGIN_VERSION "1.0.0 (" __DATE__ " " __TIME__ ")"
43 #define PLUGIN_COPYRIGHT " (C) Ninux.org"
44 #define PLUGIN_AUTHOR " Saverio Proto (zioproto@gmail.com)"
45 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
46 #define PLUGIN_INTERFACE_VERSION 5
48 #define PLUGIN_DESCR "OBAMP"
50 #define OBAMP_JITTER 25 /* percent */
51 #define OBAMP_ALIVE_EIVAL 5
52 #define OBAMP_MESH_CREATE_IVAL 5 //Seconds
53 #define OBAMP_TREE_CREATE_IVAL 10 //seconds
54 #define TREE_HEARTBEAT 25 //seconds
55 #define OBAMP_OUTER_TREE_CREATE_IVAL 30 //seconds
56 #define _MESH_LOCK_ 10 //seconds
58 #define _Texpire_ 15 //time in seconds before expire a neighbor
59 #define _Texpire_timer_ 1 //time in seconds to parse the list decrement and purge
62 /*OBAMP Protocol MESSAGE IDs */
66 #define OBAMP_TREECREATE 2
68 #define OBAMP_TREE_REQ 4
69 #define OBAMP_TREE_ACK 5
71 #define OBAMP_SIGNALLING_PORT 6226
75 extern struct ObampNodeState* myState; //Internal state of the running OBAMP node
77 /* Forward declaration of OLSR interface type */
80 union olsr_ip_addr *MainAddressOf(union olsr_ip_addr *ip);
82 void ObampSignalling(int sd, void *x, unsigned int y);
84 //Gets packets from sniffing interfaces, checks if are multicast, and pushes them to OBAMP tree links
85 void EncapFlowInObamp(int sd, void * x, unsigned int y);
87 //Used to add Sniffing Interfaces read from config file to the list
88 int AddObampSniffingIf(const char *ifName, void *data, set_plugin_parameter_addon addon);
92 int PreInitOBAMP(void);
93 void CloseOBAMP(void);
95 void olsr_obamp_gen(unsigned char *packet, int len);
97 void obamp_hello_gen(void *para);
98 void obamp_alive_gen(void *para);
99 void purge_nodes(void *para);
100 void mesh_create(void *para);
101 void tree_create(void *para);
102 void outer_tree_create(void *para);
104 int addObampNode4(struct in_addr * ipv4, u_int8_t status);
107 /* Parser function to register with the scheduler */
108 void olsr_parser(union olsr_message *, struct interface *, union olsr_ip_addr *, enum duplicate_status);
110 //Struct to describe the other OBAMP nodes in the mesh network
113 union olsr_ip_addr neighbor_ip_addr; //IP address
115 int isMesh; //The consider the path from us to this OBAMP node as an overlay mesh link
117 int outerTreeLink; //I'm using this OBAMP node as an anchor
118 int isTree;//it identifies if it is a link of tree
119 int MeshLock; //Is mesh because requested from neighbor with hello messages
121 u_int8_t status; //indicates if this OBAMP node has at least a tree link
123 int Texpire;// TTL to softstate expire
125 u_int8_t DataSeqNumber;
127 struct list_head list;
130 //Interfaces of the router not talking OLSR, where we capture the multicast traffic
131 struct ObampSniffingIf {
133 int skd; //Socket descriptor
134 char ifName[16]; //Interface name
135 struct list_head list;
140 //Internal State of the OBAMP NoDE
141 struct ObampNodeState {
143 union olsr_ip_addr myipaddr; //IP ADDRESS
144 union olsr_ip_addr CoreAddress; //CORE IP ADDRESS
146 int iamcore; //Indicates if I'm the core
148 u_int8_t TreeCreateSequenceNumber;
149 u_int8_t tree_req_sn;
150 u_int8_t DataSequenceNumber;
152 union olsr_ip_addr ParentId; //Tree link towards the core
153 union olsr_ip_addr OldParentId;
156 TTL to check if I'm receiving tree_create messages from core
157 if this expires there is a problem with the spanning tree
163 // OBAMP message types
166 struct OBAMP_data_message {
169 union olsr_ip_addr router_id;
170 union olsr_ip_addr last_hop;
171 u_int8_t SequenceNumber;
172 union olsr_ip_addr CoreAddress;
174 unsigned char data[1280]; //TODO:fix me
178 struct OBAMP_tree_create {
181 union olsr_ip_addr router_id;
182 u_int8_t SequenceNumber;
183 union olsr_ip_addr CoreAddress;
187 struct OBAMP_tree_link_req {
190 union olsr_ip_addr router_id;
191 u_int8_t SequenceNumber;
192 union olsr_ip_addr CoreAddress;
195 struct OBAMP_tree_link_ack {
198 union olsr_ip_addr router_id;
199 u_int8_t SequenceNumber;
200 union olsr_ip_addr CoreAddress;
207 union olsr_ip_addr router_id;
208 u_int8_t HelloSequenceNumber;
209 union olsr_ip_addr CoreAddress;
217 u_int32_t CoreAddress;
218 //REMEMBER:Pad to 4 bytes this is a OLSR message
222 #endif /* _OBAMP_OBAMP_H */