comparison src/dhcp.c @ 5573:5bf8e1fc0634 draft

DHCP: For anonymous, just use a generic clientid
author Roy Marples <roy@marples.name>
date Sun, 27 Dec 2020 23:52:44 +0000
parents 6d72dc67a984
children
comparison
equal deleted inserted replaced
5572:aae13416e9b7 5573:5bf8e1fc0634
3884 3884
3885 free(state->clientid); 3885 free(state->clientid);
3886 state->clientid = NULL; 3886 state->clientid = NULL;
3887 3887
3888 if (ifo->options & DHCPCD_ANONYMOUS) { 3888 if (ifo->options & DHCPCD_ANONYMOUS) {
3889 uint8_t duid[DUID_LEN]; 3889 /* Removing the option could show that we want anonymous.
3890 uint8_t duid_len; 3890 * As such keep it as it's already in the hwaddr field. */
3891 3891 goto make_clientid;
3892 duid_len = (uint8_t)duid_make(duid, ifp, DUID_LL);
3893 if (duid_len != 0) {
3894 state->clientid = malloc((size_t)duid_len + 6);
3895 if (state->clientid == NULL)
3896 goto eexit;
3897 state->clientid[0] =(uint8_t)(duid_len + 5);
3898 state->clientid[1] = 255; /* RFC 4361 */
3899 memcpy(state->clientid + 2, ifo->iaid, 4);
3900 memset(state->clientid + 2, 0, 4); /* IAID */
3901 memcpy(state->clientid + 6, duid, duid_len);
3902 }
3903 } else if (*ifo->clientid) { 3892 } else if (*ifo->clientid) {
3904 state->clientid = malloc((size_t)(ifo->clientid[0] + 1)); 3893 state->clientid = malloc((size_t)(ifo->clientid[0] + 1));
3905 if (state->clientid == NULL) 3894 if (state->clientid == NULL)
3906 goto eexit; 3895 goto eexit;
3907 memcpy(state->clientid, ifo->clientid, 3896 memcpy(state->clientid, ifo->clientid,
3915 state->clientid[1] = 255; /* RFC 4361 */ 3904 state->clientid[1] = 255; /* RFC 4361 */
3916 memcpy(state->clientid + 2, ifo->iaid, 4); 3905 memcpy(state->clientid + 2, ifo->iaid, 4);
3917 memcpy(state->clientid + 6, ifp->ctx->duid, 3906 memcpy(state->clientid + 6, ifp->ctx->duid,
3918 ifp->ctx->duid_len); 3907 ifp->ctx->duid_len);
3919 } else { 3908 } else {
3909 make_clientid:
3920 len = (uint8_t)(ifp->hwlen + 1); 3910 len = (uint8_t)(ifp->hwlen + 1);
3921 state->clientid = malloc((size_t)len + 1); 3911 state->clientid = malloc((size_t)len + 1);
3922 if (state->clientid == NULL) 3912 if (state->clientid == NULL)
3923 goto eexit; 3913 goto eexit;
3924 state->clientid[0] = len; 3914 state->clientid[0] = len;