j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:

> j...@wxcvbn.org (Jeremie Courreges-Anglas) writes:
>
>> Alexander Bluhm <alexander.bl...@gmx.net> writes:
>>
>>> On Tue, Feb 09, 2016 at 02:17:18AM +0100, J??r??mie Courr??ges-Anglas wrote:
>>>> 
>>>> - a few *cnt members of struct rainfo aren't used for anything
>>>> - the SIOCGIFPREFIX_IN6 ioctl has been deprecated since June 2002
>>>> - prefix_match() and in6a_site_allrouters are remnants from the
>>>>   Renumbering code (now in the Attic)
>>>> 
>>>> ok?
>>>
>>> OK bluhm@
>>>
>>> I think you should also kill the function init_prefix() and move
>>> the remaining 4 lines into make_prefix() in another diff.
>>
>> duh, thanks.  Here's the diff:

Committed,

> The next diff will merge make_prefix/add_prefix and kill the use of
> "struct in6_prefixreq"... in rtadvd.

Index: config.c
===================================================================
RCS file: /cvs/src/usr.sbin/rtadvd/config.c,v
retrieving revision 1.53
diff -u -p -r1.53 config.c
--- config.c    29 Feb 2016 06:37:55 -0000      1.53
+++ config.c    29 Feb 2016 06:40:21 -0000
@@ -618,8 +618,8 @@ makeentry(char *buf, size_t len, int id,
  * XXX: other parameters of the prefix (e.g. lifetime) ought
  * to be specified.
  */
-static void
-add_prefix(struct rainfo *rai, struct in6_prefixreq *ipr)
+void
+make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
 {
        struct prefix *prefix;
        u_char ntopbuf[INET6_ADDRSTRLEN];
@@ -628,20 +628,20 @@ add_prefix(struct rainfo *rai, struct in
                log_warn("calloc");
                return;         /* XXX: error or exit? */
        }
-       prefix->prefix = ipr->ipr_prefix.sin6_addr;
-       prefix->prefixlen = ipr->ipr_plen;
-       prefix->validlifetime = ipr->ipr_vltime;
-       prefix->preflifetime = ipr->ipr_pltime;
-       prefix->onlinkflg = ipr->ipr_raf_onlink;
-       prefix->autoconfflg = ipr->ipr_raf_auto;
+       prefix->prefix = *addr;
+       prefix->prefixlen = plen;
+       prefix->validlifetime = DEF_ADVVALIDLIFETIME;
+       prefix->preflifetime = DEF_ADVPREFERREDLIFETIME;
+       prefix->onlinkflg = 1;
+       prefix->autoconfflg = 1;
        prefix->origin = PREFIX_FROM_DYNAMIC;
 
        TAILQ_INSERT_TAIL(&rai->prefixes, prefix, entry);
 
        log_debug("new prefix %s/%d was added on %s",
-           inet_ntop(AF_INET6, &ipr->ipr_prefix.sin6_addr,
+           inet_ntop(AF_INET6, &prefix->prefix,
               ntopbuf, INET6_ADDRSTRLEN),
-           ipr->ipr_plen, rai->ifname);
+           prefix->prefixlen, rai->ifname);
 
        /* free the previous packet */
        free(rai->ra_data);
@@ -676,29 +676,6 @@ delete_prefix(struct rainfo *rai, struct
        free(prefix);
        rai->pfxs--;
        make_packet(rai);
-}
-
-void
-make_prefix(struct rainfo *rai, int ifindex, struct in6_addr *addr, int plen)
-{
-       struct in6_prefixreq ipr;
-
-       memset(&ipr, 0, sizeof(ipr));
-       if (if_indextoname(ifindex, ipr.ipr_name) == NULL) {
-               log_warn("Prefix added interface No.%d doesn't"
-                   " exist. This should not happen!", ifindex);
-               exit(1);
-       }
-       ipr.ipr_prefix.sin6_len = sizeof(ipr.ipr_prefix);
-       ipr.ipr_prefix.sin6_family = AF_INET6;
-       ipr.ipr_prefix.sin6_addr = *addr;
-       ipr.ipr_plen = plen;
-       ipr.ipr_vltime = DEF_ADVVALIDLIFETIME;
-       ipr.ipr_pltime = DEF_ADVPREFERREDLIFETIME;
-       ipr.ipr_raf_onlink = 1;
-       ipr.ipr_raf_auto = 1;
-
-       add_prefix(rai, &ipr);
 }
 
 void


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to