openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

dhcpv6-ia: allow up to 64 bit wide hostid #173

Closed mikma closed 2 years ago

mikma commented 2 years ago

This PR implements up to 64 bit wide hostid for dynamic and static leases.

dedeckeh commented 2 years ago

Can you squash all the commits into one commit as they're all related to the same feature

mikma commented 2 years ago

I have squashed and rebased on master at git.openwrt.org.

I also added a check against the reserved IPv6 interface identifier ranges listed at http://www.iana.org/assignments/ipv6-interface-ids .

dedeckeh commented 2 years ago

This fails to compile for me with the following error

src/dhcpv6-ia.c: In function 'dhcpv6_ia_write_statefile': src/dhcpv6-ia.c:367:54: error: format '%zx' expects argument of type 'size_t', but argument 10 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=] ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s %"PRId64" %zx %u ", ^~~~~~~ src/dhcpv6-ia.c:374:9: (ctxt.c->flags & OAF_DHCPV6_NA) ? ctxt.c->assigned_host_id : ctxt.c->assigned_subnet_id,


src/dhcpv6-ia.c:367:83: note: format string is defined here
      ctxt.buf_idx = snprintf(ctxt.buf, ctxt.buf_len, "# %s %s %x %s%s %"PRId64" %zx %u ",
                                                                                 ~~^
                                                                                 %llx

As assigned_hostìd is an uint64_t the best option is to move this to two separate snprintf lines depending on the assignment type
mikma commented 2 years ago

I have duplicated the snprintf statements and I use the PRIx64/32-macros in the format string now.

dedeckeh commented 2 years ago

Patch pushed to master with a minor modification (https://git.openwrt.org/?p=project/odhcpd.git;a=commit;h=16667699228101fda936068e3d11c0cf19270e34); thx