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
00044
00045
00046
00047 #ifndef _PROTOCOLS_OLSR_H
00048 #define _PROTOCOLS_OLSR_H
00049
00050 #include "olsr_types.h"
00051 #include "olsr_cfg.h"
00052
00053 #include <string.h>
00054
00055
00056 #define OLSRPORT 698
00057
00058
00059
00060 #define OLSR_IPV6_MCAST_SITE_LOCAL "ff05::15"
00061 #define OLSR_IPV6_MCAST_GLOBAL "ff0e::1"
00062
00063 #define OLSR_HEADERSIZE (sizeof(uint16_t) + sizeof(uint16_t))
00064
00065 #define OLSR_MSGHDRSZ_IPV4 12
00066 #define OLSR_MSGHDRSZ_IPV6 24
00067
00068
00069
00070
00071
00072
00073 #define HELLO_INTERVAL 2000
00074 #define REFRESH_INTERVAL 2000
00075 #define TC_INTERVAL 5000
00076 #define MID_INTERVAL TC_INTERVAL
00077 #define HNA_INTERVAL TC_INTERVAL
00078
00079
00080
00081 #define HELLO_JITTER 25
00082 #define HNA_JITTER 25
00083 #define MID_JITTER 25
00084 #define TC_JITTER 25
00085
00086
00087
00088
00089
00090 #define NEIGHB_HOLD_TIME 10 * REFRESH_INTERVAL
00091 #define TOP_HOLD_TIME 60 * TC_INTERVAL
00092 #define DUP_HOLD_TIME 30000
00093 #define MID_HOLD_TIME 60 * MID_INTERVAL
00094 #define HNA_HOLD_TIME 60 * HNA_INTERVAL
00095
00096
00097
00098
00099
00100 enum olsr_message_types {
00101 HELLO_MESSAGE = 1,
00102 TC_MESSAGE = 2,
00103 MID_MESSAGE = 3,
00104 HNA_MESSAGE = 4,
00105 };
00106
00107
00108
00109
00110
00111 enum olsr_link_types {
00112 UNSPEC_LINK,
00113 ASYM_LINK,
00114 SYM_LINK,
00115 LOST_LINK,
00116 COUNT_LINK_TYPES
00117 };
00118
00119
00120
00121
00122
00123 enum olsr_neigh_types {
00124 NOT_NEIGH,
00125 SYM_NEIGH,
00126 MPR_NEIGH,
00127 COUNT_NEIGH_TYPES
00128 };
00129
00130
00131
00132
00133
00134 #define WILL_NEVER 0
00135 #define WILL_LOW 1
00136 #define WILL_DEFAULT 3
00137 #define WILL_HIGH 6
00138 #define WILL_ALWAYS 7
00139
00140
00141
00142
00143 #define TC_REDUNDANCY 2
00144 #define MPR_COVERAGE 5
00145
00146
00147
00148
00149 #define MAXJITTER HELLO_INTERVAL / 4
00150 #define MAX_TTL 0xff
00151
00152
00153
00154
00155
00156
00157
00158 #define MAXVALUE 0xFFFF
00159
00160
00161 #define SEQNO_GREATER_THAN(s1, s2) \
00162 (((s1 > s2) && (s1 - s2 <= (MAXVALUE/2))) \
00163 || ((s2 > s1) && (s2 - s1 > (MAXVALUE/2))))
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 #define CREATE_LINK_CODE(status, link) (link | (status<<2))
00174
00175 #define EXTRACT_STATUS(link_code) ((link_code & 0xC)>>2)
00176
00177 #define EXTRACT_LINK(link_code) (link_code & 0x3)
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 struct hellinfo {
00193 uint8_t link_code;
00194 uint8_t reserved;
00195 uint16_t size;
00196 uint32_t neigh_addr[1];
00197 } __attribute__ ((packed));
00198
00199 struct hellomsg {
00200 uint16_t reserved;
00201 uint8_t htime;
00202 uint8_t willingness;
00203 struct hellinfo hell_info[1];
00204 } __attribute__ ((packed));
00205
00206
00207
00208
00209
00210 struct hellinfo6 {
00211 uint8_t link_code;
00212 uint8_t reserved;
00213 uint16_t size;
00214 struct in6_addr neigh_addr[1];
00215 } __attribute__ ((packed));
00216
00217 struct hellomsg6 {
00218 uint16_t reserved;
00219 uint8_t htime;
00220 uint8_t willingness;
00221 struct hellinfo6 hell_info[1];
00222 } __attribute__ ((packed));
00223
00224
00225
00226
00227
00228 struct neigh_info {
00229 uint32_t addr;
00230 } __attribute__ ((packed));
00231
00232
00233 struct olsr_tcmsg {
00234 uint16_t ansn;
00235 uint16_t reserved;
00236 struct neigh_info neigh[1];
00237 } __attribute__ ((packed));
00238
00239
00240
00241
00242
00243
00244
00245 struct neigh_info6 {
00246 struct in6_addr addr;
00247 } __attribute__ ((packed));
00248
00249
00250 struct olsr_tcmsg6 {
00251 uint16_t ansn;
00252 uint16_t reserved;
00253 struct neigh_info6 neigh[1];
00254 } __attribute__ ((packed));
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 struct midaddr {
00270 uint32_t addr;
00271 } __attribute__ ((packed));
00272
00273
00274 struct midmsg {
00275 struct midaddr mid_addr[1];
00276 } __attribute__ ((packed));
00277
00278
00279
00280
00281
00282 struct midaddr6 {
00283 struct in6_addr addr;
00284 } __attribute__ ((packed));
00285
00286
00287 struct midmsg6 {
00288 struct midaddr6 mid_addr[1];
00289 } __attribute__ ((packed));
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 struct hnapair {
00300 uint32_t addr;
00301 uint32_t netmask;
00302 } __attribute__ ((packed));
00303
00304 struct hnamsg {
00305 struct hnapair hna_net[1];
00306 } __attribute__ ((packed));
00307
00308
00309
00310
00311
00312 struct hnapair6 {
00313 struct in6_addr addr;
00314 struct in6_addr netmask;
00315 } __attribute__ ((packed));
00316
00317 struct hnamsg6 {
00318 struct hnapair6 hna_net[1];
00319 } __attribute__ ((packed));
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 struct olsr_message {
00330 uint8_t type;
00331 uint32_t vtime;
00332 uint16_t size;
00333 union olsr_ip_addr originator;
00334 uint8_t ttl;
00335 uint8_t hopcnt;
00336 uint16_t seqno;
00337
00338
00339 const uint8_t *header;
00340 const uint8_t *payload;
00341 const uint8_t *end;
00342 };
00343
00344
00345
00346
00347
00348 struct olsr_packet {
00349 uint16_t size;
00350 uint16_t seqno;
00351 } __attribute__ ((packed));
00352 #endif
00353
00354
00355
00356
00357
00358
00359