summaryrefslogtreecommitdiffstats
path: root/src/net/udp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/udp')
-rw-r--r--src/net/udp/dhcp.c44
-rw-r--r--src/net/udp/dhcpv6.c6
-rw-r--r--src/net/udp/dns.c8
-rw-r--r--src/net/udp/syslog.c14
4 files changed, 33 insertions, 39 deletions
diff --git a/src/net/udp/dhcp.c b/src/net/udp/dhcp.c
index 66bcc83ae..3163f39c7 100644
--- a/src/net/udp/dhcp.c
+++ b/src/net/udp/dhcp.c
@@ -92,7 +92,7 @@ static uint8_t dhcp_request_options_data[] = {
};
/** DHCP server address setting */
-struct setting dhcp_server_setting __setting ( SETTING_MISC ) = {
+const struct setting dhcp_server_setting __setting ( SETTING_MISC ) = {
.name = "dhcp-server",
.description = "DHCP server",
.tag = DHCP_SERVER_IDENTIFIER,
@@ -975,6 +975,7 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
uint8_t *dhcp_features;
size_t dhcp_features_len;
size_t ll_addr_len;
+ void *user_class;
ssize_t len;
int rc;
@@ -985,7 +986,7 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
data, max_len ) ) != 0 ) {
DBG ( "DHCP could not create DHCP packet: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_create_packet;
}
/* Set client IP address */
@@ -998,17 +999,17 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
dhcp_features_len ) ) != 0 ) {
DBG ( "DHCP could not set features list option: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_store_features;
}
/* Add options to identify the network device */
- fetch_setting ( &netdev->settings.settings, &busid_setting, &dhcp_desc,
- sizeof ( dhcp_desc ) );
+ fetch_raw_setting ( netdev_settings ( netdev ), &busid_setting,
+ &dhcp_desc, sizeof ( dhcp_desc ) );
if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_EB_BUS_ID, &dhcp_desc,
sizeof ( dhcp_desc ) ) ) != 0 ) {
DBG ( "DHCP could not set bus ID option: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_store_busid;
}
/* Add DHCP client identifier. Required for Infiniband, and
@@ -1022,7 +1023,7 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
( ll_addr_len + 1 ) ) ) != 0 ) {
DBG ( "DHCP could not set client ID: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_store_client_id;
}
/* Add client UUID, if we have one. Required for PXE. The
@@ -1039,25 +1040,29 @@ int dhcp_create_request ( struct dhcp_packet *dhcppkt,
sizeof ( client_uuid ) ) ) != 0 ) {
DBG ( "DHCP could not set client UUID: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_store_client_uuid;
}
}
/* Add user class, if we have one. */
- if ( ( len = fetch_setting_len ( NULL, &user_class_setting ) ) >= 0 ) {
- char user_class[len];
- fetch_setting ( NULL, &user_class_setting, user_class,
- sizeof ( user_class ) );
+ if ( ( len = fetch_raw_setting_copy ( NULL, &user_class_setting,
+ &user_class ) ) >= 0 ) {
if ( ( rc = dhcppkt_store ( dhcppkt, DHCP_USER_CLASS_ID,
- &user_class,
- sizeof ( user_class ) ) ) != 0 ) {
+ user_class, len ) ) != 0 ) {
DBG ( "DHCP could not set user class: %s\n",
strerror ( rc ) );
- return rc;
+ goto err_store_user_class;
}
}
- return 0;
+ err_store_user_class:
+ free ( user_class );
+ err_store_client_uuid:
+ err_store_client_id:
+ err_store_busid:
+ err_store_features:
+ err_create_packet:
+ return rc;
}
/****************************************************************************
@@ -1384,7 +1389,8 @@ int start_pxebs ( struct interface *job, struct net_device *netdev,
int rc;
/* Get upper bound for PXE boot server IP address list */
- pxebs_list_len = fetch_setting_len ( NULL, &pxe_boot_servers_setting );
+ pxebs_list_len = fetch_raw_setting ( NULL, &pxe_boot_servers_setting,
+ NULL, 0 );
if ( pxebs_list_len < 0 )
pxebs_list_len = 0;
@@ -1422,8 +1428,8 @@ int start_pxebs ( struct interface *job, struct net_device *netdev,
if ( pxebs_list_len ) {
uint8_t buf[pxebs_list_len];
- fetch_setting ( NULL, &pxe_boot_servers_setting,
- buf, sizeof ( buf ) );
+ fetch_raw_setting ( NULL, &pxe_boot_servers_setting,
+ buf, sizeof ( buf ) );
pxebs_list ( dhcp, buf, sizeof ( buf ), ip );
}
if ( ! dhcp->pxe_attempt->s_addr ) {
diff --git a/src/net/udp/dhcpv6.c b/src/net/udp/dhcpv6.c
index 42d11194f..7bed83d92 100644
--- a/src/net/udp/dhcpv6.c
+++ b/src/net/udp/dhcpv6.c
@@ -256,7 +256,7 @@ static int dhcpv6_iaaddr ( struct dhcpv6_option_list *options, uint32_t iaid,
*/
/** DHCPv6 settings scope */
-static struct settings_scope dhcpv6_settings_scope;
+static const struct settings_scope dhcpv6_settings_scope;
/** A DHCPv6 settings block */
struct dhcpv6_settings {
@@ -276,7 +276,7 @@ struct dhcpv6_settings {
* @ret applies Setting applies within this settings block
*/
static int dhcpv6_applies ( struct settings *settings __unused,
- struct setting *setting ) {
+ const struct setting *setting ) {
return ( setting->scope == &dhcpv6_settings_scope );
}
@@ -543,7 +543,7 @@ static size_t dhcpv6_user_class ( void *data, size_t len ) {
int actual_len;
/* Fetch user-class setting, if defined */
- actual_len = fetch_setting ( NULL, &user_class_setting, data, len );
+ actual_len = fetch_raw_setting ( NULL, &user_class_setting, data, len );
if ( actual_len >= 0 )
return actual_len;
diff --git a/src/net/udp/dns.c b/src/net/udp/dns.c
index 45f0f07c1..447da8afd 100644
--- a/src/net/udp/dns.c
+++ b/src/net/udp/dns.c
@@ -594,7 +594,7 @@ struct resolver dns_resolver __resolver ( RESOLV_NORMAL ) = {
*/
/** DNS server setting */
-struct setting dns_setting __setting ( SETTING_IPv4_EXTRA ) = {
+const struct setting dns_setting __setting ( SETTING_IPv4_EXTRA ) = {
.name = "dns",
.description = "DNS server",
.tag = DHCP_DNS_SERVERS,
@@ -622,11 +622,7 @@ static int apply_dns_settings ( void ) {
/* Get local domain DHCP option */
free ( localdomain );
- if ( ( len = fetch_string_setting_copy ( NULL, &domain_setting,
- &localdomain ) ) < 0 ) {
- DBG ( "DNS could not fetch local domain: %s\n",
- strerror ( len ) );
- }
+ fetch_string_setting_copy ( NULL, &domain_setting, &localdomain );
if ( localdomain )
DBG ( "DNS local domain %s\n", localdomain );
diff --git a/src/net/udp/syslog.c b/src/net/udp/syslog.c
index 4210083d2..6554ab9bf 100644
--- a/src/net/udp/syslog.c
+++ b/src/net/udp/syslog.c
@@ -188,7 +188,7 @@ struct console_driver syslog_console __console_driver = {
*/
/** Syslog server setting */
-struct setting syslog_setting __setting ( SETTING_MISC ) = {
+const struct setting syslog_setting __setting ( SETTING_MISC ) = {
.name = "syslog",
.description = "Syslog server",
.tag = DHCP_LOG_SERVERS,
@@ -209,17 +209,9 @@ static int apply_syslog_settings ( void ) {
/* Fetch hostname and domain name */
free ( syslog_hostname );
- if ( ( len = fetch_string_setting_copy ( NULL, &hostname_setting,
- &syslog_hostname ) ) < 0 ) {
- rc = len;
- DBG ( "SYSLOG could not fetch hostname: %s\n", strerror ( rc ));
- }
+ fetch_string_setting_copy ( NULL, &hostname_setting, &syslog_hostname );
free ( syslog_domain );
- if ( ( len = fetch_string_setting_copy ( NULL, &domain_setting,
- &syslog_domain ) ) < 0 ) {
- rc = len;
- DBG ( "SYSLOG could not fetch domain: %s\n", strerror ( rc ) );
- }
+ fetch_string_setting_copy ( NULL, &domain_setting, &syslog_domain );
/* Fetch log server */
syslog_console.disabled = CONSOLE_DISABLED;