Deleted Added
full compact
rarpd.c (238282) rarpd.c (246143)
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 8 unchanged lines hidden (view full) ---

17#if 0
18#ifndef lint
19static const char copyright[] =
20"@(#) Copyright (c) 1990, 1991, 1992, 1993, 1996\n\
21The Regents of the University of California. All rights reserved.\n";
22#endif /* not lint */
23#endif
24#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1990, 1991, 1992, 1993, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 8 unchanged lines hidden (view full) ---

17#if 0
18#ifndef lint
19static const char copyright[] =
20"@(#) Copyright (c) 1990, 1991, 1992, 1993, 1996\n\
21The Regents of the University of California. All rights reserved.\n";
22#endif /* not lint */
23#endif
24#include <sys/cdefs.h>
25__FBSDID("$FreeBSD: head/usr.sbin/rarpd/rarpd.c 238282 2012-07-09 08:11:16Z hrs $");
25__FBSDID("$FreeBSD: head/usr.sbin/rarpd/rarpd.c 246143 2013-01-31 08:55:21Z glebius $");
26
27/*
28 * rarpd - Reverse ARP Daemon
29 *
30 * Usage: rarpd -a [-dfsv] [-t directory] [-P pidfile] [hostname]
31 * rarpd [-dfsv] [-t directory] [-P pidfile] interface [hostname]
32 *
33 * 'hostname' is optional solely for backwards compatibility with Sun's rarpd.

--- 653 unchanged lines hidden (view full) ---

687}
688
689/*
690 * Poke the kernel arp tables with the ethernet/ip address combinataion
691 * given. When processing a reply, we must do this so that the booting
692 * host (i.e. the guy running rarpd), won't try to ARP for the hardware
693 * address of the guy being booted (he cannot answer the ARP).
694 */
26
27/*
28 * rarpd - Reverse ARP Daemon
29 *
30 * Usage: rarpd -a [-dfsv] [-t directory] [-P pidfile] [hostname]
31 * rarpd [-dfsv] [-t directory] [-P pidfile] interface [hostname]
32 *
33 * 'hostname' is optional solely for backwards compatibility with Sun's rarpd.

--- 653 unchanged lines hidden (view full) ---

687}
688
689/*
690 * Poke the kernel arp tables with the ethernet/ip address combinataion
691 * given. When processing a reply, we must do this so that the booting
692 * host (i.e. the guy running rarpd), won't try to ARP for the hardware
693 * address of the guy being booted (he cannot answer the ARP).
694 */
695struct sockaddr_inarp sin_inarp = {
696 sizeof(struct sockaddr_inarp), AF_INET, 0,
695struct sockaddr_in sin_inarp = {
696 sizeof(struct sockaddr_in), AF_INET, 0,
697 {0},
698 {0},
697 {0},
698 {0},
699 0, 0
700};
701struct sockaddr_dl sin_dl = {
702 sizeof(struct sockaddr_dl), AF_LINK, 0, IFT_ETHER, 0, 6,
703 0, ""
704};
705struct {
706 struct rt_msghdr rthdr;
707 char rtspace[512];
708} rtmsg;
709
710static void
711update_arptab(u_char *ep, in_addr_t ipaddr)
712{
713 struct timespec tp;
714 int cc;
699};
700struct sockaddr_dl sin_dl = {
701 sizeof(struct sockaddr_dl), AF_LINK, 0, IFT_ETHER, 0, 6,
702 0, ""
703};
704struct {
705 struct rt_msghdr rthdr;
706 char rtspace[512];
707} rtmsg;
708
709static void
710update_arptab(u_char *ep, in_addr_t ipaddr)
711{
712 struct timespec tp;
713 int cc;
715 struct sockaddr_inarp *ar, *ar2;
714 struct sockaddr_in *ar, *ar2;
716 struct sockaddr_dl *ll, *ll2;
717 struct rt_msghdr *rt;
718 int xtype, xindex;
719 static pid_t pid;
720 int r;
721 static int seq;
722
723 r = socket(PF_ROUTE, SOCK_RAW, 0);

--- 11 unchanged lines hidden (view full) ---

735
736 /* Get the type and interface index */
737 rt = &rtmsg.rthdr;
738 bzero(rt, sizeof(rtmsg));
739 rt->rtm_version = RTM_VERSION;
740 rt->rtm_addrs = RTA_DST;
741 rt->rtm_type = RTM_GET;
742 rt->rtm_seq = ++seq;
715 struct sockaddr_dl *ll, *ll2;
716 struct rt_msghdr *rt;
717 int xtype, xindex;
718 static pid_t pid;
719 int r;
720 static int seq;
721
722 r = socket(PF_ROUTE, SOCK_RAW, 0);

--- 11 unchanged lines hidden (view full) ---

734
735 /* Get the type and interface index */
736 rt = &rtmsg.rthdr;
737 bzero(rt, sizeof(rtmsg));
738 rt->rtm_version = RTM_VERSION;
739 rt->rtm_addrs = RTA_DST;
740 rt->rtm_type = RTM_GET;
741 rt->rtm_seq = ++seq;
743 ar2 = (struct sockaddr_inarp *)rtmsg.rtspace;
742 ar2 = (struct sockaddr_in *)rtmsg.rtspace;
744 bcopy(ar, ar2, sizeof(*ar));
745 rt->rtm_msglen = sizeof(*rt) + sizeof(*ar);
746 errno = 0;
747 if ((write(r, rt, rt->rtm_msglen) == -1) && (errno != ESRCH)) {
748 logmsg(LOG_ERR, "rtmsg get write: %m");
749 close(r);
750 return;
751 }

--- 247 unchanged lines hidden ---
743 bcopy(ar, ar2, sizeof(*ar));
744 rt->rtm_msglen = sizeof(*rt) + sizeof(*ar);
745 errno = 0;
746 if ((write(r, rt, rt->rtm_msglen) == -1) && (errno != ESRCH)) {
747 logmsg(LOG_ERR, "rtmsg get write: %m");
748 close(r);
749 return;
750 }

--- 247 unchanged lines hidden ---