-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsrout.cpp
150 lines (146 loc) · 3.31 KB
/
parsrout.cpp
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
147
148
149
150
// MaxiM: memicmp
#include "partoss.h"
#include "globext.h"
#include "globfunc.h"
#include "parsrout.h"
#include "lowlevel.h"
#include "morfiles.h"
#include "chains.h"
void runroute (void)
{
struct route *trou = NULL;
struct myaddr tsnd;
char hfile[DirSize + 1];
addhome (hfile, bcfg.route);
setf = mysopen (hfile, 0, __FILE__, __LINE__);
mystrncpy (confile, hfile, DirSize);
lineno[0] = 1;
endinput[0] = 0;
while (!endinput[0])
{
readblock (setf, 0);
endblock[0] = 0;
do
{
getstring (0);
gettoken (0);
if (*token != ';')
{
memcpy (&defaddr, bcfg.address.chain, szmyaddr);
if (memicmp (token, "Route", 5) == 0)
{
gettoken (0);
if (isdigit (token[0]) || token[0] == '/' || token[0] == ':'
|| token[0] == '.')
{
if (roulist == NULL)
{
roulist =
(struct route *)myalloc (szroute, __FILE__,
__LINE__);
trou = roulist;
}
else
{
trou = roulist;
while (trou->next)
trou = trou->next;
trou->next =
(struct route *)myalloc (szroute, __FILE__,
__LINE__);
trou = trou->next;
}
memset (trou, 0, szroute);
trou->next = NULL;
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(trou->list), &tsnd);
while (!endstring[0])
{
gettoken (0);
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(trou->list), &tsnd);
}
}
}
else
{
if (memicmp (token, "Direct", 6) == 0)
{
gettoken (0);
if (direct == NULL)
{
direct =
(struct route *)myalloc (szroute, __FILE__,
__LINE__);
memset (direct, 0, szroute);
direct->next = NULL;
}
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(direct->list), &tsnd);
while (!endstring[0])
{
gettoken (0);
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(direct->list), &tsnd);
}
}
else
{
if (memicmp (token, "NoTouch", 7) == 0)
{
gettoken (0);
if (notouch == NULL)
{
notouch =
(struct route *)myalloc (szroute, __FILE__,
__LINE__);
memset (notouch, 0, szroute);
notouch->next = NULL;
}
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(notouch->list), &tsnd);
while (!endstring[0])
{
gettoken (0);
parseaddr (token, &tsnd, toklen);
if (tsnd.zone)
addaddr (&(notouch->list), &tsnd);
}
}
else
{
tokencpy (logout, BufSize);
if (strlen (logout))
ccprintf
("Incorrect keyword \"%s\" in %s (line %d)\r\n",
logout, bcfg.route, lineno[0]);
}
}
}
}
lineno[0] += numcr[0];
}
while (!endblock[0]);
}
cclose (&setf, __FILE__, __LINE__);
}
short compaddr (struct myaddr *chain, struct myaddr *mess)
{
struct myaddr *current = NULL;
current = chain;
while (current != NULL)
{
if ((current->zone == mess->zone || current->zone == 65535u) &&
(current->net == mess->net || current->net == 65535u) &&
(current->node == mess->node || current->node == 65535u) &&
(current->point == mess->point || current->point == 65535u))
return 0;
current = current->next;
}
return 1;
}