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.12 1997/06/09 03:27:11 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"
98 " for proxy ARP\n");
99 return 0;
100 }
101 if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
102 LogPrintf(LogERROR, "sifproxyarp: opening routing socket: %s\n",
103 strerror(errno));
104 return 0;
105 }
106 arpmsg.hdr.rtm_type = RTM_ADD;

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

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

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

227 struct sockaddr_dl *dla;
228 struct ifreq ifreq;
229 struct ifconf ifc;
230 struct ifreq ifs[MAX_IFS];
231
232 ifc.ifc_len = sizeof(ifs);
233 ifc.ifc_req = ifs;
234 if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
235 LogPrintf(LogERROR, "get_ether_addr: ioctl(SIOCGIFCONF): \n");
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 ---