-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.h
75 lines (55 loc) · 1.21 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
#ifndef __GRAPH__
#define __GRAPH__
#include "gluethread/glthread.h"
#include "net.h"
/* global constant values*/
#define GRAPH_NAME_SIZE 32
#define NODE_NAME_SIZE 16
#define INTF_NAME_SIZE 16
#define MAX_INTF_PER_NODE 10
typedef struct node_ Node;
typedef struct link_ Link;
typedef struct graph_ {
char topology_name[GRAPH_NAME_SIZE];
glthread list;
} Graph;
typedef struct interface_ {
char intf_name[INTF_NAME_SIZE];
Node *src_node;
Link *link;
IntfNetProp intf_net_prop;
} Interface;
struct node_ {
char node_name[NODE_NAME_SIZE];
Interface *intf[MAX_INTF_PER_NODE];
glthread glue;
NodeNetProp node_net_prop;
};
struct link_ {
Interface intf1;
Interface intf2;
unsigned int cost;
};
GLTHREAD_TO_STRUCT(glue_to_node, Node, glue)
int
ret_empty_intf_slot(Node *node);
Node *
get_other_node(Interface *intf);
Interface *
get_intf_from_intf_name(Node *node, char *intf);
Node *
get_node_from_node_name(Graph *graph, char *node);
Graph *
create_graph(char *topo_name);
Node *
create_node(Graph *graph, char *node_name);
void
insert_link(Node* n1, Node* n2, char *from_if,
char *to_if, unsigned int cost);
void
dump_graph(Graph *graph);
void
dump_node(Node *node);
void
dump_interface(Interface *intf);
#endif