Commit 48fcd151 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Clean up add_network.

parent eaac3c08
...@@ -44,25 +44,29 @@ int numnets = 0; ...@@ -44,25 +44,29 @@ int numnets = 0;
struct network * struct network *
add_network(char *ifname) add_network(char *ifname)
{ {
struct network *net;
if(numnets >= MAXNETS) { if(numnets >= MAXNETS) {
fprintf(stderr, "Too many networks.\n"); fprintf(stderr, "Too many networks.\n");
return NULL; return NULL;
} }
memset(nets + numnets, 0, sizeof(struct network)); net = &nets[numnets];
nets[numnets].up = 0;
nets[numnets].ifindex = 0; memset(net, 0, sizeof(struct network));
nets[numnets].ipv4 = NULL; net->up = 0;
nets[numnets].activity_time = now.tv_sec; net->ifindex = 0;
nets[numnets].bufsize = 0; net->ipv4 = NULL;
strncpy(nets[numnets].ifname, ifname, IF_NAMESIZE); net->activity_time = now.tv_sec;
nets[numnets].sendbuf = NULL; net->bufsize = 0;
nets[numnets].buffered = 0; strncpy(net->ifname, ifname, IF_NAMESIZE);
nets[numnets].bucket_time = now.tv_sec; net->sendbuf = NULL;
nets[numnets].bucket = BUCKET_TOKENS_MAX; net->buffered = 0;
nets[numnets].hello_seqno = (random() & 0xFFFF); net->bucket_time = now.tv_sec;
net->bucket = BUCKET_TOKENS_MAX;
net->hello_seqno = (random() & 0xFFFF);
numnets++; numnets++;
return &nets[numnets - 1]; return net;
} }
int int
......
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