Deleted Added
full compact
route.c (58032) route.c (58034)
1/*
2 * PPP Routing related Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
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 the Internet Initiative Japan, Inc. The name of the
14 * IIJ 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 *
1/*
2 * PPP Routing related Module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
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 the Internet Initiative Japan, Inc. The name of the
14 * IIJ 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 * $FreeBSD: head/usr.sbin/ppp/route.c 58032 2000-03-14 01:46:44Z brian $
20 * $FreeBSD: head/usr.sbin/ppp/route.c 58034 2000-03-14 01:46:54Z brian $
21 *
22 */
23
24#include <sys/param.h>
25#include <sys/socket.h>
26#include <net/if_types.h>
27#include <net/route.h>
28#include <net/if.h>

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

295 mib[2] = 0;
296 mib[3] = 0;
297 mib[4] = NET_RT_IFLIST;
298 mib[5] = 0;
299
300 if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
301 log_Printf(LogERROR, "Index2Nam: sysctl: estimate: %s\n",
302 strerror(errno));
21 *
22 */
23
24#include <sys/param.h>
25#include <sys/socket.h>
26#include <net/if_types.h>
27#include <net/route.h>
28#include <net/if.h>

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

295 mib[2] = 0;
296 mib[3] = 0;
297 mib[4] = NET_RT_IFLIST;
298 mib[5] = 0;
299
300 if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
301 log_Printf(LogERROR, "Index2Nam: sysctl: estimate: %s\n",
302 strerror(errno));
303 return "???";
303 return NumStr(idx, NULL, 0);
304 }
305 if ((buf = malloc(needed)) == NULL)
304 }
305 if ((buf = malloc(needed)) == NULL)
306 return "???";
306 return NumStr(idx, NULL, 0);
307 if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
308 free(buf);
307 if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) {
308 free(buf);
309 return "???";
309 return NumStr(idx, NULL, 0);
310 }
311 end = buf + needed;
312
313 have = 0;
314 for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) {
315 ifm = (struct if_msghdr *)ptr;
316 if (ifm->ifm_type != RTM_IFINFO)
317 break;

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

329 if (!newifs) {
330 log_Printf(LogDEBUG, "Index2Nam: %s\n", strerror(errno));
331 nifs = 0;
332 if (ifs) {
333 free(ifs);
334 ifs = NULL;
335 }
336 free(buf);
310 }
311 end = buf + needed;
312
313 have = 0;
314 for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) {
315 ifm = (struct if_msghdr *)ptr;
316 if (ifm->ifm_type != RTM_IFINFO)
317 break;

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

329 if (!newifs) {
330 log_Printf(LogDEBUG, "Index2Nam: %s\n", strerror(errno));
331 nifs = 0;
332 if (ifs) {
333 free(ifs);
334 ifs = NULL;
335 }
336 free(buf);
337 return "???";
337 return NumStr(idx, NULL, 0);
338 }
339 ifs = newifs;
340 memset(ifs + had, '\0', sizeof(char *) * (have - had));
341 }
342 if (ifs[ifm->ifm_index-1] == NULL) {
343 ifs[ifm->ifm_index-1] = (char *)malloc(dl->sdl_nlen+1);
344 memcpy(ifs[ifm->ifm_index-1], dl->sdl_data, dl->sdl_nlen);
345 ifs[ifm->ifm_index-1][dl->sdl_nlen] = '\0';

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

359 log_Printf(LogDEBUG, "Found the following interfaces:\n");
360 for (f = 0; f < nifs; f++)
361 if (ifs[f] != NULL)
362 log_Printf(LogDEBUG, " Index %d, name \"%s\"\n", f+1, ifs[f]);
363 debug_done = 1;
364 }
365
366 if (idx < 1 || idx > nifs || ifs[idx-1] == NULL)
338 }
339 ifs = newifs;
340 memset(ifs + had, '\0', sizeof(char *) * (have - had));
341 }
342 if (ifs[ifm->ifm_index-1] == NULL) {
343 ifs[ifm->ifm_index-1] = (char *)malloc(dl->sdl_nlen+1);
344 memcpy(ifs[ifm->ifm_index-1], dl->sdl_data, dl->sdl_nlen);
345 ifs[ifm->ifm_index-1][dl->sdl_nlen] = '\0';

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

359 log_Printf(LogDEBUG, "Found the following interfaces:\n");
360 for (f = 0; f < nifs; f++)
361 if (ifs[f] != NULL)
362 log_Printf(LogDEBUG, " Index %d, name \"%s\"\n", f+1, ifs[f]);
363 debug_done = 1;
364 }
365
366 if (idx < 1 || idx > nifs || ifs[idx-1] == NULL)
367 return "???";
367 return NumStr(idx, NULL, 0);
368
369 return ifs[idx-1];
370}
371
372void
373route_ParseHdr(struct rt_msghdr *rtm, struct sockaddr *sa[RTAX_MAX])
374{
375 char *wp;

--- 292 unchanged lines hidden ---
368
369 return ifs[idx-1];
370}
371
372void
373route_ParseHdr(struct rt_msghdr *rtm, struct sockaddr *sa[RTAX_MAX])
374{
375 char *wp;

--- 292 unchanged lines hidden ---