Main Page | Class List | File List | Class Members | File Members

inetdevice.h

Go to the documentation of this file.
00001 #ifndef _LINUX_INETDEVICE_H 00002 #define _LINUX_INETDEVICE_H 00003 00004 #ifdef __KERNEL__ 00005 00006 struct ipv4_devconf 00007 { 00008 int accept_redirects; 00009 int send_redirects; 00010 int secure_redirects; 00011 int shared_media; 00012 int accept_source_route; 00013 int rp_filter; 00014 int proxy_arp; 00015 int bootp_relay; 00016 int log_martians; 00017 int forwarding; 00018 int mc_forwarding; 00019 int tag; 00020 int arp_filter; 00021 int medium_id; 00022 int loop; 00023 void *sysctl; 00024 }; 00025 00026 extern struct ipv4_devconf ipv4_devconf; 00027 00028 struct in_device 00029 { 00030 struct net_device *dev; 00031 atomic_t refcnt; 00032 rwlock_t lock; 00033 int dead; 00034 struct in_ifaddr *ifa_list; /* IP ifaddr chain */ 00035 struct ip_mc_list *mc_list; /* IP multicast filter chain */ 00036 rwlock_t mc_lock; /* for mc_tomb */ 00037 struct ip_mc_list *mc_tomb; 00038 unsigned long mr_v1_seen; 00039 unsigned long mr_v2_seen; 00040 unsigned long mr_maxdelay; 00041 unsigned char mr_qrv; 00042 unsigned char mr_gq_running; 00043 unsigned char mr_ifc_count; 00044 struct timer_list mr_gq_timer; /* general query timer */ 00045 struct timer_list mr_ifc_timer; /* interface change timer */ 00046 00047 struct neigh_parms *arp_parms; 00048 struct ipv4_devconf cnf; 00049 }; 00050 00051 #define IN_DEV_FORWARD(in_dev) ((in_dev)->cnf.forwarding) 00052 #define IN_DEV_MFORWARD(in_dev) (ipv4_devconf.mc_forwarding && (in_dev)->cnf.mc_forwarding) 00053 #define IN_DEV_RPFILTER(in_dev) (ipv4_devconf.rp_filter && (in_dev)->cnf.rp_filter) 00054 #define IN_DEV_SOURCE_ROUTE(in_dev) (ipv4_devconf.accept_source_route && (in_dev)->cnf.accept_source_route) 00055 #define IN_DEV_BOOTP_RELAY(in_dev) (ipv4_devconf.bootp_relay && (in_dev)->cnf.bootp_relay) 00056 00057 #define IN_DEV_LOG_MARTIANS(in_dev) (ipv4_devconf.log_martians || (in_dev)->cnf.log_martians) 00058 #define IN_DEV_PROXY_ARP(in_dev) (ipv4_devconf.proxy_arp || (in_dev)->cnf.proxy_arp) 00059 #define IN_DEV_SHARED_MEDIA(in_dev) (ipv4_devconf.shared_media || (in_dev)->cnf.shared_media) 00060 #define IN_DEV_TX_REDIRECTS(in_dev) (ipv4_devconf.send_redirects || (in_dev)->cnf.send_redirects) 00061 #define IN_DEV_SEC_REDIRECTS(in_dev) (ipv4_devconf.secure_redirects || (in_dev)->cnf.secure_redirects) 00062 #define IN_DEV_IDTAG(in_dev) ((in_dev)->cnf.tag) 00063 #define IN_DEV_MEDIUM_ID(in_dev) ((in_dev)->cnf.medium_id) 00064 00065 #define IN_DEV_RX_REDIRECTS(in_dev) \ 00066 ((IN_DEV_FORWARD(in_dev) && \ 00067 (ipv4_devconf.accept_redirects && (in_dev)->cnf.accept_redirects)) \ 00068 || (!IN_DEV_FORWARD(in_dev) && \ 00069 (ipv4_devconf.accept_redirects || (in_dev)->cnf.accept_redirects))) 00070 00071 #define IN_DEV_ARPFILTER(in_dev) (ipv4_devconf.arp_filter || (in_dev)->cnf.arp_filter) 00072 #define IN_DEV_LOOP(in_dev) ((in_dev)->cnf.loop) 00073 00074 struct in_ifaddr 00075 { 00076 struct in_ifaddr *ifa_next; 00077 struct in_device *ifa_dev; 00078 u32 ifa_local; 00079 u32 ifa_address; 00080 u32 ifa_mask; 00081 u32 ifa_broadcast; 00082 u32 ifa_anycast; 00083 unsigned char ifa_scope; 00084 unsigned char ifa_flags; 00085 unsigned char ifa_prefixlen; 00086 char ifa_label[IFNAMSIZ]; 00087 }; 00088 00089 extern int register_inetaddr_notifier(struct notifier_block *nb); 00090 extern int unregister_inetaddr_notifier(struct notifier_block *nb); 00091 00092 extern struct net_device *ip_dev_find(u32 addr); 00093 extern int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b); 00094 extern int devinet_ioctl(unsigned int cmd, void *); 00095 extern void devinet_init(void); 00096 extern struct in_device *inetdev_init(struct net_device *dev); 00097 extern struct in_device *inetdev_by_index(int); 00098 extern u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope); 00099 extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask); 00100 extern void inet_forward_change(void); 00101 00102 static __inline__ int inet_ifa_match(u32 addr, struct in_ifaddr *ifa) 00103 { 00104 return !((addr^ifa->ifa_address)&ifa->ifa_mask); 00105 } 00106 00107 /* 00108 * Check if a mask is acceptable. 00109 */ 00110 00111 static __inline__ int bad_mask(u32 mask, u32 addr) 00112 { 00113 if (addr & (mask = ~mask)) 00114 return 1; 00115 mask = ntohl(mask); 00116 if (mask & (mask+1)) 00117 return 1; 00118 return 0; 00119 } 00120 00121 #define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \ 00122 for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next) 00123 00124 #define for_ifa(in_dev) { struct in_ifaddr *ifa; \ 00125 for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next) 00126 00127 00128 #define endfor_ifa(in_dev) } 00129 00130 extern rwlock_t inetdev_lock; 00131 00132 00133 static __inline__ struct in_device * 00134 in_dev_get(const struct net_device *dev) 00135 { 00136 struct in_device *in_dev; 00137 00138 read_lock(&inetdev_lock); 00139 in_dev = dev->ip_ptr; 00140 if (in_dev) 00141 atomic_inc(&in_dev->refcnt); 00142 read_unlock(&inetdev_lock); 00143 return in_dev; 00144 } 00145 00146 static __inline__ struct in_device * 00147 __in_dev_get(const struct net_device *dev) 00148 { 00149 return (struct in_device*)dev->ip_ptr; 00150 } 00151 00152 extern void in_dev_finish_destroy(struct in_device *idev); 00153 00154 static __inline__ void 00155 in_dev_put(struct in_device *idev) 00156 { 00157 if (atomic_dec_and_test(&idev->refcnt)) 00158 in_dev_finish_destroy(idev); 00159 } 00160 00161 #define __in_dev_put(idev) atomic_dec(&(idev)->refcnt) 00162 #define in_dev_hold(idev) atomic_inc(&(idev)->refcnt) 00163 00164 #endif /* __KERNEL__ */ 00165 00166 static __inline__ __u32 inet_make_mask(int logmask) 00167 { 00168 if (logmask) 00169 return htonl(~((1<<(32-logmask))-1)); 00170 return 0; 00171 } 00172 00173 static __inline__ int inet_mask_len(__u32 mask) 00174 { 00175 if (!(mask = ntohl(mask))) 00176 return 0; 00177 return 32 - ffz(~mask); 00178 } 00179 00180 00181 #endif /* _LINUX_INETDEVICE_H */

Generated on Wed Dec 1 21:25:30 2004 for Linux 2.4.23 Networking by doxygen 1.3.8