mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Use trigger for interface up/down
This commit is contained in:
parent
b5afcf9a8f
commit
cf8932d5ba
@ -137,3 +137,8 @@ int directory_registration(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void interface_change(struct overlay_interface *UNUSED(interface)){
|
||||
directory_registration();
|
||||
}
|
||||
|
||||
DEFINE_TRIGGER(iupdown, interface_change);
|
||||
|
11
monitor.c
11
monitor.c
@ -685,3 +685,14 @@ int monitor_tell_formatted(int mask, char *fmt, ...){
|
||||
monitor_tell_clients(msg, n, mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void monitor_interface_change(struct overlay_interface *interface){
|
||||
if (interface->state==INTERFACE_STATE_UP)
|
||||
monitor_tell_formatted(MONITOR_INTERFACE, "\nINTERFACE:%s:UP\n", interface->name);
|
||||
else if(interface->state==INTERFACE_STATE_DOWN)
|
||||
monitor_tell_formatted(MONITOR_INTERFACE, "\nINTERFACE:%s:DOWN\n", interface->name);
|
||||
}
|
||||
|
||||
DEFINE_TRIGGER(iupdown, monitor_interface_change);
|
||||
|
||||
|
||||
|
@ -88,11 +88,10 @@ void overlay_interface_close(overlay_interface *interface)
|
||||
radio_link_free(interface);
|
||||
interface->state=INTERFACE_STATE_DOWN;
|
||||
|
||||
monitor_tell_formatted(MONITOR_INTERFACE, "\nINTERFACE:%s:DOWN\n", interface->name);
|
||||
INFOF("Interface %s addr %s is down",
|
||||
interface->name, alloca_socket_address(&interface->address));
|
||||
CALL_TRIGGER(iupdown, interface);
|
||||
|
||||
link_interface_down(interface);
|
||||
}
|
||||
|
||||
void overlay_interface_close_all()
|
||||
@ -649,15 +648,12 @@ overlay_interface_init(const char *name,
|
||||
return -1;
|
||||
|
||||
interface->state=INTERFACE_STATE_UP;
|
||||
monitor_tell_formatted(MONITOR_INTERFACE, "\nINTERFACE:%s:UP\n", interface->name);
|
||||
INFOF("Interface %s addr %s, is up",interface->name, alloca_socket_address(addr));
|
||||
|
||||
directory_registration();
|
||||
|
||||
INFOF("Allowing a maximum of %d packets every %"PRId64"ms",
|
||||
interface->destination->transfer_limit.burst_size,
|
||||
interface->destination->transfer_limit.burst_length);
|
||||
|
||||
|
||||
CALL_TRIGGER(iupdown, interface);
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
|
@ -136,4 +136,6 @@ int overlay_broadcast_ensemble(struct network_destination *destination, struct o
|
||||
void interface_state_html(struct strbuf *b, struct overlay_interface *interface);
|
||||
void overlay_interface_monitor_up();
|
||||
|
||||
DECLARE_TRIGGER(iupdown, struct overlay_interface *);
|
||||
|
||||
#endif // __SERVAL_DNA__OVERLAY_INTERFACE_H
|
||||
|
@ -1580,11 +1580,13 @@ void link_explained(struct subscriber *subscriber)
|
||||
update_alarm(__WHENCE__, now + 5);
|
||||
}
|
||||
|
||||
void link_interface_down(struct overlay_interface *UNUSED(interface))
|
||||
static void link_interface_change(struct overlay_interface *UNUSED(interface))
|
||||
{
|
||||
clean_neighbours(gettime_ms());
|
||||
}
|
||||
|
||||
DEFINE_TRIGGER(iupdown, link_interface_change);
|
||||
|
||||
/* if an ancient node on the network uses their old protocol to tell us that they can hear us;
|
||||
- send the same format back at them
|
||||
- treat the link as up.
|
||||
|
@ -42,7 +42,6 @@ int link_received_duplicate(struct decode_context *context, int payload_seq);
|
||||
int link_received_packet(struct decode_context *context, int sender_seq, uint8_t unicast);
|
||||
int link_unicast_ack(struct subscriber *subscriber, struct overlay_interface *interface, struct socket_address *addr);
|
||||
void link_explained(struct subscriber *subscriber);
|
||||
void link_interface_down(struct overlay_interface *interface);
|
||||
int link_state_legacy_ack(struct overlay_frame *frame, time_ms_t now);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user