From 57721604f26eefbe3dfb628affec8ca167a9f4b8 Mon Sep 17 00:00:00 2001 From: Bjørn Mork Date: Fri, 6 Aug 2010 15:33:05 +0200 Subject: Adding ifid option to the dhcp6c.conf prefix-interface statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds the ability to override the default EUI-64 address selection. Useful for interfaces without a unique hardware address, or for creating more userfriendly addresses in general. Signed-off-by: Bjørn Mork --- cfparse.y | 10 +++++++++- cftoken.l | 1 + config.c | 5 +++++ config.h | 2 +- dhcp6c.conf.5 | 10 ++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/cfparse.y b/cfparse.y index c79d131..e83ecf7 100644 --- a/cfparse.y +++ b/cfparse.y @@ -104,7 +104,7 @@ static void cleanup_cflist __P((struct cf_list *)); %token INTERFACE IFNAME %token PROFILE PROFILENAME -%token PREFIX_INTERFACE SLA_ID SLA_LEN DUID_ID +%token PREFIX_INTERFACE SLA_ID SLA_LEN IFID DUID_ID %token ID_ASSOC IA_PD IAID IA_NA %token ADDRESS %token REQUEST SEND ALLOW PREFERENCE @@ -1056,6 +1056,14 @@ ifparam: l->num = $2; $$ = l; } + | IFID NUMBER EOS + { + struct cf_list *l; + + MAKE_CFLIST(l, IFPARAM_IFID, NULL, NULL); + l->num = (u_int64_t)$2; + $$ = l; + } ; ianaconf_list: diff --git a/cftoken.l b/cftoken.l index 4c9ed10..6afda5f 100644 --- a/cftoken.l +++ b/cftoken.l @@ -240,6 +240,7 @@ ecl \} prefix-interface { DECHO; BEGIN S_IFACE; return (PREFIX_INTERFACE); } sla-id { DECHO; return (SLA_ID); } sla-len { DECHO; return (SLA_LEN); } +ifid { DECHO; return (IFID); } /* duration */ infinity { DECHO; return (INFINITY); } diff --git a/config.c b/config.c index 23598fc..bb16c21 100644 --- a/config.c +++ b/config.c @@ -471,6 +471,7 @@ add_pd_pif(iapdc, cfl0) { struct cf_list *cfl; struct prefix_ifconf *pif; + int i; /* duplication check */ for (pif = TAILQ_FIRST(&iapdc->iapd_pif_list); pif; @@ -524,6 +525,10 @@ add_pd_pif(iapdc, cfl0) goto bad; } break; + case IFPARAM_IFID: + for (i = sizeof(pif->ifid) -1; i >= 0; i--) + pif->ifid[i] = (cfl->num >> 8*(sizeof(pif->ifid) - 1 - i)) & 0xff; + break; default: debug_printf(LOG_ERR, FNAME, "%s:%d internal error: " "invalid configuration", diff --git a/config.h b/config.h index ea8d17c..64ce9e8 100644 --- a/config.h +++ b/config.h @@ -266,7 +266,7 @@ enum { DECL_SEND, DECL_ALLOW, DECL_INFO_ONLY, DECL_REQUEST, DECL_DUID, DECL_PREFIX, DECL_PREFERENCE, DECL_SCRIPT, DECL_DELAYEDKEY, DECL_ADDRESS, DECL_RANGE, DECL_ADDRESSPOOL, - IFPARAM_SLA_ID, IFPARAM_SLA_LEN, + IFPARAM_SLA_ID, IFPARAM_SLA_LEN, IFPARAM_IFID, DHCPOPT_RAPID_COMMIT, DHCPOPT_AUTHINFO, DHCPOPT_DNS, DHCPOPT_DNSNAME, DHCPOPT_IA_PD, DHCPOPT_IA_NA, DHCPOPT_NTP, diff --git a/dhcp6c.conf.5 b/dhcp6c.conf.5 index 3d5d25a..1c91d72 100644 --- a/dhcp6c.conf.5 +++ b/dhcp6c.conf.5 @@ -443,6 +443,16 @@ This statement specifies the length of the SLA ID in bits. must be a decimal number between 0 and 128. If the length is not specified by this statement, the default value 16 will be used. +.It Xo +.Ic ifid Ar ID +; +.Xc +This statement specifies the interface id. +.Ar ID +must be a decimal integer. It will be combined with the delegated +prefix and the sla-id to form a complete interface address. The +default is to use the EUI-64 address of the +.Ar interface . .El .El .\" -- cgit v1.2.3