-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodr_lib.h
83 lines (60 loc) · 1.77 KB
/
odr_lib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef ODR_LIB_H
#define ODR_LIB_H
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <netdb.h>
#include "hw_addrs.h"
#define UNIX_D_PATH "unix2159.dg"
struct route_entry{
unsigned long dest_ip; /*Entry for which destination*/
int if_index; /*which local interface to use*/
char neighbour[8]; /*neighbour's MAC from which destination is reachable*/
int hop_count; /*Destination reachable in how many hops*/
time_t ts; /*time stamp when this entry was made*/
struct route_entry *next;
};
extern int bcast_id;
typedef struct route_entry t_route;
struct odr_packet{
int type;
#define RREQ 0
#define RREP 1
#define APP_DATA 2
unsigned long source_ip;
unsigned long dest_ip;
int source_port;
int dest_port;
int hop_count;
int bcast_id;
int flag;
#define FORCED_ROUTE 0x01
#define REP_ALREADY_SENT 0x02
char data[40]; /*valid only if DREQ or DREP else ignored*/
};
typedef struct odr_packet t_odrp;
struct seen_list_node{
unsigned long source_ip;
int broadcast_id;
struct seen_list_node *next;
};
int is_dup_req(unsigned long source_ip,int broadcast_id,int hop_count);
struct queue_node {
t_odrp packet;
struct queue_node *next;
};
typedef struct queue_node qnode;
typedef struct seen_list_node snode;
extern snode *shead;
extern qnode *qhead;
extern t_route *head;
t_route * find_route_entry(unsigned long dest_ip,time_t ts);
int add_route_entry(unsigned long dest_ip,int if_index, char* neighbour,int hop_count,time_t ts,int force);
int send_pf_packet(int sockfd,int index_in_if_list, char *dest_mac, t_odrp *odr_packet);
char *get_name(unsigned long);
int recv_process_pf_packet(int,int );
int is_dup_req(unsigned long source_ip,int broadcast_id,int hop_count);
qnode* enqueue(t_odrp *packet);
qnode * dequeue( unsigned long dest_ip);
#endif