and sometimes uintNN_t.
-/* $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. */
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),
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),
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++;
-/* $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. */
#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 *);
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;
}
int
-parse_X(FILE *cfile, u_int8_t *buf, int max)
+parse_X(FILE *cfile, uint8_t *buf, int max)
{
int token;
char *val;
* 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;
{
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;
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 "
-/* $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>
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." */
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;
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);
-/* $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. */
#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). */
};
-/* $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>
struct option_data {
unsigned int len;
- u_int8_t *data;
+ uint8_t *data;
};
struct reject_elem {
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;
size_t rbuf_offset;
size_t rbuf_len;
int errors;
- u_int16_t index;
+ uint16_t index;
int linkstat;
int rdomain;
int flags;
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;
/* 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 *);
-/* $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>
* [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;
}
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);
-/* $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. */
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));
-/* $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. */
#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;
}
return (sum);
}
-u_int32_t
-wrapsum(u_int32_t sum)
+uint32_t
+wrapsum(uint32_t sum)
{
sum = ~sum & 0xFFFF;
return (htons(sum));
}
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;
}
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)
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) {
-/* $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. */
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.");
-/* $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>
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 *);