diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/bpf.c | 28 | ||||
-rw-r--r-- | sbin/dhclient/clparse.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/dhclient.c | 12 | ||||
-rw-r--r-- | sbin/dhclient/dhcpd.h | 4 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 29 | ||||
-rw-r--r-- | sbin/dhclient/inet.c | 6 | ||||
-rw-r--r-- | sbin/dhclient/options.c | 5 |
7 files changed, 42 insertions, 48 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c index 5d4b5fcdbc8..64d8c5f0077 100644 --- a/sbin/dhclient/bpf.c +++ b/sbin/dhclient/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.9 2004/02/24 17:26:43 henning Exp $ */ +/* $OpenBSD: bpf.c,v 1.10 2004/03/02 18:49:21 deraadt Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -60,8 +60,8 @@ int if_register_bpf(struct interface_info *info) { - int sock, b; - char filename[50]; + char filename[50]; + int sock, b; /* Open a BPF device */ for (b = 0; 1; b++) { @@ -118,7 +118,7 @@ struct bpf_insn dhcp_bpf_filter[] = { /* Make sure it's to the right port... */ BPF_STMT(BPF_LD + BPF_H + BPF_IND, 16), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 67, 0, 1), /* patch */ + 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), @@ -132,9 +132,9 @@ int dhcp_bpf_filter_len = sizeof(dhcp_bpf_filter) / sizeof(struct bpf_insn); void if_register_receive(struct interface_info *info) { - int flag = 1, sz; - struct bpf_version v; - struct bpf_program p; + struct bpf_version v; + struct bpf_program p; + int flag = 1, sz; /* Open a BPF device and hang it on this interface... */ info->rfdesc = if_register_bpf(info); @@ -186,10 +186,9 @@ send_packet(struct interface_info *interface, struct packet *packet, struct dhcp_packet *raw, size_t len, struct in_addr from, struct sockaddr_in *to, struct hardware *hto) { - int bufp = 0; - unsigned char buf[256]; - struct iovec iov[2]; - int result; + unsigned char buf[256]; + struct iovec iov[2]; + int result, bufp = 0; /* Assemble the headers... */ assemble_hw_header(interface, buf, &bufp, hto); @@ -212,9 +211,8 @@ ssize_t receive_packet(struct interface_info *interface, unsigned char *buf, size_t len, struct sockaddr_in *from, struct hardware *hfrom) { - int length = 0; - int offset = 0; - struct bpf_hdr hdr; + int length = 0, offset = 0; + struct bpf_hdr hdr; /* * All this complexity is because BPF doesn't guarantee that @@ -315,7 +313,7 @@ receive_packet(struct interface_info *interface, unsigned char *buf, /* Copy out the data in the packet... */ memcpy(buf, interface->rbuf + interface->rbuf_offset, - hdr.bh_caplen); + hdr.bh_caplen); interface->rbuf_offset += hdr.bh_caplen; return (hdr.bh_caplen); } while (!length); diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 4bc419a2dea..751f80f5d29 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.11 2004/03/02 15:41:44 henning Exp $ */ +/* $OpenBSD: clparse.c,v 1.12 2004/03/02 18:49:21 deraadt Exp $ */ /* Parser for dhclient config and lease files... */ @@ -538,7 +538,7 @@ parse_client_lease_statement(FILE *cfile, int is_static) for (lp = ip->client->leases; lp; lp = lp->next) { if (lp->address.len == lease->address.len && !memcmp(lp->address.iabuf, lease->address.iabuf, - lease->address.len)) { + lease->address.len)) { if (pl) pl->next = lp->next; else @@ -838,7 +838,7 @@ bad_flag: goto alloc; default: warn("Bad format %c in parse_option_param.", - *fmt); + *fmt); skip_to_semi(cfile); return (NULL); } diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 1026cb8a04e..1df475d0764 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.29 2004/03/02 15:58:41 henning Exp $ */ +/* $OpenBSD: dhclient.c,v 1.30 2004/03/02 18:49:21 deraadt Exp $ */ /* DHCP Client. */ @@ -643,7 +643,7 @@ bootp(struct packet *packet) /* If there's a reject list, make sure this packet's sender isn't on it. */ for (ap = packet->interface->client->config->reject_list; - ap; ap = ap->next) { + ap; ap = ap->next) { if (addr_eq(packet->client_addr, ap->addr)) { note("BOOTREPLY from %s rejected.", piaddr(ap->addr)); return; @@ -679,7 +679,7 @@ dhcp(struct packet *packet) /* If there's a reject list, make sure this packet's sender isn't on it. */ for (ap = packet->interface->client->config->reject_list; - ap; ap = ap->next) { + ap; ap = ap->next) { if (addr_eq(packet->client_addr, ap->addr)) { note("%s from %s rejected.", type, piaddr(ap->addr)); return; @@ -722,7 +722,7 @@ dhcpoffer(struct packet *packet) /* If we've already seen this lease, don't record it again. */ for (lease = ip->client->offered_leases; - lease; lease = lease->next) { + lease; lease = lease->next) { if (lease->address.len == sizeof(packet->raw->yiaddr) && !memcmp(lease->address.iabuf, &packet->raw->yiaddr, lease->address.len)) { @@ -842,7 +842,7 @@ packet_to_lease(struct packet *packet) 0; } if (!check_option(lease,i)) { - /* ignore a bogus lease offer */ + /* ignore a bogus lease offer */ warn("Invalid lease option - ignoring offer"); free_client_lease(lease); return (NULL); @@ -877,7 +877,7 @@ packet_to_lease(struct packet *packet) if ((!packet->options[DHO_DHCP_OPTION_OVERLOAD].len || !(packet->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 1)) && packet->raw->file[0]) { - /* Don't count on the NUL terminator. */ + /* Don't count on the NUL terminator. */ lease->filename = malloc(DHCP_FILE_LEN + 1); if (!lease->filename) { warn("dhcpoffer: no memory for filename."); diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h index af2741dc003..65e4269ca44 100644 --- a/sbin/dhclient/dhcpd.h +++ b/sbin/dhclient/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.24 2004/03/02 15:41:44 henning Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.25 2004/03/02 18:49:21 deraadt Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -62,8 +62,6 @@ #include <netdb.h> #include <paths.h> #include <unistd.h> -#include <setjmp.h> -#include <signal.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index b10b2715014..f2eee05921c 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.21 2004/03/02 13:39:44 henning Exp $ */ +/* $OpenBSD: dispatch.c,v 1.22 2004/03/02 18:49:21 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -52,8 +52,8 @@ struct timeout *timeouts; static struct timeout *free_timeouts; static int interfaces_invalidated; void (*bootp_packet_handler)(struct interface_info *, - struct dhcp_packet *, int, unsigned int, - struct iaddr, struct hardware *); + struct dhcp_packet *, int, unsigned int, + struct iaddr, struct hardware *); static int interface_status(struct interface_info *ifinfo); @@ -67,8 +67,8 @@ void discover_interfaces(struct interface_info *iface) { struct sockaddr_in foo; - struct ifreq *tif; struct ifaddrs *ifap, *ifa; + struct ifreq *tif; if (getifaddrs(&ifap) != 0) error("getifaddrs failed"); @@ -141,13 +141,10 @@ reinitialize_interfaces(void) void dispatch(void) { + int count, i, to_msec, nfds = 0; struct protocol *l; - int nfds = 0; struct pollfd *fds; - int count; - int i; time_t howlong; - int to_msec; nfds = 0; for (l = protocols; l; l = l->next) @@ -226,7 +223,7 @@ another: if ((fds[i].revents & POLLIN)) { fds[i].revents = 0; if (ip && (l->handler != got_one || - !ip->dead)) + !ip->dead)) (*(l->handler))(l); if (interfaces_invalidated) break; @@ -255,8 +252,8 @@ got_one(struct protocol *l) } u; struct interface_info *ip = l->local; - if ((result = - receive_packet(ip, u.packbuf, sizeof(u), &from, &hfrom)) == -1) { + if ((result = receive_packet(ip, u.packbuf, sizeof(u), &from, + &hfrom)) == -1) { warn("receive_packet failed on %s: %s", ip->name, strerror(errno)); ip->errors++; @@ -264,7 +261,7 @@ got_one(struct protocol *l) (ip->noifmedia && ip->errors > 20)) { /* our interface has gone away. */ warn("Interface %s no longer appears valid.", - ip->name); + ip->name); ip->dead = 1; interfaces_invalidated = 1; close(l->fd); @@ -316,6 +313,7 @@ interface_status(struct interface_info *ifinfo) if (errno != EINVAL) { syslog(LOG_DEBUG, "ioctl(SIOCGIFMEDIA) on %s: %m", ifname); + ifinfo->noifmedia = 1; goto active; } @@ -443,7 +441,6 @@ add_protocol(char *name, int fd, void (*handler)(struct protocol *), p->fd = fd; p->handler = handler; p->local = local; - p->next = protocols; protocols = p; } @@ -469,8 +466,8 @@ remove_protocol(struct protocol *proto) int interface_link_status(char *ifname) { - int sock; struct ifmediareq ifmr; + int sock; if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) == -1) error("Can't create socket"); @@ -487,13 +484,13 @@ interface_link_status(char *ifname) } close(sock); - if (ifmr.ifm_status & IFM_AVALID) + if (ifmr.ifm_status & IFM_AVALID) { if ((ifmr.ifm_active & IFM_NMASK) == IFM_ETHER) { if (ifmr.ifm_status & IFM_ACTIVE) return (1); else return (0); } - + } return (1); } diff --git a/sbin/dhclient/inet.c b/sbin/dhclient/inet.c index 20494bd500a..42466bc6f32 100644 --- a/sbin/dhclient/inet.c +++ b/sbin/dhclient/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.4 2004/02/07 13:26:35 henning Exp $ */ +/* $OpenBSD: inet.c,v 1.5 2004/03/02 18:49:21 deraadt Exp $ */ /* * Subroutines to manipulate internet addresses in a safely portable @@ -50,8 +50,8 @@ struct iaddr subnet_number(struct iaddr addr, struct iaddr mask) { - int i; struct iaddr rv; + int i; rv.len = 0; @@ -75,8 +75,8 @@ ip_addr(struct iaddr subnet, struct iaddr mask, u_int32_t host_address) { int i, j, k; u_int32_t swaddr; - struct iaddr rv; unsigned char habuf[sizeof(swaddr)]; + struct iaddr rv; swaddr = htonl(host_address); memcpy(habuf, &swaddr, sizeof(swaddr)); diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index b1e4bb425a5..ad3d70489b2 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.6 2004/02/24 17:02:40 henning Exp $ */ +/* $OpenBSD: options.c,v 1.7 2004/03/02 18:49:21 deraadt Exp $ */ /* DHCP options parsing and reassembly. */ @@ -74,7 +74,8 @@ parse_options(struct packet *packet) * the End field. */ parse_option_buffer(packet, &packet->raw->options[4], - packet->packet_length - DHCP_FIXED_NON_UDP - 4); + packet->packet_length - DHCP_FIXED_NON_UDP - 4); + /* * If we parsed a DHCP Option Overload option, parse more * options out of the buffer(s) containing them. |