1
1
/*
2
- ** igmpproxy - IGMP proxy based multicast router
2
+ ** igmpproxy - IGMP proxy based multicast router
3
3
** Copyright (C) 2005 Johnny Egeland <[email protected] >
4
4
**
5
5
** This program is free software; you can redistribute it and/or modify
33
33
*/
34
34
/**
35
35
* config.c - Contains functions to load and parse config
36
- * file, and functions to configure the daemon.
36
+ * file, and functions to configure the daemon.
37
37
*/
38
38
39
39
#include "igmpproxy.h"
40
-
41
- // Structure to keep configuration for VIFs...
40
+
41
+ // Structure to keep configuration for VIFs...
42
42
struct vifconfig {
43
43
char * name ;
44
44
short state ;
@@ -50,13 +50,13 @@ struct vifconfig {
50
50
51
51
// Allowed Groups
52
52
struct SubnetList * allowedgroups ;
53
-
53
+
54
54
// Next config in list...
55
55
struct vifconfig * next ;
56
56
};
57
-
57
+
58
58
// Structure to keep vif configuration
59
- struct vifconfig * vifconf ;
59
+ struct vifconfig * vifconf ;
60
60
61
61
// Keeps common settings...
62
62
static struct Config commonConfig ;
@@ -65,7 +65,6 @@ static struct Config commonConfig;
65
65
struct vifconfig * parsePhyintToken (void );
66
66
struct SubnetList * parseSubnetAddress (char * addrstr );
67
67
68
-
69
68
/**
70
69
* Initializes common config..
71
70
*/
@@ -84,11 +83,10 @@ static void initCommonConfig(void) {
84
83
85
84
// If 1, a leave message is sent upstream on leave messages from downstream.
86
85
commonConfig .fastUpstreamLeave = 0 ;
87
-
86
+
88
87
// aimwang: default value
89
88
commonConfig .defaultInterfaceState = IF_STATE_DISABLED ;
90
89
commonConfig .rescanVif = 0 ;
91
-
92
90
}
93
91
94
92
/**
@@ -99,14 +97,14 @@ struct Config *getCommonConfig(void) {
99
97
}
100
98
101
99
/**
102
- * Loads the configuration from file, and stores the config in
100
+ * Loads the configuration from file, and stores the config in
103
101
* respective holders...
104
- */
102
+ */
105
103
int loadConfig (char * configFile ) {
106
104
struct vifconfig * tmpPtr ;
107
105
struct vifconfig * * currPtr = & vifconf ;
108
106
char * token ;
109
-
107
+
110
108
// Initialize common config
111
109
initCommonConfig ();
112
110
@@ -146,29 +144,29 @@ int loadConfig(char *configFile) {
146
144
* currPtr = tmpPtr ;
147
145
currPtr = & tmpPtr -> next ;
148
146
}
149
- }
147
+ }
150
148
else if (strcmp ("quickleave" , token )== 0 ) {
151
149
// Got a quickleave token....
152
150
my_log (LOG_DEBUG , 0 , "Config: Quick leave mode enabled." );
153
151
commonConfig .fastUpstreamLeave = 1 ;
154
-
152
+
155
153
// Read next token...
156
154
token = nextConfigToken ();
157
155
continue ;
158
156
}
159
157
else if (strcmp ("defaultdown" , token )== 0 ) {
160
- // Got a defaultdown token...
161
- my_log (LOG_DEBUG , 0 , "Config: interface Default as down stream." );
162
- commonConfig .defaultInterfaceState = IF_STATE_DOWNSTREAM ;
158
+ // Got a defaultdown token...
159
+ my_log (LOG_DEBUG , 0 , "Config: interface Default as down stream." );
160
+ commonConfig .defaultInterfaceState = IF_STATE_DOWNSTREAM ;
163
161
164
162
// Read next token...
165
163
token = nextConfigToken ();
166
164
continue ;
167
165
}
168
166
else if (strcmp ("rescanvif" , token )== 0 ) {
169
- // Got a defaultdown token...
170
- my_log (LOG_DEBUG , 0 , "Config: Need detect new interace." );
171
- commonConfig .rescanVif = 1 ;
167
+ // Got a defaultdown token...
168
+ my_log (LOG_DEBUG , 0 , "Config: Need detect new interace." );
169
+ commonConfig .rescanVif = 1 ;
172
170
173
171
// Read next token...
174
172
token = nextConfigToken ();
@@ -216,19 +214,19 @@ void configureVifs(void) {
216
214
my_log (LOG_DEBUG , 0 , "Found config for %s" , Dp -> Name );
217
215
218
216
219
- // Set the VIF state
217
+ // Set the VIF state
220
218
Dp -> state = confPtr -> state ;
221
-
219
+
222
220
Dp -> threshold = confPtr -> threshold ;
223
221
Dp -> ratelimit = confPtr -> ratelimit ;
224
222
225
223
// Go to last allowed net on VIF...
226
224
for (vifLast = Dp -> allowednets ; vifLast -> next ; vifLast = vifLast -> next );
227
-
225
+
228
226
// Insert the configured nets...
229
227
vifLast -> next = confPtr -> allowednets ;
230
228
231
- Dp -> allowedgroups = confPtr -> allowedgroups ;
229
+ Dp -> allowedgroups = confPtr -> allowedgroups ;
232
230
233
231
break ;
234
232
}
@@ -277,7 +275,7 @@ struct vifconfig *parsePhyintToken(void) {
277
275
278
276
// Set the altnet pointer to the allowednets pointer.
279
277
anetPtr = & tmpPtr -> allowednets ;
280
- agrpPtr = & tmpPtr -> allowedgroups ;
278
+ agrpPtr = & tmpPtr -> allowedgroups ;
281
279
282
280
// Parse the rest of the config..
283
281
token = nextConfigToken ();
@@ -296,20 +294,20 @@ struct vifconfig *parsePhyintToken(void) {
296
294
anetPtr = & (* anetPtr )-> next ;
297
295
}
298
296
}
299
- else if (strcmp ("whitelist" , token )== 0 ) {
300
- // Whitelist
301
- token = nextConfigToken ();
302
- my_log (LOG_DEBUG , 0 , "Config: IF: Got whitelist token %s." , token );
303
-
304
- * agrpPtr = parseSubnetAddress (token );
305
- if (* agrpPtr == NULL ) {
306
- parseError = 1 ;
307
- my_log (LOG_WARNING , 0 , "Unable to parse subnet address." );
308
- break ;
309
- } else {
310
- agrpPtr = & (* agrpPtr )-> next ;
311
- }
312
- }
297
+ else if (strcmp ("whitelist" , token )== 0 ) {
298
+ // Whitelist
299
+ token = nextConfigToken ();
300
+ my_log (LOG_DEBUG , 0 , "Config: IF: Got whitelist token %s." , token );
301
+
302
+ * agrpPtr = parseSubnetAddress (token );
303
+ if (* agrpPtr == NULL ) {
304
+ parseError = 1 ;
305
+ my_log (LOG_WARNING , 0 , "Unable to parse subnet address." );
306
+ break ;
307
+ } else {
308
+ agrpPtr = & (* agrpPtr )-> next ;
309
+ }
310
+ }
313
311
else if (strcmp ("upstream" , token )== 0 ) {
314
312
// Upstream
315
313
my_log (LOG_DEBUG , 0 , "Config: IF: Got upstream token." );
@@ -369,10 +367,10 @@ struct vifconfig *parsePhyintToken(void) {
369
367
* a.b.c.d/n into a SubnetList entry.
370
368
*/
371
369
struct SubnetList * parseSubnetAddress (char * addrstr ) {
372
- struct SubnetList * tmpSubnet ;
373
- char * tmpStr ;
374
- uint32_t addr = 0x00000000 ;
375
- uint32_t mask = 0xFFFFFFFF ;
370
+ struct SubnetList * tmpSubnet ;
371
+ char * tmpStr ;
372
+ uint32_t addr = 0x00000000 ;
373
+ uint32_t mask = 0xFFFFFFFF ;
376
374
377
375
// First get the network part of the address...
378
376
tmpStr = strtok (addrstr , "/" );
@@ -403,7 +401,7 @@ struct SubnetList *parseSubnetAddress(char *addrstr) {
403
401
tmpSubnet -> next = NULL ;
404
402
405
403
my_log (LOG_DEBUG , 0 , "Config: IF: Altnet: Parsed altnet to %s." ,
406
- inetFmts (tmpSubnet -> subnet_addr , tmpSubnet -> subnet_mask ,s1 ));
404
+ inetFmts (tmpSubnet -> subnet_addr , tmpSubnet -> subnet_mask ,s1 ));
407
405
408
406
return tmpSubnet ;
409
407
}
0 commit comments