mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
sd-dhcp6-client: typedef several enums
Also introduces _MAX and _INVALID for several enums.
This commit is contained in:
parent
76dc17254f
commit
dd5e9378a2
@ -5,6 +5,7 @@
|
||||
Copyright © 2014 Intel Corporation. All rights reserved.
|
||||
***/
|
||||
|
||||
#include <errno.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/udp.h>
|
||||
|
||||
@ -49,15 +50,17 @@ enum {
|
||||
#define DHCP6_REB_TIMEOUT 10 * USEC_PER_SEC
|
||||
#define DHCP6_REB_MAX_RT 600 * USEC_PER_SEC
|
||||
|
||||
enum DHCP6State {
|
||||
DHCP6_STATE_STOPPED = 0,
|
||||
DHCP6_STATE_INFORMATION_REQUEST = 1,
|
||||
DHCP6_STATE_SOLICITATION = 2,
|
||||
DHCP6_STATE_REQUEST = 3,
|
||||
DHCP6_STATE_BOUND = 4,
|
||||
DHCP6_STATE_RENEW = 5,
|
||||
DHCP6_STATE_REBIND = 6,
|
||||
};
|
||||
typedef enum DHCP6State {
|
||||
DHCP6_STATE_STOPPED,
|
||||
DHCP6_STATE_INFORMATION_REQUEST,
|
||||
DHCP6_STATE_SOLICITATION,
|
||||
DHCP6_STATE_REQUEST,
|
||||
DHCP6_STATE_BOUND,
|
||||
DHCP6_STATE_RENEW,
|
||||
DHCP6_STATE_REBIND,
|
||||
_DHCP6_STATE_MAX,
|
||||
_DHCP6_STATE_INVALID = -EINVAL,
|
||||
} DHCP6State;
|
||||
|
||||
enum {
|
||||
DHCP6_SOLICIT = 1,
|
||||
@ -76,17 +79,17 @@ enum {
|
||||
_DHCP6_MESSAGE_MAX = 14,
|
||||
};
|
||||
|
||||
enum {
|
||||
typedef enum DHCP6NTPSubOption {
|
||||
DHCP6_NTP_SUBOPTION_SRV_ADDR = 1,
|
||||
DHCP6_NTP_SUBOPTION_MC_ADDR = 2,
|
||||
DHCP6_NTP_SUBOPTION_SRV_FQDN = 3,
|
||||
};
|
||||
} DHCP6NTPSubOption;
|
||||
|
||||
/*
|
||||
* RFC 8415, RFC 5007 and RFC 7653 status codes:
|
||||
* https://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xhtml#dhcpv6-parameters-5
|
||||
*/
|
||||
enum {
|
||||
typedef enum DHCP6Status {
|
||||
DHCP6_STATUS_SUCCESS = 0,
|
||||
DHCP6_STATUS_UNSPEC_FAIL = 1,
|
||||
DHCP6_STATUS_NO_ADDRS_AVAIL = 2,
|
||||
@ -110,11 +113,12 @@ enum {
|
||||
DHCP6_STATUS_SERVER_SHUTTING_DOWN = 20,
|
||||
DHCP6_STATUS_DNS_UPDATE_NOT_SUPPORTED = 21,
|
||||
DHCP6_STATUS_EXCESSIVE_TIME_SKEW = 22,
|
||||
_DHCP6_STATUS_MAX = 23,
|
||||
};
|
||||
_DHCP6_STATUS_MAX,
|
||||
_DHCP6_STATUS_INVALID = -EINVAL,
|
||||
} DHCP6Status;
|
||||
|
||||
enum {
|
||||
DHCP6_FQDN_FLAG_S = (1 << 0),
|
||||
DHCP6_FQDN_FLAG_O = (1 << 1),
|
||||
DHCP6_FQDN_FLAG_N = (1 << 2),
|
||||
};
|
||||
typedef enum DHCP6FQDNFlag {
|
||||
DHCP6_FQDN_FLAG_S = 1 << 0,
|
||||
DHCP6_FQDN_FLAG_O = 1 << 1,
|
||||
DHCP6_FQDN_FLAG_N = 1 << 2,
|
||||
} DHCP6FQDNFlag;
|
||||
|
@ -44,7 +44,7 @@ enum {
|
||||
struct sd_dhcp6_client {
|
||||
unsigned n_ref;
|
||||
|
||||
enum DHCP6State state;
|
||||
DHCP6State state;
|
||||
sd_event *event;
|
||||
int event_priority;
|
||||
int ifindex;
|
||||
@ -145,7 +145,7 @@ DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_status, int);
|
||||
#define DHCP6_CLIENT_DONT_DESTROY(client) \
|
||||
_cleanup_(sd_dhcp6_client_unrefp) _unused_ sd_dhcp6_client *_dont_destroy_##client = sd_dhcp6_client_ref(client)
|
||||
|
||||
static int client_start(sd_dhcp6_client *client, enum DHCP6State state);
|
||||
static int client_start(sd_dhcp6_client *client, DHCP6State state);
|
||||
|
||||
int sd_dhcp6_client_set_callback(
|
||||
sd_dhcp6_client *client,
|
||||
@ -849,6 +849,8 @@ static int client_send_message(sd_dhcp6_client *client, usec_t time_now) {
|
||||
case DHCP6_STATE_STOPPED:
|
||||
case DHCP6_STATE_BOUND:
|
||||
return -EINVAL;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
r = dhcp6_option_append(&opt, &optlen, SD_DHCP6_OPTION_ORO,
|
||||
@ -926,7 +928,7 @@ static int client_timeout_t1(sd_event_source *s, uint64_t usec, void *userdata)
|
||||
static int client_timeout_resend_expire(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
sd_dhcp6_client *client = userdata;
|
||||
DHCP6_CLIENT_DONT_DESTROY(client);
|
||||
enum DHCP6State state;
|
||||
DHCP6State state;
|
||||
|
||||
assert(s);
|
||||
assert(client);
|
||||
@ -1017,6 +1019,8 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
|
||||
case DHCP6_STATE_STOPPED:
|
||||
case DHCP6_STATE_BOUND:
|
||||
return 0;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (max_retransmit_count > 0 &&
|
||||
@ -1507,6 +1511,8 @@ static int client_receive_message(
|
||||
|
||||
case DHCP6_STATE_STOPPED:
|
||||
return 0;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
log_dhcp6_client(client, "Recv %s",
|
||||
@ -1537,7 +1543,7 @@ static int client_get_lifetime(sd_dhcp6_client *client, uint32_t *lifetime_t1,
|
||||
return -ENOMSG;
|
||||
}
|
||||
|
||||
static int client_start(sd_dhcp6_client *client, enum DHCP6State state) {
|
||||
static int client_start(sd_dhcp6_client *client, DHCP6State state) {
|
||||
int r;
|
||||
usec_t timeout, time_now;
|
||||
uint32_t lifetime_t1, lifetime_t2;
|
||||
@ -1637,6 +1643,8 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state) {
|
||||
client->state = state;
|
||||
|
||||
return 0;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
client->transaction_id = random_u32() & htobe32(0x00ffffff);
|
||||
@ -1675,7 +1683,7 @@ int sd_dhcp6_client_is_running(sd_dhcp6_client *client) {
|
||||
}
|
||||
|
||||
int sd_dhcp6_client_start(sd_dhcp6_client *client) {
|
||||
enum DHCP6State state = DHCP6_STATE_SOLICITATION;
|
||||
DHCP6State state = DHCP6_STATE_SOLICITATION;
|
||||
int r;
|
||||
|
||||
assert_return(client, -EINVAL);
|
||||
|
Loading…
Reference in New Issue
Block a user