View | Details | Raw Unified | Return to bug 194386
Collapse All | Expand All

(-)sbin/ifconfig/af_link.c (-1 / +23 lines)
Lines 42-47 Link Here
42
#include <stdlib.h>
42
#include <stdlib.h>
43
#include <string.h>
43
#include <string.h>
44
#include <ifaddrs.h>
44
#include <ifaddrs.h>
45
#include <unistd.h>
45
46
46
#include <net/if_dl.h>
47
#include <net/if_dl.h>
47
#include <net/if_types.h>
48
#include <net/if_types.h>
Lines 61-69 Link Here
61
		if ((sdl->sdl_type == IFT_ETHER ||
62
		if ((sdl->sdl_type == IFT_ETHER ||
62
		    sdl->sdl_type == IFT_L2VLAN ||
63
		    sdl->sdl_type == IFT_L2VLAN ||
63
		    sdl->sdl_type == IFT_BRIDGE) &&
64
		    sdl->sdl_type == IFT_BRIDGE) &&
64
		    sdl->sdl_alen == ETHER_ADDR_LEN)
65
		    sdl->sdl_alen == ETHER_ADDR_LEN) {
66
			struct ifreq ifr;
67
			int s_hw;
65
			printf("\tether %s\n",
68
			printf("\tether %s\n",
66
			    ether_ntoa((struct ether_addr *)LLADDR(sdl)));
69
			    ether_ntoa((struct ether_addr *)LLADDR(sdl)));
70
			strncpy(ifr.ifr_name, ifa->ifa_name,
71
			    sizeof(ifr.ifr_name));
72
			memcpy(&ifr.ifr_addr, ifa->ifa_addr,
73
			    sizeof(ifa->ifa_addr->sa_len));
74
			ifr.ifr_addr.sa_family = AF_LOCAL;
75
			if ((s_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
76
				warn("socket(AF_LOCAL,SOCK_DGRAM)");
77
				return;
78
			}
79
			if (ioctl(s_hw, SIOCGHWLLADDR, &ifr) < 0) {
80
				warn("SIOCGHWLLADDR");
81
				close(s_hw);
82
				return;
83
			}
84
			printf("\thwaddr %s\n",
85
			    ether_ntoa((const struct ether_addr *)
86
			    &ifr.ifr_addr.sa_data));
87
			close(s_hw);
88
		}
67
		else {
89
		else {
68
			int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
90
			int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0;
69
91
(-)sys/net/if.c (+31 lines)
Lines 2613-2618 Link Here
2613
		EVENTHANDLER_INVOKE(iflladdr_event, ifp);
2613
		EVENTHANDLER_INVOKE(iflladdr_event, ifp);
2614
		break;
2614
		break;
2615
2615
2616
	case SIOCGHWLLADDR:
2617
		error = if_gethwlladdr(ifp, ifr);
2618
		break;
2619
2616
	case SIOCAIFGROUP:
2620
	case SIOCAIFGROUP:
2617
	{
2621
	{
2618
		struct ifgroupreq *ifgr = (struct ifgroupreq *)ifr;
2622
		struct ifgroupreq *ifgr = (struct ifgroupreq *)ifr;
Lines 3486-3491 Link Here
3486
}
3490
}
3487
3491
3488
/*
3492
/*
3493
 * Get the link layer address that was read from the hardware at probe.
3494
 *
3495
 * At this time we only support certain types of interfaces.
3496
 */
3497
int
3498
if_gethwlladdr(struct ifnet *ifp, struct ifreq *ifr)
3499
{
3500
	switch (ifp->if_type) {
3501
	case IFT_ETHER:
3502
	case IFT_FDDI:
3503
	case IFT_XETHER:
3504
	case IFT_ISO88025:
3505
	case IFT_L2VLAN:
3506
	case IFT_BRIDGE:
3507
	case IFT_ARCNET:
3508
	case IFT_IEEE8023ADLAG:
3509
	case IFT_IEEE80211:
3510
		bcopy(&IFP2AC(ifp)->hw_lladdr, ifr->ifr_addr.sa_data, ETHER_ADDR_LEN);
3511
		ifr->ifr_addr.sa_len = ETHER_ADDR_LEN;
3512
		break;
3513
	default:
3514
		return (ENODEV);
3515
	}
3516
	return (0);
3517
}
3518
3519
/*
3489
 * The name argument must be a pointer to storage which will last as
3520
 * The name argument must be a pointer to storage which will last as
3490
 * long as the interface does.  For physical devices, the result of
3521
 * long as the interface does.  For physical devices, the result of
3491
 * device_get_name(dev) is a good choice and for pseudo-devices a
3522
 * device_get_name(dev) is a good choice and for pseudo-devices a
(-)sys/net/if_arp.h (+2 lines)
Lines 102-110 Link Here
102
 * Structure shared between the ethernet driver modules and
102
 * Structure shared between the ethernet driver modules and
103
 * the address resolution code.
103
 * the address resolution code.
104
 */
104
 */
105
#include <net/ethernet.h>
105
struct	arpcom {
106
struct	arpcom {
106
	struct 	ifnet *ac_ifp;		/* network-visible interface */
107
	struct 	ifnet *ac_ifp;		/* network-visible interface */
107
	void	*ac_netgraph;		/* ng_ether(4) netgraph node info */
108
	void	*ac_netgraph;		/* ng_ether(4) netgraph node info */
109
	struct 	ether_addr hw_lladdr;	/* original lladdr from hardware */
108
};
110
};
109
#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com))
111
#define IFP2AC(ifp) ((struct arpcom *)(ifp->if_l2com))
110
#define AC2IFP(ac) ((ac)->ac_ifp)
112
#define AC2IFP(ac) ((ac)->ac_ifp)
(-)sys/net/if_ethersubr.c (+1 lines)
Lines 841-846 Link Here
841
	sdl->sdl_type = IFT_ETHER;
841
	sdl->sdl_type = IFT_ETHER;
842
	sdl->sdl_alen = ifp->if_addrlen;
842
	sdl->sdl_alen = ifp->if_addrlen;
843
	bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
843
	bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
844
	bcopy(lla, &IFP2AC(ifp)->hw_lladdr, ifp->if_addrlen);
844
845
845
	bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
846
	bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
846
	if (ng_ether_attach_p != NULL)
847
	if (ng_ether_attach_p != NULL)
(-)sys/net/if_var.h (+1 lines)
Lines 498-503 Link Here
498
void	if_ref(struct ifnet *);
498
void	if_ref(struct ifnet *);
499
void	if_rele(struct ifnet *);
499
void	if_rele(struct ifnet *);
500
int	if_setlladdr(struct ifnet *, const u_char *, int);
500
int	if_setlladdr(struct ifnet *, const u_char *, int);
501
int	if_gethwlladdr(struct ifnet *, struct ifreq *);
501
void	if_up(struct ifnet *);
502
void	if_up(struct ifnet *);
502
int	ifioctl(struct socket *, u_long, caddr_t, struct thread *);
503
int	ifioctl(struct socket *, u_long, caddr_t, struct thread *);
503
int	ifpromisc(struct ifnet *, int);
504
int	ifpromisc(struct ifnet *, int);
(-)sys/sys/sockio.h (+1 lines)
Lines 97-102 Link Here
97
#define	SIOCGIFSTATUS	_IOWR('i', 59, struct ifstat)	/* get IF status */
97
#define	SIOCGIFSTATUS	_IOWR('i', 59, struct ifstat)	/* get IF status */
98
#define	SIOCSIFLLADDR	 _IOW('i', 60, struct ifreq)	/* set linklevel addr */
98
#define	SIOCSIFLLADDR	 _IOW('i', 60, struct ifreq)	/* set linklevel addr */
99
#define	SIOCGI2C	_IOWR('i', 61, struct ifstat)	/* get I2C data  */
99
#define	SIOCGI2C	_IOWR('i', 61, struct ifstat)	/* get I2C data  */
100
#define	SIOCGHWLLADDR	_IOWR('i', 62, struct ifreq)	/* get hw lladdr */
100
101
101
#define	SIOCSIFPHYADDR	 _IOW('i', 70, struct ifaliasreq) /* set gif addres */
102
#define	SIOCSIFPHYADDR	 _IOW('i', 70, struct ifaliasreq) /* set gif addres */
102
#define	SIOCGIFPSRCADDR	_IOWR('i', 71, struct ifreq)	/* get gif psrc addr */
103
#define	SIOCGIFPSRCADDR	_IOWR('i', 71, struct ifreq)	/* get gif psrc addr */

Return to bug 194386