Skip to content

Commit a496223

Browse files
interface/local: add remove_interface function
Babeld can add interfaces dynamically. However, babeld is missing a function to remove interfaces and stop meshing on them. Add a function that can do it. Signed-off-by: Nick Hainke <vincent@systemli.org>
1 parent 91c44f8 commit a496223

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

interface.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,33 @@ add_interface(char *ifname, struct interface_conf *if_conf)
9696
return ifp;
9797
}
9898

99+
void
100+
remove_interface(char *ifname)
101+
{
102+
struct interface *ifp = NULL;
103+
104+
if(interfaces == NULL)
105+
return;
106+
107+
if(strcmp(interfaces->name, ifname) == 0) {
108+
interfaces = interfaces->next;
109+
return;
110+
}
111+
112+
FOR_ALL_INTERFACES(ifp) {
113+
if(ifp->next == NULL)
114+
break;
115+
if(strcmp(ifp->next->name, ifname) == 0) {
116+
break;
117+
}
118+
}
119+
120+
if(ifp->next == NULL)
121+
return;
122+
123+
interfaces = ifp->next;
124+
}
125+
99126
int
100127
flush_interface(char *ifname)
101128
{

interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ if_up(struct interface *ifp)
163163
}
164164

165165
struct interface *add_interface(char *ifname, struct interface_conf *if_conf);
166+
void remove_interface(char *ifname);
166167
int flush_interface(char *ifname);
167168
unsigned jitter(struct buffered *buf, int urgent);
168169
unsigned update_jitter(struct interface *ifp, int urgent);

local.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct xroute;
2727
#define LOCAL_FLUSH 0
2828
#define LOCAL_ADD 1
2929
#define LOCAL_CHANGE 2
30+
#define LOCAL_REMOVE 3
3031

3132
#ifndef MAX_LOCAL_SOCKETS
3233
#define MAX_LOCAL_SOCKETS 4

0 commit comments

Comments
 (0)