Continue SLPD refactor
This commit is contained in:
parent
26a7e51cbe
commit
0fbde0e5a0
4 changed files with 22 additions and 15 deletions
|
@ -315,20 +315,6 @@ static bool read_rsa_private_key(void) {
|
|||
static timeout_t keyexpire_timeout;
|
||||
static timeout_t edgeupdate_timeout;
|
||||
/* Local Peer Discovery */
|
||||
static timeout_t slpdupdate_timeout;
|
||||
|
||||
static void slpdupdate_handler(void *data) {
|
||||
config_t *c_iface;
|
||||
c_iface = lookup_config(config_tree, "SLPDInterface");
|
||||
|
||||
while(c_iface) {
|
||||
logger(DEBUG_STATUS, LOG_NOTICE, "Sending SLPD out on %s", c_iface->value);
|
||||
send_slpd_broadcast(myself, c_iface->value);
|
||||
c_iface = lookup_config_next(config_tree, c_iface);
|
||||
}
|
||||
|
||||
timeout_set(data, &(struct timeval){slpdinterval + (rand() % 10), rand() % 100000});
|
||||
}
|
||||
|
||||
static void keyexpire_handler(void *data) {
|
||||
regenerate_key();
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "net.h"
|
||||
#include "netutl.h"
|
||||
#include "protocol.h"
|
||||
#include "slpd.h"
|
||||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
|
|
17
src/slpd.c
17
src/slpd.c
|
@ -24,7 +24,8 @@ char *my_slpd_group;
|
|||
int my_slpd_expire;
|
||||
int slpdinterval = 0;
|
||||
|
||||
extern char *myname;
|
||||
//extern char *myname;
|
||||
timeout_t slpdupdate_timeout;
|
||||
|
||||
void periodic_slpd_handler(void) {
|
||||
// expire SLPD addresses
|
||||
|
@ -40,6 +41,20 @@ void periodic_slpd_handler(void) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void slpdupdate_handler(void *data) {
|
||||
config_t *c_iface;
|
||||
c_iface = lookup_config(config_tree, "SLPDInterface");
|
||||
|
||||
while(c_iface) {
|
||||
logger(DEBUG_STATUS, LOG_NOTICE, "Sending SLPD out on %s", c_iface->value);
|
||||
send_slpd_broadcast(myself, c_iface->value);
|
||||
c_iface = lookup_config_next(config_tree, c_iface);
|
||||
}
|
||||
|
||||
timeout_set(data, &(struct timeval){slpdinterval + (rand() % 10), rand() % 100000});
|
||||
}
|
||||
|
||||
void setup_slpd(void) {
|
||||
if(!get_config_string(lookup_config(config_tree, "SLPDPort"), &my_slpd_port))
|
||||
my_slpd_port = xstrdup(DEFAULT_SLPD_PORT);
|
||||
|
|
|
@ -24,8 +24,13 @@
|
|||
#include "utils.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
extern int slpdinterval;
|
||||
extern timeout_t slpdupdate_timeout;
|
||||
|
||||
void periodic_slpd_handler(void);
|
||||
void slpdupdate_handler(void *);
|
||||
void setup_slpd(void);
|
||||
int setup_slpd_in_socket(void);
|
||||
void handle_incoming_slpd_packet(listen_socket_t *, void *, struct sockaddr_in6 *, size_t);
|
||||
void handle_incoming_slpd_data(void *, int);
|
||||
void send_slpd_broadcast(node_t *, char *);
|
||||
|
|
Loading…
Reference in a new issue