if_dl.h revision 96184
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1990, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)if_dl.h	8.1 (Berkeley) 6/10/93
3450477Speter * $FreeBSD: head/sys/net/if_dl.h 96184 2002-05-07 22:14:06Z kbyanc $
351541Srgrimes */
361541Srgrimes
372168Spaul#ifndef _NET_IF_DL_H_
382168Spaul#define _NET_IF_DL_H_
392168Spaul
408876Srgrimes/*
411541Srgrimes * A Link-Level Sockaddr may specify the interface in one of two
421541Srgrimes * ways: either by means of a system-provided index number (computed
431541Srgrimes * anew and possibly differently on every reboot), or by a human-readable
441541Srgrimes * string such as "il0" (for managerial convenience).
458876Srgrimes *
461541Srgrimes * Census taking actions, such as something akin to SIOCGCONF would return
471541Srgrimes * both the index and the human name.
488876Srgrimes *
491541Srgrimes * High volume transactions (such as giving a link-level ``from'' address
501541Srgrimes * in a recvfrom or recvmsg call) may be likely only to provide the indexed
511541Srgrimes * form, (which requires fewer copy operations and less space).
528876Srgrimes *
531541Srgrimes * The form and interpretation  of the link-level address is purely a matter
541541Srgrimes * of convention between the device driver and its consumers; however, it is
551541Srgrimes * expected that all drivers for an interface of a given if_type will agree.
561541Srgrimes */
571541Srgrimes
581541Srgrimes/*
591541Srgrimes * Structure of a Link-Level sockaddr:
601541Srgrimes */
611541Srgrimesstruct sockaddr_dl {
621541Srgrimes	u_char	sdl_len;	/* Total length of sockaddr */
6357637Sarchie	u_char	sdl_family;	/* AF_LINK */
641541Srgrimes	u_short	sdl_index;	/* if != 0, system given index for interface */
651541Srgrimes	u_char	sdl_type;	/* interface type */
661541Srgrimes	u_char	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
671541Srgrimes	u_char	sdl_alen;	/* link level address length */
681541Srgrimes	u_char	sdl_slen;	/* link layer selector length */
6996184Skbyanc	char	sdl_data[46];	/* minimum work area, can be larger;
701541Srgrimes				   contains both if name and ll address */
711541Srgrimes};
721541Srgrimes
731541Srgrimes#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
741541Srgrimes
7555205Speter#ifndef _KERNEL
761541Srgrimes
771541Srgrimes#include <sys/cdefs.h>
781541Srgrimes
791541Srgrimes__BEGIN_DECLS
8092725Salfredvoid	link_addr(const char *, struct sockaddr_dl *);
8192725Salfredchar	*link_ntoa(const struct sockaddr_dl *);
821541Srgrimes__END_DECLS
831541Srgrimes
8455205Speter#endif /* !_KERNEL */
852168Spaul
862168Spaul#endif
87