Deleted Added
sdiff udiff text old ( 28679 ) new ( 28974 )
full compact
1/*
2 * sys-bsd.c - System-dependent procedures for setting up
3 * PPP interfaces on bsd-4.4-ish systems (including 386BSD, NetBSD, etc.)
4 *
5 * Copyright (c) 1989 Carnegie Mellon University.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by Carnegie Mellon University. The name of the
14 * University may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: arp.c,v 1.13 1997/08/25 00:29:03 brian Exp $
21 *
22 */
23
24/*
25 * TODO:
26 */
27
28#include <sys/ioctl.h>

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

89 int routes;
90
91 /*
92 * Get the hardware address of an interface on the same subnet as our local
93 * address.
94 */
95 memset(&arpmsg, 0, sizeof(arpmsg));
96 if (!get_ether_addr(unit, hisaddr, &arpmsg.hwa)) {
97 LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
98 return 0;
99 }
100 if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
101 LogPrintf(LogERROR, "sifproxyarp: opening routing socket: %s\n",
102 strerror(errno));
103 return 0;
104 }
105 arpmsg.hdr.rtm_type = RTM_ADD;

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

180 }
181 arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
182 arpreq.arp_ha.sa_family = AF_UNSPEC;
183 BCOPY(LLADDR(&dls.sdl), arpreq.arp_ha.sa_data, dls.sdl.sdl_alen);
184 SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
185 ((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
186 arpreq.arp_flags = ATF_PERM | ATF_PUBL;
187 if (ioctl(unit, SIOCSARP, (caddr_t) & arpreq) < 0) {
188 LogPrintf(LogERROR, "sifproxyarp: ioctl(SIOCSARP): %s\n", strerror(errno));
189 return 0;
190 }
191 return 1;
192}
193
194/*
195 * cifproxyarp - Delete the proxy ARP entry for the peer.
196 */
197int
198cifproxyarp(int unit, u_long hisaddr)
199{
200 struct arpreq arpreq;
201
202 BZERO(&arpreq, sizeof(arpreq));
203 SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
204 ((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
205 if (ioctl(unit, SIOCDARP, (caddr_t) & arpreq) < 0) {
206 LogPrintf(LogERROR, "cifproxyarp: ioctl(SIOCDARP): %s\n", strerror(errno));
207 return 0;
208 }
209 return 1;
210}
211
212#endif /* RTM_VERSION */
213
214

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

226 struct sockaddr_dl *dla;
227 struct ifreq ifreq;
228 struct ifconf ifc;
229 struct ifreq ifs[MAX_IFS];
230
231 ifc.ifc_len = sizeof(ifs);
232 ifc.ifc_req = ifs;
233 if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
234 LogPrintf(LogERROR, "get_ether_addr: ioctl(SIOCGIFCONF): %s\n",
235 strerror(errno));
236 return 0;
237 }
238
239 /*
240 * Scan through looking for an interface with an Internet address on the
241 * same subnet as `ipaddr'.
242 */
243 ifend = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);

--- 169 unchanged lines hidden ---