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

Clean up add_network.

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