-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunRouter.c
148 lines (120 loc) · 3.75 KB
/
runRouter.c
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// runRouter runs the whole program
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "externVariables.h"
int L2MAXLOAD;
int L3MAXLOAD;
void main(){
enum inputQueues {inptQA, inptQB, inptQC, inptQD, inptQE, mainQ, outPtQA, outPtQB, outPtQC, outPtQD, outPtQE };
// This piece of code sets the length of layer two's payload array.
int l2PayLoadLength;
int l3PayLoadLength;
int out = 0;
int out1 = 0;
while(out == 0){
puts("Enter layer 2 pay load array length | Must not be < 5 or > 30");
scanf("%d", &l2PayLoadLength);
if(l2PayLoadLength >= 4 && l2PayLoadLength <= 30){
L2MAXLOAD = l2PayLoadLength;
out = 1;
}
else{
out = 0;
}
}
while(out1 == 0){
puts("Enter layer 3 pay load array length | Must not be > 28");
scanf("%d", &l3PayLoadLength);
if(l3PayLoadLength <= 28 && l3PayLoadLength > -1){
L3MAXLOAD = l3PayLoadLength;
out1 = 1;
}
else{
out1 = 0;
}
} //end setting of layer two array length.
feeder();
puts("\n\nPackets in ecs501's input Queue A");
puts("------------------------------------");
display(inptQA);
puts("\n\nPackets in ecs501's input Queue B");
puts("------------------------------------");
display(inptQB);
puts("\n\nPackets in ecs501's input Queue C");
puts("------------------------------------");
display(inptQC);
puts("\n\nPackets in ecs501's input Queue D");
puts("------------------------------------");
display(inptQD);
puts("\n\nPackets in ecs501's input Queue E");
puts("------------------------------------");
display(inptQE);
puts("\n\nPackets in ecs501's main Queue");
puts("------------------------------------");
display(mainQ);
puts("\n\nPackets in ecs501's output Queue A");
puts("------------------------------------");
display(outPtQA);
puts("\n\nPackets in ecs501's output Queue B");
puts("------------------------------------");
display(outPtQB);
puts("\n\nPackets in ecs501's output Queue C");
puts("------------------------------------");
display(outPtQC);
puts("\n\nPackets in ecs501's output Queue D");
puts("------------------------------------");
display(outPtQD);
puts("\n\nPackets in ecs501's output Queue E");
puts("------------------------------------");
display(outPtQE);
}
//end main()
/********************************************************/
/*
Tester function; part of the user interface
and placed here for conveinience. This piece of
code is no longer used in this program.
*/
void testerFunction(){
int choice, control, Q;
char waste;
struct l2Packet *deqdPakt;
//User interface for debugging queues.
control = 1;
while(control){
puts("Choose queue:");
puts("0 - inputQueueA");
puts("1 - inputQueueB");
puts("2 - inputQueueC");
puts("3 - inputQueueD");
puts("4 - inputQueueE");
puts("5 - mainQueue");
scanf("%d", &Q);
waste = getchar();
printf("1 - Dequeue\n");
printf("2 - Queue Size\n");
printf("3 - Display queue\n");
printf("4 - stop and exit\n");
printf("Enter choice: \n");
scanf("%d", &choice);
waste = getchar();
switch (choice){
case 1:
deqdPakt = (struct l2Packet*) dequeue(Q);
free(deqdPakt);
break;
case 2:
printf("The queue has %d nodes.\n", queueSize(Q));
break;
case 3:
display(Q);
break;
case 4:
//I need to empty the queue on exit
control = 0;
default:
break;
} //end queue control switch statement
} //end queue control while loop and GUI
}//end testerFunction()