static + __printflike + __dead

This commit is contained in:
joerg 2011-08-30 20:25:18 +00:00
parent 9b838647dd
commit 76d8a55bb7
2 changed files with 41 additions and 44 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkarp.c,v 1.8 2009/04/18 08:50:23 lukem Exp $ */
/* $NetBSD: mkarp.c,v 1.9 2011/08/30 20:25:18 joerg Exp $ */
/*
* Copyright (c) 1984, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 1993\
#if 0
static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: mkarp.c,v 1.8 2009/04/18 08:50:23 lukem Exp $");
__RCSID("$NetBSD: mkarp.c,v 1.9 2011/08/30 20:25:18 joerg Exp $");
#endif
#endif /* not lint */
@ -82,7 +82,7 @@ __RCSID("$NetBSD: mkarp.c,v 1.8 2009/04/18 08:50:23 lukem Exp $");
int rtmsg(int, int, struct rt_msghdr *, struct sockaddr_inarp *,
struct sockaddr_dl *);
struct {
static struct {
struct rt_msghdr m_rtm;
char m_space[512];
} m_rtmsg;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rarpd.c,v 1.58 2009/04/18 08:50:23 lukem Exp $ */
/* $NetBSD: rarpd.c,v 1.59 2011/08/30 20:25:18 joerg Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@ -25,7 +25,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990\
#endif /* not lint */
#ifndef lint
__RCSID("$NetBSD: rarpd.c,v 1.58 2009/04/18 08:50:23 lukem Exp $");
__RCSID("$NetBSD: rarpd.c,v 1.59 2011/08/30 20:25:18 joerg Exp $");
#endif
@ -89,44 +89,41 @@ struct if_info {
* The list of all interfaces that are being listened to. rarp_loop()
* "selects" on the descriptors in this list.
*/
struct if_info *iflist;
static struct if_info *iflist;
u_int32_t choose_ipaddr(u_int32_t **, u_int32_t, u_int32_t);
void debug(const char *,...)
__attribute__((__format__(__printf__, 1, 2)));
void init_some(char *name);
void init_one(char *, u_int32_t);
u_int32_t ipaddrtonetmask(u_int32_t);
void lookup_eaddr(char *, u_char *);
void lookup_ipaddr(char *, u_int32_t *, u_int32_t *);
int main(int, char **);
void rarp_loop(void);
int rarp_open(char *);
void rarp_process(struct if_info *, u_char *);
void rarp_reply(struct if_info *, struct ether_header *, u_int32_t,
struct hostent *);
void rarperr(int, const char *,...)
__attribute__((__format__(__printf__, 2, 3)));
static u_int32_t choose_ipaddr(u_int32_t **, u_int32_t, u_int32_t);
static void debug(const char *,...) __printflike(1, 2);
static void init_some(char *name);
static void init_one(char *, u_int32_t);
static u_int32_t ipaddrtonetmask(u_int32_t);
static void lookup_eaddr(char *, u_char *);
static void lookup_ipaddr(char *, u_int32_t *, u_int32_t *);
static void rarp_loop(void) __dead;
static int rarp_open(char *);
static void rarp_process(struct if_info *, u_char *);
static void rarp_reply(struct if_info *, struct ether_header *, u_int32_t,
struct hostent *);
static void rarperr(int, const char *,...) __printflike(2, 3);
#if defined(__NetBSD__)
#include "mkarp.h"
#else
void update_arptab(u_char *, u_int32_t);
static void update_arptab(u_char *, u_int32_t);
#endif
void usage(void);
__dead static void usage(void);
static int bpf_open(void);
static int rarp_check(u_char *, int);
#ifdef REQUIRE_TFTPBOOT
int rarp_bootable(u_int32_t);
static int rarp_bootable(u_int32_t);
#endif
int aflag = 0; /* listen on "all" interfaces */
int dflag = 0; /* print debugging messages */
int fflag = 0; /* don't fork */
int lflag = 0; /* log all replies */
static int aflag = 0; /* listen on "all" interfaces */
static int dflag = 0; /* print debugging messages */
static int fflag = 0; /* don't fork */
static int lflag = 0; /* log all replies */
int
main(int argc, char **argv)
@ -189,7 +186,7 @@ main(int argc, char **argv)
* Add 'ifname' to the interface list. Lookup its IP address and network
* mask and Ethernet address, and open a BPF file for it.
*/
void
static void
init_one(char *ifname, u_int32_t ipaddr)
{
struct if_info *h;
@ -237,7 +234,7 @@ init_one(char *ifname, u_int32_t ipaddr)
* configuration list. A "candidate" is up, not loopback and not
* point to point.
*/
void
static void
init_some(char *name)
{
struct ifaddrs *ifap, *ifa, *p;
@ -267,7 +264,7 @@ init_some(char *name)
freeifaddrs(ifap);
}
void
static void
usage(void)
{
(void) fprintf(stderr, "Usage: %s -a [-d|-f] [-l]\n", getprogname());
@ -293,7 +290,7 @@ bpf_open(void)
* Open a BPF file and attach it to the interface named 'device'.
* Set immediate mode, and set a filter that accepts only RARP requests.
*/
int
static int
rarp_open(char *device)
{
int fd;
@ -434,7 +431,7 @@ rarp_check(u_char *p, int len)
* Loop indefinitely listening for RARP requests on the
* interfaces in 'iflist'.
*/
void
static void
rarp_loop(void)
{
u_char *buf, *bp, *ep;
@ -524,7 +521,7 @@ rarp_loop(void)
* This check is made by looking in the tftp directory for the
* configuration file.
*/
int
static int
rarp_bootable(u_int32_t addr)
{
struct dirent *dent;
@ -560,7 +557,7 @@ rarp_bootable(u_int32_t addr)
* is on network 'net'; 'netmask' is a mask indicating the network portion
* of the address.
*/
u_int32_t
static u_int32_t
choose_ipaddr(u_int32_t **alist, u_int32_t net, u_int32_t netmask)
{
@ -574,7 +571,7 @@ choose_ipaddr(u_int32_t **alist, u_int32_t net, u_int32_t netmask)
* Answer the RARP request in 'pkt', on the interface 'ii'. 'pkt' has
* already been checked for validity. The reply is overlaid on the request.
*/
void
static void
rarp_process(struct if_info *ii, u_char *pkt)
{
struct ether_header *ep;
@ -631,7 +628,7 @@ rarp_process(struct if_info *ii, u_char *pkt)
* Lookup the ethernet address of the interface attached to the BPF
* file descriptor 'fd'; return it in 'eaddr'.
*/
void
static void
lookup_eaddr(char *ifname, u_char *eaddr)
{
struct ifaddrs *ifap, *ifa;
@ -662,7 +659,7 @@ lookup_eaddr(char *ifname, u_char *eaddr)
/*
* Lookup the IP address and network mask of the interface named 'ifname'.
*/
void
static void
lookup_ipaddr(char *ifname, u_int32_t *addrp, u_int32_t *netmaskp)
{
int fd;
@ -713,7 +710,7 @@ lookup_ipaddr(char *ifname, u_int32_t *addrp, u_int32_t *netmaskp)
* address of the guy being booted (he cannot answer the ARP).
*/
#ifndef __NetBSD__
void
static void
update_arptab(u_char *ep, u_int32_t ipaddr)
{
struct arpreq request;
@ -773,7 +770,7 @@ update_arptab(u_char *ep, u_int32_t ipaddr)
* address pair (arp_spa, arp_sha) may eliminate the need for a subsequent
* ARP request.
*/
void
static void
rarp_reply(struct if_info *ii, struct ether_header *ep, u_int32_t ipaddr,
struct hostent *hp)
{
@ -844,7 +841,7 @@ rarp_reply(struct if_info *ii, struct ether_header *ep, u_int32_t ipaddr,
* Get the netmask of an IP address. This routine is used if
* SIOCGIFNETMASK doesn't work.
*/
u_int32_t
static u_int32_t
ipaddrtonetmask(u_int32_t addr)
{
@ -861,7 +858,7 @@ ipaddrtonetmask(u_int32_t addr)
#include <stdarg.h>
void
static void
rarperr(int fatal, const char *fmt,...)
{
va_list ap;
@ -884,7 +881,7 @@ rarperr(int fatal, const char *fmt,...)
/* NOTREACHED */
}
void
static void
debug(const char *fmt,...)
{
va_list ap;