static + __printflike + __dead
This commit is contained in:
parent
9b838647dd
commit
76d8a55bb7
|
@ -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
|
* Copyright (c) 1984, 1993
|
||||||
|
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1984, 1993\
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95";
|
static char sccsid[] = "@(#)arp.c 8.3 (Berkeley) 4/28/95";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#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 *,
|
int rtmsg(int, int, struct rt_msghdr *, struct sockaddr_inarp *,
|
||||||
struct sockaddr_dl *);
|
struct sockaddr_dl *);
|
||||||
struct {
|
static struct {
|
||||||
struct rt_msghdr m_rtm;
|
struct rt_msghdr m_rtm;
|
||||||
char m_space[512];
|
char m_space[512];
|
||||||
} m_rtmsg;
|
} m_rtmsg;
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1990 The Regents of the University of California.
|
||||||
|
@ -25,7 +25,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990\
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef 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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,44 +89,41 @@ struct if_info {
|
||||||
* The list of all interfaces that are being listened to. rarp_loop()
|
* The list of all interfaces that are being listened to. rarp_loop()
|
||||||
* "selects" on the descriptors in this list.
|
* "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);
|
static u_int32_t choose_ipaddr(u_int32_t **, u_int32_t, u_int32_t);
|
||||||
void debug(const char *,...)
|
static void debug(const char *,...) __printflike(1, 2);
|
||||||
__attribute__((__format__(__printf__, 1, 2)));
|
static void init_some(char *name);
|
||||||
void init_some(char *name);
|
static void init_one(char *, u_int32_t);
|
||||||
void init_one(char *, u_int32_t);
|
static u_int32_t ipaddrtonetmask(u_int32_t);
|
||||||
u_int32_t ipaddrtonetmask(u_int32_t);
|
static void lookup_eaddr(char *, u_char *);
|
||||||
void lookup_eaddr(char *, u_char *);
|
static void lookup_ipaddr(char *, u_int32_t *, u_int32_t *);
|
||||||
void lookup_ipaddr(char *, u_int32_t *, u_int32_t *);
|
static void rarp_loop(void) __dead;
|
||||||
int main(int, char **);
|
static int rarp_open(char *);
|
||||||
void rarp_loop(void);
|
static void rarp_process(struct if_info *, u_char *);
|
||||||
int rarp_open(char *);
|
static void rarp_reply(struct if_info *, struct ether_header *, u_int32_t,
|
||||||
void rarp_process(struct if_info *, u_char *);
|
struct hostent *);
|
||||||
void rarp_reply(struct if_info *, struct ether_header *, u_int32_t,
|
static void rarperr(int, const char *,...) __printflike(2, 3);
|
||||||
struct hostent *);
|
|
||||||
void rarperr(int, const char *,...)
|
|
||||||
__attribute__((__format__(__printf__, 2, 3)));
|
|
||||||
|
|
||||||
#if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
#include "mkarp.h"
|
#include "mkarp.h"
|
||||||
#else
|
#else
|
||||||
void update_arptab(u_char *, u_int32_t);
|
static void update_arptab(u_char *, u_int32_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void usage(void);
|
__dead static void usage(void);
|
||||||
|
|
||||||
static int bpf_open(void);
|
static int bpf_open(void);
|
||||||
static int rarp_check(u_char *, int);
|
static int rarp_check(u_char *, int);
|
||||||
|
|
||||||
#ifdef REQUIRE_TFTPBOOT
|
#ifdef REQUIRE_TFTPBOOT
|
||||||
int rarp_bootable(u_int32_t);
|
static int rarp_bootable(u_int32_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int aflag = 0; /* listen on "all" interfaces */
|
static int aflag = 0; /* listen on "all" interfaces */
|
||||||
int dflag = 0; /* print debugging messages */
|
static int dflag = 0; /* print debugging messages */
|
||||||
int fflag = 0; /* don't fork */
|
static int fflag = 0; /* don't fork */
|
||||||
int lflag = 0; /* log all replies */
|
static int lflag = 0; /* log all replies */
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
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
|
* Add 'ifname' to the interface list. Lookup its IP address and network
|
||||||
* mask and Ethernet address, and open a BPF file for it.
|
* mask and Ethernet address, and open a BPF file for it.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
init_one(char *ifname, u_int32_t ipaddr)
|
init_one(char *ifname, u_int32_t ipaddr)
|
||||||
{
|
{
|
||||||
struct if_info *h;
|
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
|
* configuration list. A "candidate" is up, not loopback and not
|
||||||
* point to point.
|
* point to point.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
init_some(char *name)
|
init_some(char *name)
|
||||||
{
|
{
|
||||||
struct ifaddrs *ifap, *ifa, *p;
|
struct ifaddrs *ifap, *ifa, *p;
|
||||||
|
@ -267,7 +264,7 @@ init_some(char *name)
|
||||||
freeifaddrs(ifap);
|
freeifaddrs(ifap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
(void) fprintf(stderr, "Usage: %s -a [-d|-f] [-l]\n", getprogname());
|
(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'.
|
* Open a BPF file and attach it to the interface named 'device'.
|
||||||
* Set immediate mode, and set a filter that accepts only RARP requests.
|
* Set immediate mode, and set a filter that accepts only RARP requests.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
rarp_open(char *device)
|
rarp_open(char *device)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -434,7 +431,7 @@ rarp_check(u_char *p, int len)
|
||||||
* Loop indefinitely listening for RARP requests on the
|
* Loop indefinitely listening for RARP requests on the
|
||||||
* interfaces in 'iflist'.
|
* interfaces in 'iflist'.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
rarp_loop(void)
|
rarp_loop(void)
|
||||||
{
|
{
|
||||||
u_char *buf, *bp, *ep;
|
u_char *buf, *bp, *ep;
|
||||||
|
@ -524,7 +521,7 @@ rarp_loop(void)
|
||||||
* This check is made by looking in the tftp directory for the
|
* This check is made by looking in the tftp directory for the
|
||||||
* configuration file.
|
* configuration file.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
rarp_bootable(u_int32_t addr)
|
rarp_bootable(u_int32_t addr)
|
||||||
{
|
{
|
||||||
struct dirent *dent;
|
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
|
* is on network 'net'; 'netmask' is a mask indicating the network portion
|
||||||
* of the address.
|
* of the address.
|
||||||
*/
|
*/
|
||||||
u_int32_t
|
static u_int32_t
|
||||||
choose_ipaddr(u_int32_t **alist, u_int32_t net, u_int32_t netmask)
|
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
|
* Answer the RARP request in 'pkt', on the interface 'ii'. 'pkt' has
|
||||||
* already been checked for validity. The reply is overlaid on the request.
|
* already been checked for validity. The reply is overlaid on the request.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
rarp_process(struct if_info *ii, u_char *pkt)
|
rarp_process(struct if_info *ii, u_char *pkt)
|
||||||
{
|
{
|
||||||
struct ether_header *ep;
|
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
|
* Lookup the ethernet address of the interface attached to the BPF
|
||||||
* file descriptor 'fd'; return it in 'eaddr'.
|
* file descriptor 'fd'; return it in 'eaddr'.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
lookup_eaddr(char *ifname, u_char *eaddr)
|
lookup_eaddr(char *ifname, u_char *eaddr)
|
||||||
{
|
{
|
||||||
struct ifaddrs *ifap, *ifa;
|
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'.
|
* 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)
|
lookup_ipaddr(char *ifname, u_int32_t *addrp, u_int32_t *netmaskp)
|
||||||
{
|
{
|
||||||
int fd;
|
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).
|
* address of the guy being booted (he cannot answer the ARP).
|
||||||
*/
|
*/
|
||||||
#ifndef __NetBSD__
|
#ifndef __NetBSD__
|
||||||
void
|
static void
|
||||||
update_arptab(u_char *ep, u_int32_t ipaddr)
|
update_arptab(u_char *ep, u_int32_t ipaddr)
|
||||||
{
|
{
|
||||||
struct arpreq request;
|
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
|
* address pair (arp_spa, arp_sha) may eliminate the need for a subsequent
|
||||||
* ARP request.
|
* ARP request.
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
rarp_reply(struct if_info *ii, struct ether_header *ep, u_int32_t ipaddr,
|
rarp_reply(struct if_info *ii, struct ether_header *ep, u_int32_t ipaddr,
|
||||||
struct hostent *hp)
|
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
|
* Get the netmask of an IP address. This routine is used if
|
||||||
* SIOCGIFNETMASK doesn't work.
|
* SIOCGIFNETMASK doesn't work.
|
||||||
*/
|
*/
|
||||||
u_int32_t
|
static u_int32_t
|
||||||
ipaddrtonetmask(u_int32_t addr)
|
ipaddrtonetmask(u_int32_t addr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -861,7 +858,7 @@ ipaddrtonetmask(u_int32_t addr)
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
void
|
static void
|
||||||
rarperr(int fatal, const char *fmt,...)
|
rarperr(int fatal, const char *fmt,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -884,7 +881,7 @@ rarperr(int fatal, const char *fmt,...)
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
debug(const char *fmt,...)
|
debug(const char *fmt,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
Loading…
Reference in New Issue