openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/libsystemd-network/sd-dhcp6-client.c
static int dhcp6_client_set_duid_internal(sd_dhcp6_client* client,
                                          uint16_t duid_type, const void* duid,
                                          size_t duid_len, usec_t llt_time)
{
    int r;

    assert_return(client, -EINVAL);
    assert_return(duid_len == 0 || duid != NULL, -EINVAL);
    assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);

    if (duid != NULL)
    {
        r = dhcp_validate_duid_len(duid_type, duid_len, true);
        if (r < 0)
        {
            r = dhcp_validate_duid_len(duid_type, duid_len, false);
            if (r < 0)
                return r;
            log_dhcp6_client(client,
                             "Setting DUID of type %u with unexpected content",
                             duid_type);
        }

        client->duid.type = htobe16(duid_type);
        memcpy(&client->duid.raw.data, duid, duid_len);
        client->duid_len = sizeof(client->duid.type) + duid_len;
    }
    else
        switch (duid_type)
        {
            case DUID_TYPE_LLT:
                if (client->mac_addr_len == 0)
                    return -EOPNOTSUPP;

                r = dhcp_identifier_set_duid_llt(
                    &client->duid, llt_time, client->mac_addr,
                    client->mac_addr_len, client->arp_type, &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_EN:
                r = dhcp_identifier_set_duid_en(&client->duid,
                                                &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_LL:
                if (client->mac_addr_len == 0)
                    return -EOPNOTSUPP;

                r = dhcp_identifier_set_duid_ll(
                    &client->duid, client->mac_addr, client->mac_addr_len,
                    client->arp_type, &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_UUID:
                r = dhcp_identifier_set_duid_uuid(&client->duid,
                                                  &client->duid_len);
                if (r < 0)
                    return r;
                break;
            default:
                return -EINVAL;
        }

    return 0;
}
/**
 * Sets DUID. If duid is non-null, the DUID is set to duid_type + duid
 * without further modification. Otherwise, if duid_type is supported, DUID
 * is set based on that type. Otherwise, an error is returned.
 */
Sets DUID. If duid is non-null, the DUID is set to duid_type + duid
without further modification. Otherwise, if duid_type is supported, DUID
is set based on that type. Otherwise, an error is returned.
Sets DUID . If duid is non - null the DUID is set to duid_type + duid without further modification . Otherwise if duid_type is supported DUID is set based on that type . Otherwise an error is returned .
static int dhcp6_client_set_duid_internal(sd_dhcp6_client* client,
                                          uint16_t duid_type, const void* duid,
                                          size_t duid_len, usec_t llt_time)
{
    int r;
    assert_return(client, -EINVAL);
    assert_return(duid_len == 0 || duid != NULL, -EINVAL);
    assert_return(IN_SET(client->state, DHCP6_STATE_STOPPED), -EBUSY);
    if (duid != NULL)
    {
        r = dhcp_validate_duid_len(duid_type, duid_len, true);
        if (r < 0)
        {
            r = dhcp_validate_duid_len(duid_type, duid_len, false);
            if (r < 0)
                return r;
            log_dhcp6_client(client,
                             "Setting DUID of type %u with unexpected content",
                             duid_type);
        }
        client->duid.type = htobe16(duid_type);
        memcpy(&client->duid.raw.data, duid, duid_len);
        client->duid_len = sizeof(client->duid.type) + duid_len;
    }
    else
        switch (duid_type)
        {
            case DUID_TYPE_LLT:
                if (client->mac_addr_len == 0)
                    return -EOPNOTSUPP;
                r = dhcp_identifier_set_duid_llt(
                    &client->duid, llt_time, client->mac_addr,
                    client->mac_addr_len, client->arp_type, &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_EN:
                r = dhcp_identifier_set_duid_en(&client->duid,
                                                &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_LL:
                if (client->mac_addr_len == 0)
                    return -EOPNOTSUPP;
                r = dhcp_identifier_set_duid_ll(
                    &client->duid, client->mac_addr, client->mac_addr_len,
                    client->arp_type, &client->duid_len);
                if (r < 0)
                    return r;
                break;
            case DUID_TYPE_UUID:
                r = dhcp_identifier_set_duid_uuid(&client->duid,
                                                  &client->duid_len);
                if (r < 0)
                    return r;
                break;
            default:
                return -EINVAL;
        }
    return 0;
}
static int dhcp6_client_set_duid_internal ( sd_dhcp6_client * client , uint16_t duid_type , const void * duid , size_t duid_len , usec_t llt_time ) { int r ; assert_return ( client , - EINVAL ) ; assert_return ( duid_len == 0 || duid != NULL , - EINVAL ) ; assert_return ( IN_SET ( client -> state , DHCP6_STATE_STOPPED ) , - EBUSY ) ; if ( duid != NULL ) { r = dhcp_validate_duid_len ( duid_type , duid_len , true ) ; if ( r < 0 ) { r = dhcp_validate_duid_len ( duid_type , duid_len , false ) ; if ( r < 0 ) return r ; log_dhcp6_client ( client , " " , duid_type ) ; } client -> duid . type = htobe16 ( duid_type ) ; memcpy ( & client -> duid . raw . data , duid , duid_len ) ; client -> duid_len = sizeof ( client -> duid . type ) + duid_len ; } else switch ( duid_type ) { case DUID_TYPE_LLT : if ( client -> mac_addr_len == 0 ) return - EOPNOTSUPP ; r = dhcp_identifier_set_duid_llt ( & client -> duid , llt_time , client -> mac_addr , client -> mac_addr_len , client -> arp_type , & client -> duid_len ) ; if ( r < 0 ) return r ; break ; case DUID_TYPE_EN : r = dhcp_identifier_set_duid_en ( & client -> duid , & client -> duid_len ) ; if ( r < 0 ) return r ; break ; case DUID_TYPE_LL : if ( client -> mac_addr_len == 0 ) return - EOPNOTSUPP ; r = dhcp_identifier_set_duid_ll ( & client -> duid , client -> mac_addr , client -> mac_addr_len , client -> arp_type , & client -> duid_len ) ; if ( r < 0 ) return r ; break ; case DUID_TYPE_UUID : r = dhcp_identifier_set_duid_uuid ( & client -> duid , & client -> duid_len ) ; if ( r < 0 ) return r ; break ; default : return - EINVAL ; } return 0 ; }
Sets DUID.
Sets DUID .