mirror of https://github.com/F-Stack/f-stack.git
feature: add ndp tool for ipv6 neighbor
This commit is contained in:
parent
83438cffc0
commit
ebf5cedb54
|
@ -1,4 +1,4 @@
|
||||||
SUBDIRS=compat libutil libmemstat libxo libnetgraph sysctl ifconfig route top netstat ngctl ipfw arp traffic knictl
|
SUBDIRS=compat libutil libmemstat libxo libnetgraph sysctl ifconfig route top netstat ngctl ipfw arp traffic knictl ndp
|
||||||
PREFIX_BIN=/usr/local/bin
|
PREFIX_BIN=/usr/local/bin
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
@ -12,6 +12,7 @@ install:
|
||||||
|
|
||||||
cp -rf sbin/ ${PREFIX_BIN}/f-stack
|
cp -rf sbin/ ${PREFIX_BIN}/f-stack
|
||||||
ln -sf ${PREFIX_BIN}/f-stack/arp ${PREFIX_BIN}/ff_arp
|
ln -sf ${PREFIX_BIN}/f-stack/arp ${PREFIX_BIN}/ff_arp
|
||||||
|
ln -sf ${PREFIX_BIN}/f-stack/ndp ${PREFIX_BIN}/ff_ndp
|
||||||
ln -sf ${PREFIX_BIN}/f-stack/ifconfig ${PREFIX_BIN}/ff_ifconfig
|
ln -sf ${PREFIX_BIN}/f-stack/ifconfig ${PREFIX_BIN}/ff_ifconfig
|
||||||
ln -sf ${PREFIX_BIN}/f-stack/ipfw ${PREFIX_BIN}/ff_ipfw
|
ln -sf ${PREFIX_BIN}/f-stack/ipfw ${PREFIX_BIN}/ff_ipfw
|
||||||
ln -sf ${PREFIX_BIN}/f-stack/netstat ${PREFIX_BIN}/ff_netstat
|
ln -sf ${PREFIX_BIN}/f-stack/netstat ${PREFIX_BIN}/ff_netstat
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef FSTACK
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include "namespace.h"
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/sockio.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_dl.h>
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#ifndef FSTACK
|
||||||
|
#include "un-namespace.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char *
|
||||||
|
if_indextoname(unsigned int ifindex, char *ifname)
|
||||||
|
{
|
||||||
|
struct ifaddrs *ifaddrs, *ifa;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
if (ifindex == 0) {
|
||||||
|
errno = ENXIO;
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getifaddrs(&ifaddrs) < 0)
|
||||||
|
return(NULL); /* getifaddrs properly set errno */
|
||||||
|
|
||||||
|
for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) {
|
||||||
|
if (ifa->ifa_addr &&
|
||||||
|
ifa->ifa_addr->sa_family == AF_LINK &&
|
||||||
|
ifindex == LLINDEX((struct sockaddr_dl*)ifa->ifa_addr))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ifa == NULL) {
|
||||||
|
error = ENXIO;
|
||||||
|
ifname = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strncpy(ifname, ifa->ifa_name, IFNAMSIZ);
|
||||||
|
|
||||||
|
freeifaddrs(ifaddrs);
|
||||||
|
|
||||||
|
errno = error;
|
||||||
|
return(ifname);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright (c) 1996 WIDE Project. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modifications, are permitted provided that the above copyright notice
|
||||||
|
# and this paragraph are duplicated in all such forms and that any
|
||||||
|
# documentation, advertising materials, and other materials related to
|
||||||
|
# such distribution and use acknowledge that the software was developed
|
||||||
|
# by the WIDE Project, Japan. The name of the Project may not be used to
|
||||||
|
# endorse or promote products derived from this software without
|
||||||
|
# specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS''
|
||||||
|
# AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
||||||
|
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE.
|
||||||
|
# $FreeBSD: releng/11.0/usr.sbin/ndp/Makefile 201390 2010-01-02 11:07:44Z ed $
|
||||||
|
|
||||||
|
|
||||||
|
TOPDIR?=${CURDIR}/../..
|
||||||
|
|
||||||
|
PROG=ndp
|
||||||
|
|
||||||
|
include ${TOPDIR}/tools/prog.mk
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue