1 /* 2 * Copyright (c) 1982 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)in_var.h 6.2 (Berkeley) 6/8/85 7 */ 8 9 /* 10 * Interface address, internet version. One of these structures 11 * is allocated for each interface with an internet address. 12 * The ifaddr structure contains the protocol-independent part 13 * of the structure and is assumed to be first. 14 */ 15 struct in_ifaddr { 16 struct ifaddr ia_ifa; /* protocol-independent info */ 17 #define ia_addr ia_ifa.ifa_addr 18 #define ia_broadaddr ia_ifa.ifa_broadaddr 19 #define ia_dstaddr ia_ifa.ifa_dstaddr 20 #define ia_ifp ia_ifa.ifa_ifp 21 u_long ia_net; /* network number of interface */ 22 u_long ia_netmask; /* mask of net part */ 23 u_long ia_subnet; /* subnet number, including net */ 24 u_long ia_subnetmask; /* mask of net + subnet */ 25 int ia_flags; 26 struct in_ifaddr *ia_next; /* next in list of internet addresses */ 27 }; 28 29 /* 30 * Given a pointer to an in_ifaddr (ifaddr), 31 * return a pointer to the addr as a sockadd_in. 32 */ 33 #define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr)) 34 35 #define IA_B_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_broadaddr)) 36 37 /* 38 * in_ifaddr to in_addr 39 */ 40 #define IA_INADDR(ia) (IA_SIN(ia)->sin_addr) 41 42 #define IA_B_INADDR(ia) (IA_B_SIN(ia)->sin_addr) 43 44 /* 45 * ia_flags 46 */ 47 #define IFA_ROUTE 0x01 /* routing entry installed */ 48 49 /* 50 * protocol switch table built by IP at initialization time 51 */ 52 53 struct ipswitch { 54 struct protosw *ipsw_user; /* for normal user packets passed up */ 55 struct protosw *ipsw_raw; /* for raw packets passed up */ 56 int ipsw_hlen; 57 }; 58 extern struct ipswitch ipsw[]; 59 60 extern u_char inetctlerrmap[]; 61 62 /* 63 * Internet protocol statistics structure (should be at the head 64 * of protocol dependent structures). 65 */ 66 67 struct in_stat { 68 int in_total; /* total packets seen */ 69 int in_badsum; /* packets with bad cksums */ 70 int in_tooshort; /* bad sizes */ 71 int in_drops; /* packets no one (except raw) wanted */ 72 }; 73 74 75 #ifdef KERNEL 76 extern struct in_ifaddr *in_ifaddr; 77 78 extern struct in_ifaddr *in_iawithaddr(); 79 extern struct in_ifaddr *in_iawithnet(); 80 extern struct in_ifaddr *in_iafromif(); 81 #endif 82