RAdv: Style updates

Adapt the naming conventions to be a bit closer to the other protocols.

proto_radv -> radv_proto
struct radv_proto *ra -> struct radv_proto *p
struct proto *p -> struct proto *P
This commit is contained in:
Michal 'vorner' Vaner 2017-08-08 14:40:51 +02:00 committed by Ondrej Zajicek (work)
parent afd9845e26
commit 5a41eed26d
3 changed files with 78 additions and 78 deletions

View file

@ -82,8 +82,8 @@ static struct radv_prefix_config default_prefix = {
static struct radv_prefix_config * static struct radv_prefix_config *
radv_prefix_match(struct radv_iface *ifa, struct ifa *a) radv_prefix_match(struct radv_iface *ifa, struct ifa *a)
{ {
struct proto *p = &ifa->ra->p; struct radv_proto *p = ifa->ra;
struct radv_config *cf = (struct radv_config *) (p->cf); struct radv_config *cf = (struct radv_config *) (p->p.cf);
struct radv_prefix_config *pc; struct radv_prefix_config *pc;
if (a->scope <= SCOPE_LINK) if (a->scope <= SCOPE_LINK)
@ -206,7 +206,7 @@ radv_prepare_dnssl(struct radv_iface *ifa, list *dnssl_list, char **buf, char *b
else else
op->lifetime = htonl(dcf->lifetime); op->lifetime = htonl(dcf->lifetime);
while(NODE_VALID(dcf) && while(NODE_VALID(dcf) &&
(dcf->lifetime == dcf_base->lifetime) && (dcf->lifetime == dcf_base->lifetime) &&
(dcf->lifetime_mult == dcf_base->lifetime_mult)) (dcf->lifetime_mult == dcf_base->lifetime_mult))
{ {
@ -237,8 +237,8 @@ radv_prepare_dnssl(struct radv_iface *ifa, list *dnssl_list, char **buf, char *b
static void static void
radv_prepare_ra(struct radv_iface *ifa) radv_prepare_ra(struct radv_iface *ifa)
{ {
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
struct radv_config *cf = (struct radv_config *) (ra->p.cf); struct radv_config *cf = (struct radv_config *) (p->p.cf);
struct radv_iface_config *ic = ifa->cf; struct radv_iface_config *ic = ifa->cf;
char *buf = ifa->sk->tbuf; char *buf = ifa->sk->tbuf;
@ -250,7 +250,7 @@ radv_prepare_ra(struct radv_iface *ifa)
pkt->code = 0; pkt->code = 0;
pkt->checksum = 0; pkt->checksum = 0;
pkt->current_hop_limit = ic->current_hop_limit; pkt->current_hop_limit = ic->current_hop_limit;
pkt->router_lifetime = (ra->active || !ic->default_lifetime_sensitive) ? pkt->router_lifetime = (p->active || !ic->default_lifetime_sensitive) ?
htons(ic->default_lifetime) : 0; htons(ic->default_lifetime) : 0;
pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) | pkt->flags = (ic->managed ? OPT_RA_MANAGED : 0) |
(ic->other_config ? OPT_RA_OTHER_CFG : 0) | (ic->other_config ? OPT_RA_OTHER_CFG : 0) |
@ -283,7 +283,7 @@ radv_prepare_ra(struct radv_iface *ifa)
if (buf + sizeof(struct radv_opt_prefix) > bufend) if (buf + sizeof(struct radv_opt_prefix) > bufend)
{ {
log(L_WARN "%s: Too many prefixes on interface %s", ra->p.name, ifa->iface->name); log(L_WARN "%s: Too many prefixes on interface %s", p->p.name, ifa->iface->name);
goto done; goto done;
} }
@ -293,9 +293,9 @@ radv_prepare_ra(struct radv_iface *ifa)
op->pxlen = net6_pxlen(&addr->prefix); op->pxlen = net6_pxlen(&addr->prefix);
op->flags = (pc->onlink ? OPT_PX_ONLINK : 0) | op->flags = (pc->onlink ? OPT_PX_ONLINK : 0) |
(pc->autonomous ? OPT_PX_AUTONOMOUS : 0); (pc->autonomous ? OPT_PX_AUTONOMOUS : 0);
op->valid_lifetime = (ra->active || !pc->valid_lifetime_sensitive) ? op->valid_lifetime = (p->active || !pc->valid_lifetime_sensitive) ?
htonl(pc->valid_lifetime) : 0; htonl(pc->valid_lifetime) : 0;
op->preferred_lifetime = (ra->active || !pc->preferred_lifetime_sensitive) ? op->preferred_lifetime = (p->active || !pc->preferred_lifetime_sensitive) ?
htonl(pc->preferred_lifetime) : 0; htonl(pc->preferred_lifetime) : 0;
op->reserved = 0; op->reserved = 0;
op->prefix = ip6_hton(net6_prefix(&addr->prefix)); op->prefix = ip6_hton(net6_prefix(&addr->prefix));
@ -324,7 +324,7 @@ radv_prepare_ra(struct radv_iface *ifa)
void void
radv_send_ra(struct radv_iface *ifa, int shutdown) radv_send_ra(struct radv_iface *ifa, int shutdown)
{ {
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
/* We store prepared RA in tbuf */ /* We store prepared RA in tbuf */
if (!ifa->plen) if (!ifa->plen)
@ -352,7 +352,7 @@ static int
radv_rx_hook(sock *sk, uint size) radv_rx_hook(sock *sk, uint size)
{ {
struct radv_iface *ifa = sk->data; struct radv_iface *ifa = sk->data;
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
/* We want just packets from sk->iface */ /* We want just packets from sk->iface */
if (sk->lifindex != sk->iface->index) if (sk->lifindex != sk->iface->index)

View file

@ -47,7 +47,7 @@ static void
radv_timer(timer *tm) radv_timer(timer *tm)
{ {
struct radv_iface *ifa = tm->data; struct radv_iface *ifa = tm->data;
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
RADV_TRACE(D_EVENTS, "Timer fired on %s", ifa->iface->name); RADV_TRACE(D_EVENTS, "Timer fired on %s", ifa->iface->name);
@ -72,7 +72,7 @@ static char* ev_name[] = { NULL, "Init", "Change", "RS" };
void void
radv_iface_notify(struct radv_iface *ifa, int event) radv_iface_notify(struct radv_iface *ifa, int event)
{ {
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
if (!ifa->sk) if (!ifa->sk)
return; return;
@ -102,21 +102,21 @@ radv_iface_notify(struct radv_iface *ifa, int event)
} }
static void static void
radv_iface_notify_all(struct proto_radv *ra, int event) radv_iface_notify_all(struct radv_proto *p, int event)
{ {
struct radv_iface *ifa; struct radv_iface *ifa;
WALK_LIST(ifa, ra->iface_list) WALK_LIST(ifa, p->iface_list)
radv_iface_notify(ifa, event); radv_iface_notify(ifa, event);
} }
static struct radv_iface * static struct radv_iface *
radv_iface_find(struct proto_radv *ra, struct iface *what) radv_iface_find(struct radv_proto *p, struct iface *what)
{ {
struct radv_iface *ifa; struct radv_iface *ifa;
WALK_LIST(ifa, ra->iface_list) WALK_LIST(ifa, p->iface_list)
if (ifa->iface == what) if (ifa->iface == what)
return ifa; return ifa;
@ -127,11 +127,11 @@ static void
radv_iface_add(struct object_lock *lock) radv_iface_add(struct object_lock *lock)
{ {
struct radv_iface *ifa = lock->data; struct radv_iface *ifa = lock->data;
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
if (! radv_sk_open(ifa)) if (! radv_sk_open(ifa))
{ {
log(L_ERR "%s: Socket open failed on interface %s", ra->p.name, ifa->iface->name); log(L_ERR "%s: Socket open failed on interface %s", p->p.name, ifa->iface->name);
return; return;
} }
@ -150,24 +150,24 @@ find_lladdr(struct iface *iface)
} }
static void static void
radv_iface_new(struct proto_radv *ra, struct iface *iface, struct radv_iface_config *cf) radv_iface_new(struct radv_proto *p, struct iface *iface, struct radv_iface_config *cf)
{ {
pool *pool = ra->p.pool; pool *pool = p->p.pool;
struct radv_iface *ifa; struct radv_iface *ifa;
RADV_TRACE(D_EVENTS, "Adding interface %s", iface->name); RADV_TRACE(D_EVENTS, "Adding interface %s", iface->name);
ifa = mb_allocz(pool, sizeof(struct radv_iface)); ifa = mb_allocz(pool, sizeof(struct radv_iface));
ifa->ra = ra; ifa->ra = p;
ifa->cf = cf; ifa->cf = cf;
ifa->iface = iface; ifa->iface = iface;
add_tail(&ra->iface_list, NODE ifa); add_tail(&p->iface_list, NODE ifa);
ifa->addr = find_lladdr(iface); ifa->addr = find_lladdr(iface);
if (!ifa->addr) if (!ifa->addr)
{ {
log(L_ERR "%s: Cannot find link-locad addr on interface %s", ra->p.name, iface->name); log(L_ERR "%s: Cannot find link-locad addr on interface %s", p->p.name, iface->name);
return; return;
} }
@ -193,7 +193,7 @@ radv_iface_new(struct proto_radv *ra, struct iface *iface, struct radv_iface_con
static void static void
radv_iface_remove(struct radv_iface *ifa) radv_iface_remove(struct radv_iface *ifa)
{ {
struct proto_radv *ra = ifa->ra; struct radv_proto *p = ifa->ra;
RADV_TRACE(D_EVENTS, "Removing interface %s", ifa->iface->name); RADV_TRACE(D_EVENTS, "Removing interface %s", ifa->iface->name);
rem_node(NODE ifa); rem_node(NODE ifa);
@ -206,10 +206,10 @@ radv_iface_remove(struct radv_iface *ifa)
} }
static void static void
radv_if_notify(struct proto *p, unsigned flags, struct iface *iface) radv_if_notify(struct proto *P, unsigned flags, struct iface *iface)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
struct radv_config *cf = (struct radv_config *) (p->cf); struct radv_config *cf = (struct radv_config *) (P->cf);
if (iface->flags & IF_IGNORE) if (iface->flags & IF_IGNORE)
return; return;
@ -220,12 +220,12 @@ radv_if_notify(struct proto *p, unsigned flags, struct iface *iface)
iface_patt_find(&cf->patt_list, iface, NULL); iface_patt_find(&cf->patt_list, iface, NULL);
if (ic) if (ic)
radv_iface_new(ra, iface, ic); radv_iface_new(p, iface, ic);
return; return;
} }
struct radv_iface *ifa = radv_iface_find(ra, iface); struct radv_iface *ifa = radv_iface_find(p, iface);
if (!ifa) if (!ifa)
return; return;
@ -240,9 +240,9 @@ radv_if_notify(struct proto *p, unsigned flags, struct iface *iface)
} }
static void static void
radv_ifa_notify(struct proto *p, unsigned flags UNUSED, struct ifa *a) radv_ifa_notify(struct proto *P, unsigned flags UNUSED, struct ifa *a)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
if (a->flags & IA_SECONDARY) if (a->flags & IA_SECONDARY)
return; return;
@ -250,7 +250,7 @@ radv_ifa_notify(struct proto *p, unsigned flags UNUSED, struct ifa *a)
if (a->scope <= SCOPE_LINK) if (a->scope <= SCOPE_LINK)
return; return;
struct radv_iface *ifa = radv_iface_find(ra, a->iface); struct radv_iface *ifa = radv_iface_find(p, a->iface);
if (ifa) if (ifa)
radv_iface_notify(ifa, RA_EV_CHANGE); radv_iface_notify(ifa, RA_EV_CHANGE);
@ -269,10 +269,10 @@ radv_net_match_trigger(struct radv_config *cf, net *n)
} }
int int
radv_import_control(struct proto *p, rte **new, ea_list **attrs UNUSED, struct linpool *pool UNUSED) radv_import_control(struct proto *P, rte **new, ea_list **attrs UNUSED, struct linpool *pool UNUSED)
{ {
// struct proto_radv *ra = (struct proto_radv *) p; // struct radv_proto *p = (struct radv_proto *) P;
struct radv_config *cf = (struct radv_config *) (p->cf); struct radv_config *cf = (struct radv_config *) (P->cf);
if (radv_net_match_trigger(cf, (*new)->net)) if (radv_net_match_trigger(cf, (*new)->net))
return RIC_PROCESS; return RIC_PROCESS;
@ -281,38 +281,38 @@ radv_import_control(struct proto *p, rte **new, ea_list **attrs UNUSED, struct l
} }
static void static void
radv_rt_notify(struct proto *p, struct channel *ch UNUSED, net *n, rte *new, rte *old UNUSED, ea_list *attrs UNUSED) radv_rt_notify(struct proto *P, struct channel *ch UNUSED, net *n, rte *new, rte *old UNUSED, ea_list *attrs UNUSED)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
struct radv_config *cf = (struct radv_config *) (p->cf); struct radv_config *cf = (struct radv_config *) (P->cf);
if (radv_net_match_trigger(cf, n)) if (radv_net_match_trigger(cf, n))
{ {
u8 old_active = ra->active; u8 old_active = p->active;
ra->active = !!new; p->active = !!new;
if (ra->active == old_active) if (p->active == old_active)
return; return;
if (ra->active) if (p->active)
RADV_TRACE(D_EVENTS, "Triggered"); RADV_TRACE(D_EVENTS, "Triggered");
else else
RADV_TRACE(D_EVENTS, "Suppressed"); RADV_TRACE(D_EVENTS, "Suppressed");
radv_iface_notify_all(ra, RA_EV_CHANGE); radv_iface_notify_all(p, RA_EV_CHANGE);
} }
} }
static int static int
radv_check_active(struct proto_radv *ra) radv_check_active(struct radv_proto *p)
{ {
struct radv_config *cf = (struct radv_config *) (ra->p.cf); struct radv_config *cf = (struct radv_config *) (p->p.cf);
if (!radv_trigger_valid(cf)) if (!radv_trigger_valid(cf))
return 1; return 1;
struct channel *c = ra->p.main_channel; struct channel *c = p->p.main_channel;
return rt_examine(c->table, &cf->trigger, &ra->p, c->out_filter); return rt_examine(c->table, &cf->trigger, &p->p, c->out_filter);
} }
static void static void
@ -328,26 +328,26 @@ radv_postconfig(struct proto_config *CF)
static struct proto * static struct proto *
radv_init(struct proto_config *CF) radv_init(struct proto_config *CF)
{ {
struct proto *p = proto_new(CF); struct proto *P = proto_new(CF);
p->main_channel = proto_add_channel(p, proto_cf_main_channel(CF)); P->main_channel = proto_add_channel(P, proto_cf_main_channel(CF));
p->import_control = radv_import_control; P->import_control = radv_import_control;
p->rt_notify = radv_rt_notify; P->rt_notify = radv_rt_notify;
p->if_notify = radv_if_notify; P->if_notify = radv_if_notify;
p->ifa_notify = radv_ifa_notify; P->ifa_notify = radv_ifa_notify;
return p; return P;
} }
static int static int
radv_start(struct proto *p) radv_start(struct proto *P)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
struct radv_config *cf = (struct radv_config *) (p->cf); struct radv_config *cf = (struct radv_config *) (P->cf);
init_list(&(ra->iface_list)); init_list(&(p->iface_list));
ra->active = !radv_trigger_valid(cf); p->active = !radv_trigger_valid(cf);
return PS_UP; return PS_UP;
} }
@ -360,21 +360,21 @@ radv_iface_shutdown(struct radv_iface *ifa)
} }
static int static int
radv_shutdown(struct proto *p) radv_shutdown(struct proto *P)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
struct radv_iface *ifa; struct radv_iface *ifa;
WALK_LIST(ifa, ra->iface_list) WALK_LIST(ifa, p->iface_list)
radv_iface_shutdown(ifa); radv_iface_shutdown(ifa);
return PS_DOWN; return PS_DOWN;
} }
static int static int
radv_reconfigure(struct proto *p, struct proto_config *CF) radv_reconfigure(struct proto *P, struct proto_config *CF)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
// struct radv_config *old = (struct radv_config *) (p->cf); // struct radv_config *old = (struct radv_config *) (p->cf);
struct radv_config *new = (struct radv_config *) CF; struct radv_config *new = (struct radv_config *) CF;
@ -386,16 +386,16 @@ radv_reconfigure(struct proto *p, struct proto_config *CF)
* causing nodes to temporary remove their default routes. * causing nodes to temporary remove their default routes.
*/ */
if (!proto_configure_channel(p, &p->main_channel, proto_cf_main_channel(CF))) if (!proto_configure_channel(P, &P->main_channel, proto_cf_main_channel(CF)))
return 0; return 0;
p->cf = CF; /* radv_check_active() requires proper p->cf */ P->cf = CF; /* radv_check_active() requires proper p->cf */
ra->active = radv_check_active(ra); p->active = radv_check_active(p);
struct iface *iface; struct iface *iface;
WALK_LIST(iface, iface_list) WALK_LIST(iface, iface_list)
{ {
struct radv_iface *ifa = radv_iface_find(ra, iface); struct radv_iface *ifa = radv_iface_find(p, iface);
struct radv_iface_config *ic = (struct radv_iface_config *) struct radv_iface_config *ic = (struct radv_iface_config *)
iface_patt_find(&new->patt_list, iface, NULL); iface_patt_find(&new->patt_list, iface, NULL);
@ -415,7 +415,7 @@ radv_reconfigure(struct proto *p, struct proto_config *CF)
} }
if (!ifa && ic) if (!ifa && ic)
radv_iface_new(ra, iface, ic); radv_iface_new(p, iface, ic);
} }
return 1; return 1;
@ -435,11 +435,11 @@ radv_copy_config(struct proto_config *dest, struct proto_config *src)
} }
static void static void
radv_get_status(struct proto *p, byte *buf) radv_get_status(struct proto *P, byte *buf)
{ {
struct proto_radv *ra = (struct proto_radv *) p; struct radv_proto *p = (struct radv_proto *) P;
if (!ra->active) if (!p->active)
strcpy(buf, "Suppressed"); strcpy(buf, "Suppressed");
} }
@ -447,7 +447,7 @@ struct protocol proto_radv = {
.name = "RAdv", .name = "RAdv",
.template = "radv%d", .template = "radv%d",
.channel_mask = NB_IP6, .channel_mask = NB_IP6,
.proto_size = sizeof(struct proto_radv), .proto_size = sizeof(struct radv_proto),
.config_size = sizeof(struct radv_config), .config_size = sizeof(struct radv_config),
.postconfig = radv_postconfig, .postconfig = radv_postconfig,
.init = radv_init, .init = radv_init,

View file

@ -111,7 +111,7 @@ struct radv_dnssl_config
}; };
struct proto_radv struct radv_proto
{ {
struct proto p; struct proto p;
list iface_list; /* List of active ifaces */ list iface_list; /* List of active ifaces */
@ -121,7 +121,7 @@ struct proto_radv
struct radv_iface struct radv_iface
{ {
node n; node n;
struct proto_radv *ra; struct radv_proto *ra;
struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */ struct radv_iface_config *cf; /* Related config, must be updated in reconfigure */
struct iface *iface; struct iface *iface;
struct ifa *addr; /* Link-local address of iface */ struct ifa *addr; /* Link-local address of iface */
@ -151,8 +151,8 @@ struct radv_iface
#else #else
#define RADV_FORCE_DEBUG 0 #define RADV_FORCE_DEBUG 0
#endif #endif
#define RADV_TRACE(flags, msg, args...) do { if ((ra->p.debug & flags) || RADV_FORCE_DEBUG) \ #define RADV_TRACE(flags, msg, args...) do { if ((p->p.debug & flags) || RADV_FORCE_DEBUG) \
log(L_TRACE "%s: " msg, ra->p.name , ## args ); } while(0) log(L_TRACE "%s: " msg, p->p.name , ## args ); } while(0)
/* radv.c */ /* radv.c */