summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2017-07-08 00:36:10 +0000
committerkrw <krw@openbsd.org>2017-07-08 00:36:10 +0000
commit024801d2c99cff11d22a187fff2822db50e8431c (patch)
tree4a20f3cca64e1ddebd4cfe3ac7d0970462e2f695
parentRun malloc0test with all possible malloc options. (diff)
downloadwireguard-openbsd-024801d2c99cff11d22a187fff2822db50e8431c.tar.xz
wireguard-openbsd-024801d2c99cff11d22a187fff2822db50e8431c.zip
Always use uintNN_t instead of sometimes u_intNN_t
and sometimes uintNN_t.
-rw-r--r--sbin/dhclient/bpf.c8
-rw-r--r--sbin/dhclient/clparse.c22
-rw-r--r--sbin/dhclient/dhclient.c16
-rw-r--r--sbin/dhclient/dhcp.h32
-rw-r--r--sbin/dhclient/dhcpd.h24
-rw-r--r--sbin/dhclient/kroute.c12
-rw-r--r--sbin/dhclient/options.c29
-rw-r--r--sbin/dhclient/packet.c42
-rw-r--r--sbin/dhclient/parse.c4
-rw-r--r--sbin/dhclient/privsep.h6
10 files changed, 98 insertions, 97 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index c374d1e3039..ae49ac84fd2 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.56 2017/07/07 15:14:47 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.57 2017/07/08 00:36:10 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -136,7 +136,7 @@ struct bpf_insn dhcp_bpf_filter[] = {
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */
/* If we passed all the tests, ask for the whole packet. */
- BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
+ BPF_STMT(BPF_RET+BPF_K, (unsigned int)-1),
/* Otherwise, drop it. */
BPF_STMT(BPF_RET+BPF_K, 0),
@@ -176,7 +176,7 @@ struct bpf_insn dhcp_bpf_wfilter[] = {
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1),
/* If we passed all the tests, ask for the whole packet. */
- BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
+ BPF_STMT(BPF_RET+BPF_K, (unsigned int)-1),
/* Otherwise, drop it. */
BPF_STMT(BPF_RET+BPF_K, 0),
@@ -302,7 +302,7 @@ send_packet(struct interface_info *ifi, struct in_addr from, struct in_addr to)
checksum((unsigned char *)packet, len,
checksum((unsigned char *)&ip.ip_src,
2 * sizeof(ip.ip_src),
- IPPROTO_UDP + (u_int32_t)ntohs(udp.uh_ulen)))));
+ IPPROTO_UDP + (uint32_t)ntohs(udp.uh_ulen)))));
iov[iovcnt].iov_base = &udp;
iov[iovcnt].iov_len = sizeof(udp);
iovcnt++;
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 431f0fa9455..da4d664a3d9 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.116 2017/07/07 16:58:45 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.117 2017/07/08 00:36:10 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -61,8 +61,8 @@
#include "log.h"
void parse_client_statement(FILE *, char *);
-int parse_X(FILE *, u_int8_t *, int);
-int parse_option_list(FILE *, u_int8_t *, size_t);
+int parse_X(FILE *, uint8_t *, int);
+int parse_option_list(FILE *, uint8_t *, size_t);
void parse_interface_declaration(FILE *, char *);
struct client_lease *parse_client_lease_statement(FILE *, char *);
void parse_client_lease_declaration(FILE *, struct client_lease *, char *);
@@ -220,7 +220,7 @@ read_client_leases(char *name, struct client_lease_tq *tq)
void
parse_client_statement(FILE *cfile, char *name)
{
- u_int8_t optlist[DHO_COUNT];
+ uint8_t optlist[DHO_COUNT];
char *string;
int code, count, token;
@@ -334,7 +334,7 @@ parse_client_statement(FILE *cfile, char *name)
}
int
-parse_X(FILE *cfile, u_int8_t *buf, int max)
+parse_X(FILE *cfile, uint8_t *buf, int max)
{
int token;
char *val;
@@ -385,7 +385,7 @@ parse_X(FILE *cfile, u_int8_t *buf, int max)
* option_list COMMA option_name
*/
int
-parse_option_list(FILE *cfile, u_int8_t *list, size_t sz)
+parse_option_list(FILE *cfile, uint8_t *list, size_t sz)
{
unsigned int ix, j;
int i;
@@ -618,13 +618,13 @@ parse_option_decl(FILE *cfile, struct option_data *options)
{
char *val;
int token;
- u_int8_t buf[4];
- u_int8_t cidr[5];
- u_int8_t hunkbuf[1024];
+ uint8_t buf[4];
+ uint8_t cidr[5];
+ uint8_t hunkbuf[1024];
unsigned int hunkix = 0;
char *fmt;
struct in_addr ip_addr;
- u_int8_t *dp;
+ uint8_t *dp;
int len, code;
int nul_term = 0;
@@ -680,7 +680,7 @@ parse_option_decl(FILE *cfile, struct option_data *options)
if (!parse_ip_addr(cfile, &ip_addr))
return (-1);
len = sizeof(ip_addr);
- dp = (u_int8_t *)&ip_addr;
+ dp = (uint8_t *)&ip_addr;
alloc:
if (hunkix + len > sizeof(hunkbuf)) {
parse_warn("option data buffer "
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index da3f27c491b..84e5007ea77 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.459 2017/07/07 16:58:45 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.460 2017/07/08 00:36:10 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1022,8 +1022,8 @@ bind_lease(struct interface_info *ifi)
flush_routes();
opt = &options[DHO_INTERFACE_MTU];
- if (opt->len == sizeof(u_int16_t)) {
- u_int16_t mtu;
+ if (opt->len == sizeof(uint16_t)) {
+ uint16_t mtu;
memcpy(&mtu, opt->data, sizeof(mtu));
mtu = ntohs(mtu);
/* "The minimum legal value for the MTU is 68." */
@@ -2355,9 +2355,9 @@ cleanup:
void
apply_ignore_list(char *ignore_list)
{
- u_int8_t list[DHO_COUNT];
- char *p;
- int ix, i, j;
+ uint8_t list[DHO_COUNT];
+ char *p;
+ int ix, i, j;
memset(list, 0, sizeof(list));
ix = 0;
@@ -2390,8 +2390,8 @@ apply_ignore_list(char *ignore_list)
void
set_lease_times(struct client_lease *lease)
{
- time_t cur_time, time_max;
- u_int32_t uint32val;
+ time_t cur_time, time_max;
+ uint32_t uint32val;
time(&cur_time);
diff --git a/sbin/dhclient/dhcp.h b/sbin/dhclient/dhcp.h
index 29f01fa8c1e..55e25cd23a6 100644
--- a/sbin/dhclient/dhcp.h
+++ b/sbin/dhclient/dhcp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcp.h,v 1.19 2017/07/07 16:58:45 krw Exp $ */
+/* $OpenBSD: dhcp.h,v 1.20 2017/07/08 00:36:10 krw Exp $ */
/* Protocol structures. */
@@ -57,21 +57,21 @@
#define BOOTP_MIN_LEN 300
struct dhcp_packet {
- u_int8_t op; /* Message opcode/type */
- u_int8_t htype; /* Hardware addr type (see net/if_types.h) */
- u_int8_t hlen; /* Hardware addr length */
- u_int8_t hops; /* Number of relay agent hops from client */
- u_int32_t xid; /* Transaction ID */
- u_int16_t secs; /* Seconds since client started looking */
- u_int16_t flags; /* Flag bits */
- struct in_addr ciaddr; /* Client IP address (if already in use) */
- struct in_addr yiaddr; /* Client IP address */
- struct in_addr siaddr; /* IP address of next server to talk to */
- struct in_addr giaddr; /* DHCP relay agent IP address */
- unsigned char chaddr[16]; /* Client hardware address */
- char sname[DHCP_SNAME_LEN]; /* Server name */
- char file[DHCP_FILE_LEN]; /* Boot filename */
- unsigned char options[DHCP_OPTION_LEN];
+ uint8_t op; /* Message opcode/type */
+ uint8_t htype; /* Hardware addr type (see net/if_types.h) */
+ uint8_t hlen; /* Hardware addr length */
+ uint8_t hops; /* Number of relay agent hops from client */
+ uint32_t xid; /* Transaction ID */
+ uint16_t secs; /* Seconds since client started looking */
+ uint16_t flags; /* Flag bits */
+ struct in_addr ciaddr; /* Client IP address (if already in use) */
+ struct in_addr yiaddr; /* Client IP address */
+ struct in_addr siaddr; /* IP address of next server to talk to */
+ struct in_addr giaddr; /* DHCP relay agent IP address */
+ unsigned char chaddr[16]; /* Client hardware address */
+ char sname[DHCP_SNAME_LEN]; /* Server name */
+ char file[DHCP_FILE_LEN]; /* Boot filename */
+ unsigned char options[DHCP_OPTION_LEN];
/* Optional parameters
(actual length dependent on MTU). */
};
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index a5d8da4cfc0..dbdee34dc1d 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.207 2017/07/07 16:58:45 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.208 2017/07/08 00:36:10 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -51,7 +51,7 @@ struct option {
struct option_data {
unsigned int len;
- u_int8_t *data;
+ uint8_t *data;
};
struct reject_elem {
@@ -100,9 +100,9 @@ struct client_config {
struct in_addr address;
struct in_addr next_server;
struct option_data send_options[DHO_COUNT];
- u_int8_t required_options[DHO_COUNT];
- u_int8_t requested_options[DHO_COUNT];
- u_int8_t ignored_options[DHO_COUNT];
+ uint8_t required_options[DHO_COUNT];
+ uint8_t requested_options[DHO_COUNT];
+ uint8_t ignored_options[DHO_COUNT];
int requested_option_count;
int required_option_count;
int ignored_option_count;
@@ -133,7 +133,7 @@ struct interface_info {
size_t rbuf_offset;
size_t rbuf_len;
int errors;
- u_int16_t index;
+ uint16_t index;
int linkstat;
int rdomain;
int flags;
@@ -143,10 +143,10 @@ struct interface_info {
struct dhcp_packet recv_packet;
struct dhcp_packet sent_packet;
int sent_packet_length;
- u_int32_t xid;
+ uint32_t xid;
time_t timeout;
void (*timeout_func)(struct interface_info *);
- u_int16_t secs;
+ uint16_t secs;
time_t first_sending;
time_t startup_time;
enum dhcp_state state;
@@ -230,10 +230,10 @@ void routehandler(struct interface_info *, int);
/* packet.c */
void assemble_eh_header(struct ether_addr, struct ether_header *);
-ssize_t decode_hw_header(unsigned char *, u_int32_t, struct ether_addr *);
-ssize_t decode_udp_ip_header(unsigned char *, u_int32_t, struct sockaddr_in *);
-u_int32_t checksum(unsigned char *, u_int32_t, u_int32_t);
-u_int32_t wrapsum(u_int32_t);
+ssize_t decode_hw_header(unsigned char *, uint32_t, struct ether_addr *);
+ssize_t decode_udp_ip_header(unsigned char *, uint32_t, struct sockaddr_in *);
+uint32_t checksum(unsigned char *, uint32_t, uint32_t);
+uint32_t wrapsum(uint32_t);
/* clparse.c */
void read_client_conf(char *);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 8b912e8c719..58f6608b634 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.102 2017/07/02 09:11:13 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.103 2017/07/08 00:36:10 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -709,7 +709,7 @@ priv_add_address(char *name, int ioctlfd, struct imsg_add_address *imsg)
* [priv_]write_resolv_conf write out a new resolv.conf.
*/
void
-write_resolv_conf(u_int8_t *contents, size_t sz)
+write_resolv_conf(uint8_t *contents, size_t sz)
{
int rslt;
@@ -722,11 +722,11 @@ write_resolv_conf(u_int8_t *contents, size_t sz)
}
void
-priv_write_resolv_conf(u_int8_t *contents, size_t sz)
+priv_write_resolv_conf(uint8_t *contents, size_t sz)
{
- const char *path = "/etc/resolv.conf";
- ssize_t n;
- int fd;
+ const char *path = "/etc/resolv.conf";
+ ssize_t n;
+ int fd;
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c
index 56d8bc94c9d..1a2c5723d54 100644
--- a/sbin/dhclient/options.c
+++ b/sbin/dhclient/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.95 2017/07/07 16:58:45 krw Exp $ */
+/* $OpenBSD: options.c,v 1.96 2017/07/08 00:36:10 krw Exp $ */
/* DHCP options parsing and reassembly. */
@@ -414,19 +414,20 @@ char *
pretty_print_option(unsigned int code, struct option_data *option,
int emit_punct)
{
- static char optbuf[8192]; /* XXX */
- int hunksize = 0, numhunk = -1, numelem = 0;
- char fmtbuf[32], *op = optbuf, *buf;
- int i, j, k, opleft = sizeof(optbuf);
- unsigned char *data = option->data;
- unsigned char *dp = data;
- int len = option->len;
- int opcount = 0;
- struct in_addr foo;
- char comma;
- int32_t int32val;
- u_int32_t uint32val;
- u_int16_t uint16val;
+ static char optbuf[8192]; /* XXX */
+ char fmtbuf[32];
+ struct in_addr foo;
+ unsigned char *data = option->data;
+ unsigned char *dp = data;
+ char *op = optbuf, *buf;
+ int hunksize = 0, numhunk = -1, numelem = 0;
+ int i, j, k, opleft = sizeof(optbuf);
+ int len = option->len;
+ int opcount = 0;
+ int32_t int32val;
+ uint32_t uint32val;
+ uint16_t uint16val;
+ char comma;
memset(optbuf, 0, sizeof(optbuf));
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index b2c6fe38b61..810649fbf02 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.36 2017/07/07 15:14:47 krw Exp $ */
+/* $OpenBSD: packet.c,v 1.37 2017/07/08 00:36:10 krw Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -59,14 +59,14 @@
#include "dhcpd.h"
#include "log.h"
-u_int32_t
-checksum(unsigned char *buf, u_int32_t nbytes, u_int32_t sum)
+uint32_t
+checksum(unsigned char *buf, uint32_t nbytes, uint32_t sum)
{
unsigned int i;
/* Checksum all the pairs of bytes first. */
for (i = 0; i < (nbytes & ~1U); i += 2) {
- sum += (u_int16_t)ntohs(*((u_int16_t *)(buf + i)));
+ sum += (uint16_t)ntohs(*((uint16_t *)(buf + i)));
if (sum > 0xFFFF)
sum -= 0xFFFF;
}
@@ -85,8 +85,8 @@ checksum(unsigned char *buf, u_int32_t nbytes, u_int32_t sum)
return (sum);
}
-u_int32_t
-wrapsum(u_int32_t sum)
+uint32_t
+wrapsum(uint32_t sum)
{
sum = ~sum & 0xFFFF;
return (htons(sum));
@@ -104,7 +104,7 @@ assemble_eh_header(struct ether_addr shost, struct ether_header *eh)
}
ssize_t
-decode_hw_header(unsigned char *buf, u_int32_t buflen, struct ether_addr *from)
+decode_hw_header(unsigned char *buf, uint32_t buflen, struct ether_addr *from)
{
struct ether_header eh;
@@ -119,21 +119,21 @@ decode_hw_header(unsigned char *buf, u_int32_t buflen, struct ether_addr *from)
}
ssize_t
-decode_udp_ip_header(unsigned char *buf, u_int32_t buflen,
+decode_udp_ip_header(unsigned char *buf, uint32_t buflen,
struct sockaddr_in *from)
{
- struct ip *ip;
- struct udphdr *udp;
- unsigned char *data;
- u_int32_t ip_len;
- u_int32_t sum, usum;
- static int ip_packets_seen;
- static int ip_packets_bad_checksum;
- static int udp_packets_seen;
- static int udp_packets_bad_checksum;
- static int udp_packets_length_checked;
- static int udp_packets_length_overflow;
- int len;
+ static int ip_packets_seen;
+ static int ip_packets_bad_checksum;
+ static int udp_packets_seen;
+ static int udp_packets_bad_checksum;
+ static int udp_packets_length_checked;
+ static int udp_packets_length_overflow;
+ struct ip *ip;
+ struct udphdr *udp;
+ unsigned char *data;
+ int len;
+ uint32_t ip_len;
+ uint32_t sum, usum;
/* Assure that an entire IP header is within the buffer. */
if (sizeof(*ip) > buflen)
@@ -211,7 +211,7 @@ decode_udp_ip_header(unsigned char *buf, u_int32_t buflen,
sum = wrapsum(checksum((unsigned char *)udp, sizeof(*udp),
checksum(data, len, checksum((unsigned char *)&ip->ip_src,
2 * sizeof(ip->ip_src),
- IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)))));
+ IPPROTO_UDP + (uint32_t)ntohs(udp->uh_ulen)))));
udp_packets_seen++;
if (usum && usum != sum) {
diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c
index d4e5da45501..a88469a0942 100644
--- a/sbin/dhclient/parse.c
+++ b/sbin/dhclient/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.54 2017/06/29 21:37:43 krw Exp $ */
+/* $OpenBSD: parse.c,v 1.55 2017/07/08 00:36:10 krw Exp $ */
/* Common parser code for dhcpd and dhclient. */
@@ -232,7 +232,7 @@ parse_ip_addr(FILE *cfile, struct in_addr *addr)
void
parse_lease_time(FILE *cfile, time_t *timep)
{
- u_int32_t value;
+ uint32_t value;
if (!parse_decimal(cfile, (char *)&value, 'L')) {
parse_warn("expecting unsigned 32-bit decimal value.");
diff --git a/sbin/dhclient/privsep.h b/sbin/dhclient/privsep.h
index c2b0ab4d149..d2873c6bad6 100644
--- a/sbin/dhclient/privsep.h
+++ b/sbin/dhclient/privsep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.h,v 1.42 2017/07/07 15:39:30 krw Exp $ */
+/* $OpenBSD: privsep.h,v 1.43 2017/07/08 00:36:10 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -60,8 +60,8 @@ void priv_flush_routes(char *, int, int);
char *resolv_conf_contents(char *, struct option_data *,
struct option_data *, struct option_data *);
-void write_resolv_conf(u_int8_t *, size_t);
-void priv_write_resolv_conf(u_int8_t *, size_t);
+void write_resolv_conf(uint8_t *, size_t);
+void priv_write_resolv_conf(uint8_t *, size_t);
void priv_delete_address(char *, int, struct imsg_delete_address *);
void priv_add_address(char *, int, struct imsg_add_address *);