Commit ecac798d authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make add_network take a configuration parameter.

parent 787d2e65
...@@ -357,7 +357,7 @@ main(int argc, char **argv) ...@@ -357,7 +357,7 @@ main(int argc, char **argv)
while(*arg) { while(*arg) {
debugf("Adding network %s.\n", *arg); debugf("Adding network %s.\n", *arg);
vrc = add_network(*arg); vrc = add_network(*arg, NULL);
if(vrc == NULL) if(vrc == NULL)
goto fail; goto fail;
SHIFT(); SHIFT();
......
...@@ -55,17 +55,23 @@ last_network(void) ...@@ -55,17 +55,23 @@ last_network(void)
} }
struct network * struct network *
add_network(char *ifname) add_network(char *ifname, struct network_conf *conf)
{ {
struct network *net; struct network *net;
if(conf) {
if(strcmp(ifname, conf->ifname) != 0)
return NULL;
}
net = malloc(sizeof(struct network)); net = malloc(sizeof(struct network));
if(net == NULL) if(net == NULL)
return NULL; return NULL;
memset(net, 0, sizeof(struct network)); memset(net, 0, sizeof(struct network));
net->activity_time = now.tv_sec;
strncpy(net->ifname, ifname, IF_NAMESIZE); strncpy(net->ifname, ifname, IF_NAMESIZE);
net->conf = conf;
net->activity_time = now.tv_sec;
net->bucket_time = now.tv_sec; net->bucket_time = now.tv_sec;
net->bucket = BUCKET_TOKENS_MAX; net->bucket = BUCKET_TOKENS_MAX;
net->hello_seqno = (random() & 0xFFFF); net->hello_seqno = (random() & 0xFFFF);
......
...@@ -27,8 +27,14 @@ struct buffered_update { ...@@ -27,8 +27,14 @@ struct buffered_update {
unsigned char pad[3]; unsigned char pad[3];
}; };
struct network_conf {
char *ifname;
struct network_conf *next;
};
struct network { struct network {
struct network *next; struct network *next;
struct network_conf *conf;
char up; char up;
char wired; char wired;
unsigned int ifindex; unsigned int ifindex;
...@@ -68,7 +74,7 @@ extern int numnets; ...@@ -68,7 +74,7 @@ extern int numnets;
#define FOR_ALL_NETS(_net) for(_net = networks; _net; _net = _net->next) #define FOR_ALL_NETS(_net) for(_net = networks; _net; _net = _net->next)
struct network *add_network(char *ifname); struct network *add_network(char *ifname, struct network_conf *conf);
int network_idle(struct network *net); int network_idle(struct network *net);
int update_hello_interval(struct network *net); int update_hello_interval(struct network *net);
unsigned jitter(struct network *net, int urgent); unsigned jitter(struct network *net, int urgent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment