mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Add monitor message for interface up/down events
This commit is contained in:
parent
ee37385ec7
commit
628a52ca87
@ -103,6 +103,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define MONITOR_DNAHELPER (1<<3)
|
||||
#define MONITOR_LINKS (1<<4)
|
||||
#define MONITOR_QUIT (1<<5)
|
||||
#define MONITOR_INTERFACE (1<<6)
|
||||
|
||||
#define MAX_SIGNATURES 16
|
||||
|
||||
|
@ -61,6 +61,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "str.h"
|
||||
#include "strbuf_helpers.h"
|
||||
#include "overlay_address.h"
|
||||
#include "overlay_interface.h"
|
||||
#include "monitor-client.h"
|
||||
#include "socket.h"
|
||||
#include "dataformats.h"
|
||||
@ -422,6 +423,9 @@ static int monitor_set(const struct cli_parsed *parsed, struct cli_context *cont
|
||||
link_state_announce_links();
|
||||
}else if (strcase_startswith(parsed->args[1],"quit", NULL)){
|
||||
c->flags|=MONITOR_QUIT;
|
||||
}else if (strcase_startswith(parsed->args[1],"interface", NULL)){
|
||||
c->flags|=MONITOR_INTERFACE;
|
||||
overlay_interface_monitor_up();
|
||||
}else
|
||||
return monitor_write_error(c,"Unknown monitor type");
|
||||
|
||||
@ -447,6 +451,8 @@ static int monitor_clear(const struct cli_parsed *parsed, struct cli_context *co
|
||||
c->flags&=~MONITOR_LINKS;
|
||||
else if (strcase_startswith(parsed->args[1],"quit", NULL))
|
||||
c->flags&=~MONITOR_QUIT;
|
||||
else if (strcase_startswith(parsed->args[1],"interface", NULL))
|
||||
c->flags&=~MONITOR_INTERFACE;
|
||||
else
|
||||
return monitor_write_error(c,"Unknown monitor type");
|
||||
|
||||
|
@ -60,6 +60,7 @@ static void overlay_interface_poll(struct sched_ent *alarm);
|
||||
|
||||
static void
|
||||
overlay_interface_close(overlay_interface *interface){
|
||||
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));
|
||||
if (interface->address.addr.sa_family == AF_UNIX)
|
||||
@ -84,6 +85,15 @@ void overlay_interface_close_all()
|
||||
}
|
||||
}
|
||||
|
||||
void overlay_interface_monitor_up()
|
||||
{
|
||||
unsigned i;
|
||||
for (i=0;i<OVERLAY_MAX_INTERFACES;i++){
|
||||
if (overlay_interfaces[i].state == INTERFACE_STATE_UP)
|
||||
monitor_tell_formatted(MONITOR_INTERFACE, "\nINTERFACE:%s:UP\n", overlay_interfaces[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
void interface_state_html(struct strbuf *b, struct overlay_interface *interface)
|
||||
{
|
||||
switch(interface->state){
|
||||
@ -537,6 +547,7 @@ overlay_interface_init(const char *name, struct socket_address *addr,
|
||||
interface->alarm.deadline=interface->alarm.alarm;
|
||||
schedule(&interface->alarm);
|
||||
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();
|
||||
|
@ -160,5 +160,6 @@ overlay_interface * overlay_interface_find_name(const char *name);
|
||||
int overlay_interface_compare(overlay_interface *one, overlay_interface *two);
|
||||
int overlay_broadcast_ensemble(struct network_destination *destination, struct overlay_buffer *buffer);
|
||||
void interface_state_html(struct strbuf *b, struct overlay_interface *interface);
|
||||
void overlay_interface_monitor_up();
|
||||
|
||||
#endif // __SERVAL_DNA__OVERLAY_INTERFACE_H
|
||||
|
Loading…
Reference in New Issue
Block a user