-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgraph.h
94 lines (49 loc) · 1.48 KB
/
graph.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
84
85
86
87
88
89
90
91
92
#ifndef GRAPH
#define GRAPH
#include "networking.h"
#define NAME_SIZE 32
#define MAXIMUM_INTERFACE_PER_NODE 48
#define IF_NAME_SIZE 16
typedef struct Node node;
typedef struct Interface interface;
typedef struct Edge edge;
typedef struct Graph graph;
typedef struct Node{
char routerName[NAME_SIZE];
interface *intf[MAXIMUM_INTERFACE_PER_NODE];
graph *linkStateDatabase;
unsigned int udp_port_number;
int udp_sock_fd;
routing_table rt;
ip_add loopbackIPAddress;
}node;
typedef struct Interface{
char interfaceName[NAME_SIZE];
node *attachedNode;
edge *attachedEdge;
intf_properties interfaceProperties; // IP address, MAC Address and Subnet Mask;
}interface;
typedef struct Edge{
interface intf1;
interface intf2;
int cost;
}edge;
typedef struct Graph{
int numVertex,numEdges;
node *routersArray;
edge *edgesArray;
}graph;
// Creating Topology
graph* createGraph(int vertex,int edges);
void createGraphNodes(node* router, char *name);
edge* addEdge(graph* topology,node* node1 , node* router2, char* name1, char* name2, int cost);
void printGraph(graph* topology);
void printInterface(interface *intf);
void printEdges(graph* topology,int numEdges);
// Helper Functions
int getEmptyInterfaceSlot();
int getIndexOfNode(node* router,graph* topology);
char *my_itoa(int num, char *str);
node *getNeighbourNode(interface *intf);
interface * get_node_if_by_name(node *router, char *if_name);
#endif