summaryrefslogtreecommitdiff
path: root/proto/radv/radv.c
diff options
context:
space:
mode:
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>2017-08-08 14:40:51 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-08-09 12:38:20 +0200
commit1f182675c816e4708312f99dd817fb894f3a90b3 (patch)
tree5d3531588ace8e3601fad6838fb589c5a91012d5 /proto/radv/radv.c
parent637ed49868c56c0e05467f0e0ddb6aa1231deaa4 (diff)
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
Diffstat (limited to 'proto/radv/radv.c')
-rw-r--r--proto/radv/radv.c125
1 files changed, 63 insertions, 62 deletions
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index 5c52217d..4ea1f5c2 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -47,7 +47,7 @@ static void
radv_timer(timer *tm)
{
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);
@@ -72,7 +72,7 @@ static char* ev_name[] = { NULL, "Init", "Change", "RS" };
void
radv_iface_notify(struct radv_iface *ifa, int event)
{
- struct proto_radv *ra = ifa->ra;
+ struct radv_proto *p = ifa->ra;
if (!ifa->sk)
return;
@@ -102,21 +102,21 @@ radv_iface_notify(struct radv_iface *ifa, int event)
}
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;
- WALK_LIST(ifa, ra->iface_list)
+ WALK_LIST(ifa, p->iface_list)
radv_iface_notify(ifa, event);
}
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;
- WALK_LIST(ifa, ra->iface_list)
+ WALK_LIST(ifa, p->iface_list)
if (ifa->iface == what)
return ifa;
@@ -127,11 +127,11 @@ static void
radv_iface_add(struct object_lock *lock)
{
struct radv_iface *ifa = lock->data;
- struct proto_radv *ra = ifa->ra;
+ struct radv_proto *p = ifa->ra;
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;
}
@@ -150,24 +150,24 @@ find_lladdr(struct iface *iface)
}
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;
RADV_TRACE(D_EVENTS, "Adding interface %s", iface->name);
ifa = mb_allocz(pool, sizeof(struct radv_iface));
- ifa->ra = ra;
+ ifa->ra = p;
ifa->cf = cf;
ifa->iface = iface;
- add_tail(&ra->iface_list, NODE ifa);
+ add_tail(&p->iface_list, NODE ifa);
ifa->addr = find_lladdr(iface);
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;
}
@@ -193,7 +193,7 @@ radv_iface_new(struct proto_radv *ra, struct iface *iface, struct radv_iface_con
static void
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);
rem_node(NODE ifa);
@@ -206,10 +206,10 @@ radv_iface_remove(struct radv_iface *ifa)
}
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_config *cf = (struct radv_config *) (p->cf);
+ struct radv_proto *p = (struct radv_proto *) P;
+ struct radv_config *cf = (struct radv_config *) (P->cf);
if (iface->flags & IF_IGNORE)
return;
@@ -220,12 +220,12 @@ radv_if_notify(struct proto *p, unsigned flags, struct iface *iface)
iface_patt_find(&cf->patt_list, iface, NULL);
if (ic)
- radv_iface_new(ra, iface, ic);
+ radv_iface_new(p, iface, ic);
return;
}
- struct radv_iface *ifa = radv_iface_find(ra, iface);
+ struct radv_iface *ifa = radv_iface_find(p, iface);
if (!ifa)
return;
@@ -240,9 +240,9 @@ radv_if_notify(struct proto *p, unsigned flags, struct iface *iface)
}
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)
return;
@@ -250,7 +250,7 @@ radv_ifa_notify(struct proto *p, unsigned flags UNUSED, struct ifa *a)
if (a->scope <= SCOPE_LINK)
return;
- struct radv_iface *ifa = radv_iface_find(ra, a->iface);
+ struct radv_iface *ifa = radv_iface_find(p, a->iface);
if (ifa)
radv_iface_notify(ifa, RA_EV_CHANGE);
@@ -264,10 +264,10 @@ static inline int radv_net_match_trigger(struct radv_config *cf, net *n)
}
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_config *cf = (struct radv_config *) (p->cf);
+ // struct radv_proto *p = (struct radv_proto *) P;
+ struct radv_config *cf = (struct radv_config *) (P->cf);
if (radv_net_match_trigger(cf, (*new)->net))
return RIC_PROCESS;
@@ -276,61 +276,62 @@ radv_import_control(struct proto *p, rte **new, ea_list **attrs UNUSED, struct l
}
static void
-radv_rt_notify(struct proto *p, rtable *tbl UNUSED, net *n, rte *new, rte *old UNUSED, ea_list *attrs UNUSED)
+radv_rt_notify(struct proto *P, rtable *tbl UNUSED, net *n, rte *new, rte *old UNUSED, ea_list *attrs UNUSED)
{
- struct proto_radv *ra = (struct proto_radv *) p;
- struct radv_config *cf = (struct radv_config *) (p->cf);
+ struct radv_proto *p = (struct radv_proto *) P;
+ struct radv_config *cf = (struct radv_config *) (P->cf);
if (radv_net_match_trigger(cf, n))
{
- u8 old_active = ra->active;
- ra->active = !!new;
+ u8 old_active = p->active;
+ p->active = !!new;
- if (ra->active == old_active)
+ if (p->active == old_active)
return;
- if (ra->active)
+ if (p->active)
RADV_TRACE(D_EVENTS, "Triggered");
else
RADV_TRACE(D_EVENTS, "Suppressed");
- radv_iface_notify_all(ra, RA_EV_CHANGE);
+ radv_iface_notify_all(p, RA_EV_CHANGE);
}
}
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 (! cf->trigger_valid)
return 1;
- return rt_examine(ra->p.table, cf->trigger_prefix, cf->trigger_pxlen,
- &(ra->p), ra->p.cf->out_filter);
+ return rt_examine(p->p.table, cf->trigger_prefix, cf->trigger_pxlen,
+ &(p->p), p->p.cf->out_filter);
}
static struct proto *
radv_init(struct proto_config *c)
{
- struct proto *p = proto_new(c, sizeof(struct proto_radv));
-
- p->accept_ra_types = RA_OPTIMAL;
- p->import_control = radv_import_control;
- p->rt_notify = radv_rt_notify;
- p->if_notify = radv_if_notify;
- p->ifa_notify = radv_ifa_notify;
- return p;
+ struct proto *P = proto_new(c, sizeof(struct radv_proto));
+
+ P->accept_ra_types = RA_OPTIMAL;
+ P->import_control = radv_import_control;
+ P->rt_notify = radv_rt_notify;
+ P->if_notify = radv_if_notify;
+ P->ifa_notify = radv_ifa_notify;
+
+ return P;
}
static int
-radv_start(struct proto *p)
+radv_start(struct proto *P)
{
- struct proto_radv *ra = (struct proto_radv *) p;
- struct radv_config *cf = (struct radv_config *) (p->cf);
+ struct radv_proto *p = (struct radv_proto *) P;
+ struct radv_config *cf = (struct radv_config *) (P->cf);
- init_list(&(ra->iface_list));
- ra->active = !cf->trigger_valid;
+ init_list(&(p->iface_list));
+ p->active = !cf->trigger_valid;
return PS_UP;
}
@@ -343,21 +344,21 @@ radv_iface_shutdown(struct radv_iface *ifa)
}
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;
- WALK_LIST(ifa, ra->iface_list)
+ WALK_LIST(ifa, p->iface_list)
radv_iface_shutdown(ifa);
return PS_DOWN;
}
static int
-radv_reconfigure(struct proto *p, struct proto_config *c)
+radv_reconfigure(struct proto *P, struct proto_config *c)
{
- 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 *new = (struct radv_config *) c;
@@ -369,13 +370,13 @@ radv_reconfigure(struct proto *p, struct proto_config *c)
* causing nodes to temporary remove their default routes.
*/
- p->cf = c; /* radv_check_active() requires proper p->cf */
- ra->active = radv_check_active(ra);
+ P->cf = c; /* radv_check_active() requires proper P->cf */
+ p->active = radv_check_active(p);
struct iface *iface;
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 *)
iface_patt_find(&new->patt_list, iface, NULL);
@@ -395,7 +396,7 @@ radv_reconfigure(struct proto *p, struct proto_config *c)
}
if (!ifa && ic)
- radv_iface_new(ra, iface, ic);
+ radv_iface_new(p, iface, ic);
}
return 1;
@@ -415,11 +416,11 @@ radv_copy_config(struct proto_config *dest, struct proto_config *src)
}
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");
}