]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Add initial support for CER-ID
authorSteven Barth <steven@midlink.org>
Sun, 30 Mar 2014 17:51:56 +0000 (19:51 +0200)
committerSteven Barth <steven@midlink.org>
Sun, 30 Mar 2014 17:51:56 +0000 (19:51 +0200)
CMakeLists.txt
README
src/dhcpv6.c
src/odhcp6c.h
src/script.c

index 47537e9f79f39210dd9b49baa866a171ef6455a1..aedeebf02a90d890c977f1a4de593916e5a0d55d 100644 (file)
@@ -11,6 +11,10 @@ if(${EXT_PREFIX_CLASS})
        add_definitions(-DEXT_PREFIX_CLASS=${EXT_PREFIX_CLASS})
 endif(${EXT_PREFIX_CLASS})
 
+if(${EXT_CER_ID})
+       add_definitions(-DEXT_CER_ID=${EXT_CER_ID})
+endif(${EXT_CER_ID})
+
 if(${EXT_BFD_PING})
        add_definitions(-DEXT_BFD_PING)
        set(BFD_SOURCE src/bfd.c)
diff --git a/README b/README
index 0b4cf9ae1e01d842add38aa8ec46116787ab3f3e..6f5c62ce1508fb9fd90a6204801d133cf2e19388 100644 (file)
--- a/README
+++ b/README
@@ -28,6 +28,8 @@ especially routers. It compiles to only about 30 KB (-Os -s).
        g) Information-Refresh Options
        h) Configurable SOL_MAX_RT
        i) DS-Lite AFTR-Name Option
+       j) Prefix Class (experimental)
+       k) CER-ID (experimental)
 
 4. Support for requesting and parsing Router Advertisements
        a) parsing of prefixes, routes, MTU and RDNSS options
index c87d289e159687b03aa3fc87f1c9b98b3651c06d..afea77f2034950567c100cd95b3e977a91e10e46 100644 (file)
@@ -175,6 +175,9 @@ int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout)
                        htons(DHCPV6_OPT_INF_MAX_RT),
 #ifdef EXT_PREFIX_CLASS
                        htons(DHCPV6_OPT_PREFIX_CLASS),
+#endif
+#ifdef EXT_CER_ID
+                       htons(DHCPV6_OPT_CER_ID),
 #endif
                };
                odhcp6c_add_state(STATE_ORO, oro, sizeof(oro));
@@ -1010,7 +1013,15 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
                        if (inf_max_rt >= DHCPV6_INF_MAX_RT_MIN &&
                                        inf_max_rt <= DHCPV6_INF_MAX_RT_MAX)
                                dhcpv6_retx[DHCPV6_MSG_INFO_REQ].max_timeo = inf_max_rt;
-               }else if (otype != DHCPV6_OPT_CLIENTID &&
+#ifdef EXT_CER_ID
+               } else if (otype == DHCPV6_OPT_CER_ID && olen == -4 +
+                               sizeof(struct dhcpv6_cer_id)) {
+                       struct dhcpv6_cer_id *cer_id = (void*)&odata[-4];
+                       struct in6_addr any = IN6ADDR_ANY_INIT;
+                       if (memcmp(&cer_id->addr, &any, sizeof(any)))
+                               odhcp6c_add_state(STATE_CER, &cer_id->addr, sizeof(any));
+#endif
+               } else if (otype != DHCPV6_OPT_CLIENTID &&
                                otype != DHCPV6_OPT_SERVERID) {
                        odhcp6c_add_state(STATE_CUSTOM_OPTS,
                                        &odata[-4], olen + 4);
index f9a3fec553f137bb579c41b64acd465a6b72b6d1..2bc289b3d6198f7fae2ab185100b38b0f4ed2827 100644 (file)
@@ -67,6 +67,10 @@ enum dhcvp6_opt {
        /* draft-bhandari-dhc-class-based-prefix, not yet standardized */
        DHCPV6_OPT_PREFIX_CLASS = EXT_PREFIX_CLASS,
 #endif
+#ifdef EXT_CER_ID
+       /* draft-donley-dhc-cer-id-option-03 */
+       DHCPV6_OPT_CER_ID = EXT_CER_ID,
+#endif
 };
 
 enum dhcpv6_opt_npt {
@@ -170,6 +174,15 @@ struct dhcpv6_auth_reconfigure {
        uint8_t key[16];
 } _packed;
 
+struct dhcpv6_cer_id {
+       uint16_t type;
+       uint16_t len;
+       uint16_t reserved;
+       uint16_t auth_type;
+       uint8_t auth[16];
+       struct in6_addr addr;
+} _packed;
+
 
 #define dhcpv6_for_each_option(start, end, otype, olen, odata)\
        for (uint8_t *_o = (uint8_t*)(start); _o + 4 <= (uint8_t*)(end) &&\
@@ -215,6 +228,7 @@ enum odhcp6c_state {
        STATE_AFTR_NAME,
        STATE_VENDORCLASS,
        STATE_USERCLASS,
+       STATE_CER,
        _STATE_MAX
 };
 
index 61bab67528efba3e5b5d096a072ea1e746ce43fc..9089409565c3c2d37c94b81f812a848c35d4e577 100644 (file)
@@ -232,7 +232,7 @@ void script_delay_call(const char *status, int timeout)
 void script_call(const char *status)
 {
        size_t dns_len, search_len, custom_len, sntp_ip_len, ntp_ip_len, ntp_dns_len;
-       size_t sip_ip_len, sip_fqdn_len, aftr_name_len;
+       size_t sip_ip_len, sip_fqdn_len, aftr_name_len, cer_len;
 
        odhcp6c_expire();
        if (delayed_call) {
@@ -249,6 +249,7 @@ void script_call(const char *status)
        struct in6_addr *sip = odhcp6c_get_state(STATE_SIP_IP, &sip_ip_len);
        uint8_t *sip_fqdn = odhcp6c_get_state(STATE_SIP_FQDN, &sip_fqdn_len);
        uint8_t *aftr_name = odhcp6c_get_state(STATE_AFTR_NAME, &aftr_name_len);
+       struct in6_addr *cer = odhcp6c_get_state(STATE_CER, &cer_len);
 
        size_t prefix_len, address_len, ra_pref_len, ra_route_len, ra_dns_len;
        uint8_t *prefix = odhcp6c_get_state(STATE_IA_PD, &prefix_len);
@@ -268,6 +269,7 @@ void script_call(const char *status)
                fqdn_to_env("SIP_DOMAIN", sip_fqdn, sip_fqdn_len);
                fqdn_to_env("AFTR", aftr_name, aftr_name_len);
                fqdn_to_ip_env("AFTR_IP", aftr_name, aftr_name_len);
+               ipv6_to_env("CER", cer, cer_len / sizeof(*cer));
                bin_to_env(custom, custom_len);
                entry_to_env("PREFIXES", prefix, prefix_len, ENTRY_PREFIX);
                entry_to_env("ADDRESSES", address, address_len, ENTRY_ADDRESS);