1139823Simp/*-
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 * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)if_dl.h	8.1 (Berkeley) 6/10/93
3050477Speter * $FreeBSD$
311541Srgrimes */
321541Srgrimes
332168Spaul#ifndef _NET_IF_DL_H_
342168Spaul#define _NET_IF_DL_H_
352168Spaul
368876Srgrimes/*
371541Srgrimes * A Link-Level Sockaddr may specify the interface in one of two
381541Srgrimes * ways: either by means of a system-provided index number (computed
391541Srgrimes * anew and possibly differently on every reboot), or by a human-readable
401541Srgrimes * string such as "il0" (for managerial convenience).
418876Srgrimes *
421541Srgrimes * Census taking actions, such as something akin to SIOCGCONF would return
431541Srgrimes * both the index and the human name.
448876Srgrimes *
451541Srgrimes * High volume transactions (such as giving a link-level ``from'' address
461541Srgrimes * in a recvfrom or recvmsg call) may be likely only to provide the indexed
471541Srgrimes * form, (which requires fewer copy operations and less space).
488876Srgrimes *
491541Srgrimes * The form and interpretation  of the link-level address is purely a matter
501541Srgrimes * of convention between the device driver and its consumers; however, it is
511541Srgrimes * expected that all drivers for an interface of a given if_type will agree.
521541Srgrimes */
531541Srgrimes
541541Srgrimes/*
551541Srgrimes * Structure of a Link-Level sockaddr:
561541Srgrimes */
571541Srgrimesstruct sockaddr_dl {
581541Srgrimes	u_char	sdl_len;	/* Total length of sockaddr */
5957637Sarchie	u_char	sdl_family;	/* AF_LINK */
601541Srgrimes	u_short	sdl_index;	/* if != 0, system given index for interface */
611541Srgrimes	u_char	sdl_type;	/* interface type */
621541Srgrimes	u_char	sdl_nlen;	/* interface name length, no trailing 0 reqd. */
631541Srgrimes	u_char	sdl_alen;	/* link level address length */
641541Srgrimes	u_char	sdl_slen;	/* link layer selector length */
6596184Skbyanc	char	sdl_data[46];	/* minimum work area, can be larger;
661541Srgrimes				   contains both if name and ll address */
671541Srgrimes};
681541Srgrimes
691541Srgrimes#define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen))
70287476Smelifaro#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen))
71235640Smarcel#define LLINDEX(s) ((s)->sdl_index)
721541Srgrimes
73260870Smelifaro
74260870Smelifarostruct ifnet;
75260870Smelifarostruct sockaddr_dl *link_alloc_sdl(size_t, int);
76260870Smelifarovoid link_free_sdl(struct sockaddr *sa);
77260870Smelifarostruct sockaddr_dl *link_init_sdl(struct ifnet *, struct sockaddr *, u_char);
78260870Smelifaro
7955205Speter#ifndef _KERNEL
801541Srgrimes
811541Srgrimes#include <sys/cdefs.h>
821541Srgrimes
831541Srgrimes__BEGIN_DECLS
8492725Salfredvoid	link_addr(const char *, struct sockaddr_dl *);
8592725Salfredchar	*link_ntoa(const struct sockaddr_dl *);
861541Srgrimes__END_DECLS
871541Srgrimes
8855205Speter#endif /* !_KERNEL */
892168Spaul
902168Spaul#endif
91