1 #ifndef _LINUX_INETDEVICE_H
2 #define _LINUX_INETDEVICE_H
7 #include <linux/netdevice.h>
8 #include <linux/rcupdate.h>
9 #include <linux/timer.h>
17 int accept_source_route
;
31 int force_igmp_version
;
35 extern struct ipv4_devconf ipv4_devconf
;
39 struct net_device
*dev
;
42 struct in_ifaddr
*ifa_list
; /* IP ifaddr chain */
43 rwlock_t mc_list_lock
;
44 struct ip_mc_list
*mc_list
; /* IP multicast filter chain */
45 spinlock_t mc_tomb_lock
;
46 struct ip_mc_list
*mc_tomb
;
47 unsigned long mr_v1_seen
;
48 unsigned long mr_v2_seen
;
49 unsigned long mr_maxdelay
;
51 unsigned char mr_gq_running
;
52 unsigned char mr_ifc_count
;
53 struct timer_list mr_gq_timer
; /* general query timer */
54 struct timer_list mr_ifc_timer
; /* interface change timer */
56 struct neigh_parms
*arp_parms
;
57 struct ipv4_devconf cnf
;
58 struct rcu_head rcu_head
;
61 #define IN_DEV_FORWARD(in_dev) ((in_dev)->cnf.forwarding)
62 #define IN_DEV_MFORWARD(in_dev) (ipv4_devconf.mc_forwarding && (in_dev)->cnf.mc_forwarding)
63 #define IN_DEV_RPFILTER(in_dev) (ipv4_devconf.rp_filter && (in_dev)->cnf.rp_filter)
64 #define IN_DEV_SOURCE_ROUTE(in_dev) (ipv4_devconf.accept_source_route && (in_dev)->cnf.accept_source_route)
65 #define IN_DEV_BOOTP_RELAY(in_dev) (ipv4_devconf.bootp_relay && (in_dev)->cnf.bootp_relay)
67 #define IN_DEV_LOG_MARTIANS(in_dev) (ipv4_devconf.log_martians || (in_dev)->cnf.log_martians)
68 #define IN_DEV_PROXY_ARP(in_dev) (ipv4_devconf.proxy_arp || (in_dev)->cnf.proxy_arp)
69 #define IN_DEV_SHARED_MEDIA(in_dev) (ipv4_devconf.shared_media || (in_dev)->cnf.shared_media)
70 #define IN_DEV_TX_REDIRECTS(in_dev) (ipv4_devconf.send_redirects || (in_dev)->cnf.send_redirects)
71 #define IN_DEV_SEC_REDIRECTS(in_dev) (ipv4_devconf.secure_redirects || (in_dev)->cnf.secure_redirects)
72 #define IN_DEV_IDTAG(in_dev) ((in_dev)->cnf.tag)
73 #define IN_DEV_MEDIUM_ID(in_dev) ((in_dev)->cnf.medium_id)
75 #define IN_DEV_RX_REDIRECTS(in_dev) \
76 ((IN_DEV_FORWARD(in_dev) && \
77 (ipv4_devconf.accept_redirects && (in_dev)->cnf.accept_redirects)) \
78 || (!IN_DEV_FORWARD(in_dev) && \
79 (ipv4_devconf.accept_redirects || (in_dev)->cnf.accept_redirects)))
81 #define IN_DEV_ARPFILTER(in_dev) (ipv4_devconf.arp_filter || (in_dev)->cnf.arp_filter)
82 #define IN_DEV_ARP_ANNOUNCE(in_dev) (max(ipv4_devconf.arp_announce, (in_dev)->cnf.arp_announce))
83 #define IN_DEV_ARP_IGNORE(in_dev) (max(ipv4_devconf.arp_ignore, (in_dev)->cnf.arp_ignore))
87 struct in_ifaddr
*ifa_next
;
88 struct in_device
*ifa_dev
;
89 struct rcu_head rcu_head
;
95 unsigned char ifa_scope
;
96 unsigned char ifa_flags
;
97 unsigned char ifa_prefixlen
;
98 char ifa_label
[IFNAMSIZ
];
101 extern int register_inetaddr_notifier(struct notifier_block
*nb
);
102 extern int unregister_inetaddr_notifier(struct notifier_block
*nb
);
104 extern struct net_device
*ip_dev_find(u32 addr
);
105 extern int inet_addr_onlink(struct in_device
*in_dev
, u32 a
, u32 b
);
106 extern int devinet_ioctl(unsigned int cmd
, void __user
*);
107 extern void devinet_init(void);
108 extern struct in_device
*inetdev_init(struct net_device
*dev
);
109 extern struct in_device
*inetdev_by_index(int);
110 extern u32
inet_select_addr(const struct net_device
*dev
, u32 dst
, int scope
);
111 extern u32
inet_confirm_addr(const struct net_device
*dev
, u32 dst
, u32 local
, int scope
);
112 extern struct in_ifaddr
*inet_ifa_byprefix(struct in_device
*in_dev
, u32 prefix
, u32 mask
);
113 extern void inet_forward_change(void);
115 static __inline__
int inet_ifa_match(u32 addr
, struct in_ifaddr
*ifa
)
117 return !((addr
^ifa
->ifa_address
)&ifa
->ifa_mask
);
121 * Check if a mask is acceptable.
124 static __inline__
int bad_mask(u32 mask
, u32 addr
)
126 if (addr
& (mask
= ~mask
))
134 #define for_primary_ifa(in_dev) { struct in_ifaddr *ifa; \
135 for (ifa = (in_dev)->ifa_list; ifa && !(ifa->ifa_flags&IFA_F_SECONDARY); ifa = ifa->ifa_next)
137 #define for_ifa(in_dev) { struct in_ifaddr *ifa; \
138 for (ifa = (in_dev)->ifa_list; ifa; ifa = ifa->ifa_next)
141 #define endfor_ifa(in_dev) }
143 static __inline__
struct in_device
*
144 in_dev_get(const struct net_device
*dev
)
146 struct in_device
*in_dev
;
149 in_dev
= dev
->ip_ptr
;
151 atomic_inc(&in_dev
->refcnt
);
156 static __inline__
struct in_device
*
157 __in_dev_get(const struct net_device
*dev
)
159 return (struct in_device
*)dev
->ip_ptr
;
162 extern void in_dev_finish_destroy(struct in_device
*idev
);
164 static inline void in_dev_put(struct in_device
*idev
)
166 if (atomic_dec_and_test(&idev
->refcnt
))
167 in_dev_finish_destroy(idev
);
170 #define __in_dev_put(idev) atomic_dec(&(idev)->refcnt)
171 #define in_dev_hold(idev) atomic_inc(&(idev)->refcnt)
173 #endif /* __KERNEL__ */
175 static __inline__ __u32
inet_make_mask(int logmask
)
178 return htonl(~((1<<(32-logmask
))-1));
182 static __inline__
int inet_mask_len(__u32 mask
)
184 if (!(mask
= ntohl(mask
)))
186 return 32 - ffz(~mask
);
190 #endif /* _LINUX_INETDEVICE_H */