summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-08-26 23:05:34 +0200
committerLennart Poettering <lennart@poettering.net>2015-08-26 23:05:34 +0200
commite473522841f630bfd25725b06605462e5e30587f (patch)
tree85ea8fd6127e4cb636ec6a07453bdc147d938b22 /src/libsystemd-network
parent89ca10c6a61309d84d54c5dc5a295387ce39e610 (diff)
dhcp: generic data should be void*, not uint8_t*
If we handly arbitrary data we should use "void*" pointers, not "uint8_t*", how go intended C to be used.
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/dhcp-internal.h2
-rw-r--r--src/libsystemd-network/dhcp-lease-internal.h10
-rw-r--r--src/libsystemd-network/network-internal.c4
-rw-r--r--src/libsystemd-network/network-internal.h4
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c14
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c2
-rw-r--r--src/libsystemd-network/test-dhcp-client.c8
-rw-r--r--src/libsystemd-network/test-dhcp-option.c6
8 files changed, 25 insertions, 25 deletions
diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h
index 0df14f8051..df6f882af5 100644
--- a/src/libsystemd-network/dhcp-internal.h
+++ b/src/libsystemd-network/dhcp-internal.h
@@ -45,7 +45,7 @@ int dhcp_option_append(DHCPMessage *message, size_t size, size_t *offset, uint8_
uint8_t code, size_t optlen, const void *optval);
typedef int (*dhcp_option_cb_t)(uint8_t code, uint8_t len,
- const uint8_t *option, void *userdata);
+ const void *option, void *userdata);
int dhcp_option_parse(DHCPMessage *message, size_t len,
dhcp_option_cb_t cb, void *userdata);
diff --git a/src/libsystemd-network/dhcp-lease-internal.h b/src/libsystemd-network/dhcp-lease-internal.h
index 1765fabd4b..ebe6c2f7e7 100644
--- a/src/libsystemd-network/dhcp-lease-internal.h
+++ b/src/libsystemd-network/dhcp-lease-internal.h
@@ -78,23 +78,23 @@ struct sd_dhcp_lease {
char *domainname;
char *hostname;
char *root_path;
- uint8_t *client_id;
+ void *client_id;
size_t client_id_len;
- uint8_t *vendor_specific;
+ void *vendor_specific;
size_t vendor_specific_len;
char *timezone;
LIST_HEAD(struct sd_dhcp_raw_option, private_options);
};
int dhcp_lease_new(sd_dhcp_lease **ret);
-int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option,
+int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option,
void *userdata);
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag,
- const uint8_t *data, uint8_t len);
+ const void *data, uint8_t len);
int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease);
-int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const uint8_t *client_id,
+int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id,
size_t client_id_len);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index d8357c687e..26bd4088d9 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -525,7 +525,7 @@ int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t
return 0;
}
-int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t size) {
+int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size) {
_cleanup_free_ char *hex_buf = NULL;
assert(f);
@@ -541,7 +541,7 @@ int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t
return 0;
}
-int deserialize_dhcp_option(uint8_t **data, size_t *data_len, const char *string) {
+int deserialize_dhcp_option(void **data, size_t *data_len, const char *string) {
assert(data);
assert(data_len);
assert(string);
diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h
index dca82646ce..d5d4ef42f2 100644
--- a/src/libsystemd-network/network-internal.h
+++ b/src/libsystemd-network/network-internal.h
@@ -77,5 +77,5 @@ struct sd_dhcp_route;
void serialize_dhcp_routes(FILE *f, const char *key, struct sd_dhcp_route *routes, size_t size);
int deserialize_dhcp_routes(struct sd_dhcp_route **ret, size_t *ret_size, size_t *ret_allocated, const char *string);
-int serialize_dhcp_option(FILE *f, const char *key, const uint8_t *data, size_t size);
-int deserialize_dhcp_option(uint8_t **data, size_t *data_len, const char *string);
+int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t size);
+int deserialize_dhcp_option(void **data, size_t *data_len, const char *string);
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 75989951cf..328ab152b8 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -179,7 +179,7 @@ int sd_dhcp_lease_get_routes(sd_dhcp_lease *lease, struct sd_dhcp_route **routes
return 0;
}
-int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const uint8_t **data,
+int sd_dhcp_lease_get_vendor_specific(sd_dhcp_lease *lease, const void **data,
size_t *data_len) {
assert_return(lease, -EINVAL);
assert_return(data, -EINVAL);
@@ -436,7 +436,7 @@ static int lease_parse_classless_routes(const uint8_t *option, size_t len, struc
return 0;
}
-int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option, void *userdata) {
+int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata) {
sd_dhcp_lease *lease = userdata;
int r;
@@ -619,7 +619,7 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const uint8_t *option, v
}
int dhcp_lease_insert_private_option(sd_dhcp_lease *lease, uint8_t tag,
- const uint8_t *data, uint8_t len) {
+ const void *data, uint8_t len) {
struct sd_dhcp_raw_option *cur, *option;
LIST_FOREACH(options, cur, lease->private_options) {
@@ -669,7 +669,7 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
struct sd_dhcp_raw_option *option;
struct in_addr address;
const struct in_addr *addresses;
- const uint8_t *client_id, *data;
+ const void *client_id, *data;
size_t client_id_len, data_len;
const char *string;
uint16_t mtu;
@@ -950,7 +950,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
}
for (i = 0; i <= DHCP_OPTION_PRIVATE_LAST - DHCP_OPTION_PRIVATE_BASE; i++) {
- _cleanup_free_ uint8_t *data = NULL;
+ _cleanup_free_ void *data = NULL;
size_t len;
if (!options[i])
@@ -990,7 +990,7 @@ int dhcp_lease_set_default_subnet_mask(sd_dhcp_lease *lease) {
return 0;
}
-int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const uint8_t **client_id,
+int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const void **client_id,
size_t *client_id_len) {
assert_return(lease, -EINVAL);
assert_return(client_id, -EINVAL);
@@ -1001,7 +1001,7 @@ int sd_dhcp_lease_get_client_id(sd_dhcp_lease *lease, const uint8_t **client_id,
return 0;
}
-int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const uint8_t *client_id,
+int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id,
size_t client_id_len) {
assert_return(lease, -EINVAL);
assert_return((!client_id && !client_id_len) ||
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index df74d9f3ae..968df1f43d 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -550,7 +550,7 @@ static int server_send_forcerenew(sd_dhcp_server *server, be32_t address,
return 0;
}
-static int parse_request(uint8_t code, uint8_t len, const uint8_t *option,
+static int parse_request(uint8_t code, uint8_t len, const void *option,
void *userdata) {
DHCPRequest *req = userdata;
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 1e0df634a4..b2a0d3bb8b 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -126,7 +126,7 @@ static void test_checksum(void)
assert_se(dhcp_packet_checksum((uint8_t*)&buf, 20) == be16toh(0x78ae));
}
-static int check_options(uint8_t code, uint8_t len, const uint8_t *option,
+static int check_options(uint8_t code, uint8_t len, const void *option,
void *userdata)
{
switch(code) {
@@ -141,10 +141,10 @@ static int check_options(uint8_t code, uint8_t len, const uint8_t *option,
assert_se(len == sizeof(uint8_t) + sizeof(uint32_t) + duid_len);
assert_se(len == 19);
- assert_se(option[0] == 0xff);
+ assert_se(((uint8_t*) option)[0] == 0xff);
- assert_se(memcmp(&option[1], &iaid, sizeof(iaid)) == 0);
- assert_se(memcmp(&option[5], &duid, duid_len) == 0);
+ assert_se(memcmp((uint8_t*) option + 1, &iaid, sizeof(iaid)) == 0);
+ assert_se(memcmp((uint8_t*) option + 5, &duid, duid_len) == 0);
break;
}
diff --git a/src/libsystemd-network/test-dhcp-option.c b/src/libsystemd-network/test-dhcp-option.c
index 37f46c8c56..b1ef174849 100644
--- a/src/libsystemd-network/test-dhcp-option.c
+++ b/src/libsystemd-network/test-dhcp-option.c
@@ -145,7 +145,7 @@ static void test_ignore_opts(uint8_t *descoption, int *descpos, int *desclen) {
}
}
-static int test_options_cb(uint8_t code, uint8_t len, const uint8_t *option, void *userdata) {
+static int test_options_cb(uint8_t code, uint8_t len, const void *option, void *userdata) {
struct option_desc *desc = userdata;
uint8_t *descoption = NULL;
int *desclen = NULL, *descpos = NULL;
@@ -207,10 +207,10 @@ static int test_options_cb(uint8_t code, uint8_t len, const uint8_t *option, voi
for (i = 0; i < len; i++) {
if (verbose)
- printf("0x%02x(0x%02x) ", option[i],
+ printf("0x%02x(0x%02x) ", ((uint8_t*) option)[i],
descoption[*descpos + 2 + i]);
- assert_se(option[i] == descoption[*descpos + 2 + i]);
+ assert_se(((uint8_t*) option)[i] == descoption[*descpos + 2 + i]);
}
if (verbose)