Home | History | Annotate | Line # | Download | only in netatalk
at_var.h revision 1.4.26.2
      1  1.4.26.2      yamt /*	$NetBSD: at_var.h,v 1.4.26.2 2007/05/07 10:55:55 yamt Exp $	 */
      2       1.1  christos 
      3       1.1  christos /*
      4       1.1  christos  * Copyright (c) 1990,1991 Regents of The University of Michigan.
      5       1.1  christos  * All Rights Reserved.
      6       1.1  christos  *
      7       1.1  christos  * Permission to use, copy, modify, and distribute this software and
      8       1.1  christos  * its documentation for any purpose and without fee is hereby granted,
      9       1.1  christos  * provided that the above copyright notice appears in all copies and
     10       1.1  christos  * that both that copyright notice and this permission notice appear
     11       1.1  christos  * in supporting documentation, and that the name of The University
     12       1.1  christos  * of Michigan not be used in advertising or publicity pertaining to
     13       1.1  christos  * distribution of the software without specific, written prior
     14       1.1  christos  * permission. This software is supplied as is without expressed or
     15       1.1  christos  * implied warranties of any kind.
     16       1.1  christos  *
     17       1.1  christos  * This product includes software developed by the University of
     18       1.1  christos  * California, Berkeley and its contributors.
     19       1.1  christos  *
     20       1.1  christos  *	Research Systems Unix Group
     21       1.1  christos  *	The University of Michigan
     22       1.1  christos  *	c/o Wesley Craig
     23       1.1  christos  *	535 W. William Street
     24       1.1  christos  *	Ann Arbor, Michigan
     25       1.1  christos  *	+1-313-764-2278
     26       1.1  christos  *	netatalk (at) umich.edu
     27       1.1  christos  */
     28       1.1  christos 
     29       1.1  christos #ifndef _NETATALK_AT_VAR_H_
     30       1.4      elad #define _NETATALK_AT_VAR_H_
     31       1.2   thorpej 
     32       1.2   thorpej #include <sys/callout.h>
     33       1.2   thorpej 
     34       1.1  christos /*
     35       1.1  christos  * For phase2, we need to keep not only our address on an interface,
     36       1.1  christos  * but also the legal networks on the interface.
     37       1.1  christos  */
     38       1.1  christos struct at_ifaddr {
     39       1.1  christos 	struct ifaddr   aa_ifa;
     40       1.1  christos #define aa_ifp		aa_ifa.ifa_ifp
     41       1.1  christos 	struct sockaddr_at aa_addr;
     42       1.1  christos 	struct sockaddr_at aa_broadaddr;
     43       1.1  christos #define aa_dstaddr	aa_broadaddr;
     44       1.1  christos 	struct sockaddr_at aa_netmask;
     45       1.1  christos 	int             aa_flags;
     46       1.1  christos 	u_short         aa_firstnet, aa_lastnet;
     47       1.1  christos 	int             aa_probcnt;
     48       1.1  christos 	TAILQ_ENTRY(at_ifaddr) aa_list;	/* list of appletalk addresses */
     49       1.2   thorpej 	struct callout	aa_probe_ch;	/* for aarpprobe() */
     50       1.1  christos };
     51       1.1  christos 
     52       1.1  christos struct at_aliasreq {
     53       1.1  christos 	char			ifra_name[IFNAMSIZ];
     54       1.1  christos 	struct sockaddr_at	ifra_addr;
     55       1.1  christos 	struct sockaddr_at	ifra_broadaddr;
     56       1.1  christos #define ifra_dstaddr		ifra_broadaddr
     57       1.1  christos 	struct sockaddr_at	ifra_mask;
     58       1.1  christos };
     59       1.1  christos 
     60       1.1  christos #define AA_SAT(aa) \
     61       1.1  christos     (&(aa->aa_addr))
     62       1.1  christos #define satosat(sa)	((struct sockaddr_at *)(sa))
     63  1.4.26.1      yamt #define satocsat(sa)	((const struct sockaddr_at *)(sa))
     64       1.1  christos 
     65       1.1  christos #define AFA_ROUTE	0x0001
     66       1.1  christos #define AFA_PROBING	0x0002
     67       1.1  christos #define AFA_PHASE2	0x0004
     68       1.1  christos 
     69       1.1  christos #ifdef _KERNEL
     70  1.4.26.2      yamt int sockaddr_at_cmp(const struct sockaddr *, const struct sockaddr *);
     71  1.4.26.2      yamt 
     72  1.4.26.2      yamt static inline void
     73  1.4.26.2      yamt sockaddr_at_init1(struct sockaddr_at *sat, const struct at_addr *addr,
     74  1.4.26.2      yamt     uint8_t port)
     75  1.4.26.2      yamt {
     76  1.4.26.2      yamt 	sat->sat_port = port;
     77  1.4.26.2      yamt 	sat->sat_addr = *addr;
     78  1.4.26.2      yamt 	memset(&sat->sat_range, 0, sizeof(sat->sat_range));
     79  1.4.26.2      yamt }
     80  1.4.26.2      yamt 
     81  1.4.26.2      yamt static inline void
     82  1.4.26.2      yamt sockaddr_at_init(struct sockaddr_at *sat, const struct at_addr *addr,
     83  1.4.26.2      yamt     uint8_t port)
     84  1.4.26.2      yamt {
     85  1.4.26.2      yamt 	sat->sat_family = AF_APPLETALK;
     86  1.4.26.2      yamt 	sat->sat_len = sizeof(*sat);
     87  1.4.26.2      yamt 	sockaddr_at_init1(sat, addr, port);
     88  1.4.26.2      yamt }
     89  1.4.26.2      yamt 
     90  1.4.26.2      yamt static inline struct sockaddr *
     91  1.4.26.2      yamt sockaddr_at_alloc(const struct at_addr *addr, uint8_t port, int flags)
     92  1.4.26.2      yamt {
     93  1.4.26.2      yamt 	struct sockaddr *sa;
     94  1.4.26.2      yamt 
     95  1.4.26.2      yamt 	if ((sa = sockaddr_alloc(AF_APPLETALK, flags)) == NULL)
     96  1.4.26.2      yamt 		return NULL;
     97  1.4.26.2      yamt 
     98  1.4.26.2      yamt 	sockaddr_at_init1(satosat(sa), addr, port);
     99  1.4.26.2      yamt 
    100  1.4.26.2      yamt 	return sa;
    101  1.4.26.2      yamt }
    102       1.1  christos TAILQ_HEAD(at_ifaddrhead, at_ifaddr);
    103       1.1  christos extern struct at_ifaddrhead at_ifaddr;
    104       1.3      matt extern struct ifqueue atintrq1, atintrq2;
    105       1.1  christos #endif
    106       1.1  christos 
    107       1.4      elad #endif /* !_NETATALK_AT_VAR_H_ */
    108