X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=site.c;h=a0715000285f5f65e4dd7a617726f2dcfe79922b;hb=9eba4abfe44617aa78f625d900fe6bc2c58bb4cb;hp=08875133c1cc5fd0ca95677412f88df35c7308ab;hpb=983e0900816ece898f3d53a530fe0f2c73932bbc;p=secnet.git diff --git a/site.c b/site.c index 0887513..a071500 100644 --- a/site.c +++ b/site.c @@ -257,6 +257,7 @@ typedef struct { } transport_peers; /* Basic operations on transport peer address sets */ +static void transport_peers_init(struct site *st, transport_peers *peers); static void transport_peers_clear(struct site *st, transport_peers *peers); static int transport_peers_valid(transport_peers *peers); static void transport_peers_copy(struct site *st, transport_peers *dst, @@ -787,8 +788,7 @@ static bool_t unpick_msg(struct site *st, uint32_t type, if (type_is_msg23(type) && m->remote.extrainfo.size) { m->n_pubkeys_accepted_nom = buf_unprepend_uint8(&m->remote.extrainfo); if (!m->n_pubkeys_accepted_nom) return False; - int ki_nom; - for (ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { + for (int ki_nom=0; ki_nomn_pubkeys_accepted_nom; ki_nom++) { CHECK_AVAIL(&m->remote.extrainfo,KEYIDSZ); struct sigkeyid *kid = buf_unprepend(&m->remote.extrainfo,KEYIDSZ); if (ki_nompubkeys_accepted[ki_nom] = kid; @@ -2283,11 +2283,10 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf, return False; } -static void site_control(void *vst, bool_t run) +static void site_startup(void *vst) { struct site *st=vst; - if (run) enter_state_run(st); - else enter_state_stop(st); + enter_state_run(st); } static void site_phase_hook(void *sst, uint32_t newphase) @@ -2331,7 +2330,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, st->cl.apply=NULL; st->cl.interface=&st->ops; st->ops.st=st; - st->ops.control=site_control; + st->ops.startup=site_startup; st->ops.status=site_status; st->peerkeys_path=0; st->peerkeys_tmpl.buffer=0; @@ -2513,8 +2512,8 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context, st->chosen_transform=0; st->current.key_timeout=0; st->auxiliary_key.key_timeout=0; - transport_peers_clear(st,&st->peers); - transport_peers_clear(st,&st->setup_peers); + transport_peers_init(st,&st->peers); + transport_peers_init(st,&st->setup_peers); /* XXX mlock these */ st->dhsecret=safe_malloc(st->dh->len,"site:dhsecret"); st->sharedsecretlen=st->sharedsecretallocd=0; @@ -2730,9 +2729,14 @@ static void transport_data_msgok(struct site *st, const struct comm_addr *a) { static int transport_peers_valid(transport_peers *peers) { return peers->npeers; } +static void transport_peers_init(struct site *st, transport_peers *peers) { + peers->npeers= 0; +} static void transport_peers_clear(struct site *st, transport_peers *peers) { + bool_t need_debug=!!peers->npeers; peers->npeers= 0; - transport_peers_debug(st,peers,"clear",0,0,0); + if (need_debug) + transport_peers_debug(st,peers,"clear",0,0,0); } static void transport_peers_copy(struct site *st, transport_peers *dst, const transport_peers *src) {