Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
570a7e3f
Commit
570a7e3f
authored
May 19, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to using a linked list for the list of networks.
parent
c98f3b55
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
11 deletions
+25
-11
babel.h
babel.h
+0
-1
network.c
network.c
+22
-8
network.h
network.h
+3
-2
No files found.
babel.h
View file @
570a7e3f
...
...
@@ -23,7 +23,6 @@ THE SOFTWARE.
#define MAXROUTES 512
#define MAXSRCS 256
#define MAXNEIGHBOURS 64
#define MAXNETS 16
#define MAXXROUTES 64
#define INFINITY ((unsigned short)(~0))
...
...
network.c
View file @
570a7e3f
...
...
@@ -38,20 +38,30 @@ THE SOFTWARE.
#include "route.h"
#include "filter.h"
struct
network
nets
[
MAXNETS
];
int
numnets
=
0
;
struct
network
*
networks
=
NULL
;
static
struct
network
*
last_network
(
void
)
{
struct
network
*
net
=
networks
;
if
(
!
net
)
return
NULL
;
while
(
net
->
next
)
net
=
net
->
next
;
return
net
;
}
struct
network
*
add_network
(
char
*
ifname
)
{
struct
network
*
net
;
if
(
numnets
>=
MAXNETS
)
{
fprintf
(
stderr
,
"Too many networks.
\n
"
);
net
=
malloc
(
sizeof
(
struct
network
));
if
(
net
==
NULL
)
return
NULL
;
}
net
=
&
nets
[
numnets
];
memset
(
net
,
0
,
sizeof
(
struct
network
));
net
->
up
=
0
;
...
...
@@ -65,7 +75,11 @@ add_network(char *ifname)
net
->
bucket_time
=
now
.
tv_sec
;
net
->
bucket
=
BUCKET_TOKENS_MAX
;
net
->
hello_seqno
=
(
random
()
&
0xFFFF
);
numnets
++
;
if
(
networks
==
NULL
)
networks
=
net
;
else
last_network
()
->
next
=
net
;
return
net
;
}
...
...
network.h
View file @
570a7e3f
...
...
@@ -21,6 +21,7 @@ THE SOFTWARE.
*/
struct
network
{
struct
network
*
next
;
int
up
;
unsigned
int
ifindex
;
int
wired
;
...
...
@@ -45,10 +46,10 @@ struct network {
unsigned
int
self_update_interval
;
};
extern
struct
network
nets
[
MAXNETS
]
;
extern
struct
network
*
networks
;
extern
int
numnets
;
#define FOR_ALL_NETS(_net) for(_net = net
s; _net < nets + numnets; _net++
)
#define FOR_ALL_NETS(_net) for(_net = net
works; _net; _net = _net->next
)
struct
network
*
add_network
(
char
*
ifname
);
int
network_idle
(
struct
network
*
net
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment