2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* inet6 interface/address list definitions
|
|
|
|
* Linux INET6 implementation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Pedro Roque <roque@di.fc.ul.pt>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NET_IF_INET6_H
|
|
|
|
#define _NET_IF_INET6_H
|
|
|
|
|
|
|
|
#include <net/snmp.h>
|
|
|
|
#include <linux/ipv6.h>
|
|
|
|
|
|
|
|
/* inet6_dev.if_flags */
|
|
|
|
|
|
|
|
#define IF_RA_OTHERCONF 0x80
|
|
|
|
#define IF_RA_MANAGED 0x40
|
|
|
|
#define IF_RA_RCVD 0x20
|
|
|
|
#define IF_RS_SENT 0x10
|
2005-12-21 20:57:24 +07:00
|
|
|
#define IF_READY 0x80000000
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* prefix flags */
|
|
|
|
#define IF_PREFIX_ONLINK 0x01
|
|
|
|
#define IF_PREFIX_AUTOCONF 0x02
|
|
|
|
|
2010-05-19 05:36:06 +07:00
|
|
|
enum {
|
|
|
|
INET6_IFADDR_STATE_DAD,
|
|
|
|
INET6_IFADDR_STATE_POSTDAD,
|
|
|
|
INET6_IFADDR_STATE_UP,
|
|
|
|
INET6_IFADDR_STATE_DEAD,
|
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct inet6_ifaddr {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct in6_addr addr;
|
|
|
|
__u32 prefix_len;
|
|
|
|
|
2011-07-26 20:50:49 +07:00
|
|
|
/* In seconds, relative to tstamp. Expiry is at tstamp + HZ * lft. */
|
2005-04-17 05:20:36 +07:00
|
|
|
__u32 valid_lft;
|
|
|
|
__u32 prefered_lft;
|
|
|
|
atomic_t refcnt;
|
|
|
|
spinlock_t lock;
|
2010-05-19 05:36:06 +07:00
|
|
|
spinlock_t state_lock;
|
|
|
|
|
|
|
|
int state;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
__u8 probes;
|
|
|
|
__u8 flags;
|
|
|
|
|
|
|
|
__u16 scope;
|
|
|
|
|
2009-03-22 03:29:05 +07:00
|
|
|
unsigned long cstamp; /* created timestamp */
|
|
|
|
unsigned long tstamp; /* updated timestamp */
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
struct timer_list timer;
|
|
|
|
|
|
|
|
struct inet6_dev *idev;
|
|
|
|
struct rt6_info *rt;
|
|
|
|
|
2010-03-18 03:31:10 +07:00
|
|
|
struct hlist_node addr_lst;
|
2010-03-18 03:31:13 +07:00
|
|
|
struct list_head if_list;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_IPV6_PRIVACY
|
2010-03-18 03:31:09 +07:00
|
|
|
struct list_head tmp_list;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct inet6_ifaddr *ifpub;
|
|
|
|
int regen_count;
|
|
|
|
#endif
|
2010-03-18 03:31:11 +07:00
|
|
|
struct rcu_head rcu;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ip6_sf_socklist {
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int sl_max;
|
|
|
|
unsigned int sl_count;
|
|
|
|
struct in6_addr sl_addr[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IP6_SFLSIZE(count) (sizeof(struct ip6_sf_socklist) + \
|
|
|
|
(count) * sizeof(struct in6_addr))
|
|
|
|
|
|
|
|
#define IP6_SFBLOCK 10 /* allocate this many at once */
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ipv6_mc_socklist {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct in6_addr addr;
|
|
|
|
int ifindex;
|
2010-11-23 20:12:15 +07:00
|
|
|
struct ipv6_mc_socklist __rcu *next;
|
2005-12-28 05:03:00 +07:00
|
|
|
rwlock_t sflock;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */
|
|
|
|
struct ip6_sf_socklist *sflist;
|
2010-11-23 20:12:15 +07:00
|
|
|
struct rcu_head rcu;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ip6_sf_list {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct ip6_sf_list *sf_next;
|
|
|
|
struct in6_addr sf_addr;
|
|
|
|
unsigned long sf_count[2]; /* include/exclude counts */
|
|
|
|
unsigned char sf_gsresp; /* include in g & s response? */
|
|
|
|
unsigned char sf_oldin; /* change state */
|
|
|
|
unsigned char sf_crcount; /* retrans. left to send */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAF_TIMER_RUNNING 0x01
|
|
|
|
#define MAF_LAST_REPORTER 0x02
|
|
|
|
#define MAF_LOADED 0x04
|
|
|
|
#define MAF_NOREPORT 0x08
|
|
|
|
#define MAF_GSQUERY 0x10
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ifmcaddr6 {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct in6_addr mca_addr;
|
|
|
|
struct inet6_dev *idev;
|
|
|
|
struct ifmcaddr6 *next;
|
|
|
|
struct ip6_sf_list *mca_sources;
|
|
|
|
struct ip6_sf_list *mca_tomb;
|
|
|
|
unsigned int mca_sfmode;
|
2008-02-03 19:09:17 +07:00
|
|
|
unsigned char mca_crcount;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long mca_sfcount[2];
|
|
|
|
struct timer_list mca_timer;
|
2012-04-15 12:58:06 +07:00
|
|
|
unsigned int mca_flags;
|
2005-04-17 05:20:36 +07:00
|
|
|
int mca_users;
|
|
|
|
atomic_t mca_refcnt;
|
|
|
|
spinlock_t mca_lock;
|
|
|
|
unsigned long mca_cstamp;
|
|
|
|
unsigned long mca_tstamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Anycast stuff */
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ipv6_ac_socklist {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct in6_addr acl_addr;
|
|
|
|
int acl_ifindex;
|
|
|
|
struct ipv6_ac_socklist *acl_next;
|
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct ifacaddr6 {
|
2005-04-17 05:20:36 +07:00
|
|
|
struct in6_addr aca_addr;
|
|
|
|
struct inet6_dev *aca_idev;
|
|
|
|
struct rt6_info *aca_rt;
|
|
|
|
struct ifacaddr6 *aca_next;
|
|
|
|
int aca_users;
|
|
|
|
atomic_t aca_refcnt;
|
|
|
|
spinlock_t aca_lock;
|
|
|
|
unsigned long aca_cstamp;
|
|
|
|
unsigned long aca_tstamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IFA_HOST IPV6_ADDR_LOOPBACK
|
|
|
|
#define IFA_LINK IPV6_ADDR_LINKLOCAL
|
|
|
|
#define IFA_SITE IPV6_ADDR_SITELOCAL
|
|
|
|
|
|
|
|
struct ipv6_devstat {
|
|
|
|
struct proc_dir_entry *proc_dir_entry;
|
2006-11-04 18:11:37 +07:00
|
|
|
DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
|
2011-05-19 08:14:23 +07:00
|
|
|
DEFINE_SNMP_STAT_ATOMIC(struct icmpv6_mib_device, icmpv6dev);
|
|
|
|
DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib_device, icmpv6msgdev);
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2009-11-03 10:26:03 +07:00
|
|
|
struct inet6_dev {
|
2010-03-18 03:31:13 +07:00
|
|
|
struct net_device *dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-03-18 03:31:13 +07:00
|
|
|
struct list_head addr_list;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
struct ifmcaddr6 *mc_list;
|
|
|
|
struct ifmcaddr6 *mc_tomb;
|
2010-02-18 09:48:44 +07:00
|
|
|
spinlock_t mc_lock;
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned char mc_qrv;
|
|
|
|
unsigned char mc_gq_running;
|
|
|
|
unsigned char mc_ifc_count;
|
2008-02-03 19:06:59 +07:00
|
|
|
unsigned long mc_v1_seen;
|
|
|
|
unsigned long mc_maxdelay;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct timer_list mc_gq_timer; /* general query timer */
|
|
|
|
struct timer_list mc_ifc_timer; /* interface change timer */
|
|
|
|
|
|
|
|
struct ifacaddr6 *ac_list;
|
|
|
|
rwlock_t lock;
|
|
|
|
atomic_t refcnt;
|
|
|
|
__u32 if_flags;
|
|
|
|
int dead;
|
|
|
|
|
|
|
|
#ifdef CONFIG_IPV6_PRIVACY
|
|
|
|
u8 rndid[8];
|
|
|
|
struct timer_list regen_timer;
|
2010-03-18 03:31:09 +07:00
|
|
|
struct list_head tempaddr_list;
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct neigh_parms *nd_parms;
|
|
|
|
struct inet6_dev *next;
|
|
|
|
struct ipv6_devconf cnf;
|
|
|
|
struct ipv6_devstat stats;
|
|
|
|
unsigned long tstamp; /* ipv6InterfaceTable update timestamp */
|
2006-09-23 04:44:24 +07:00
|
|
|
struct rcu_head rcu;
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2011-04-22 11:53:02 +07:00
|
|
|
static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* +-------+-------+-------+-------+-------+-------+
|
|
|
|
* | 33 | 33 | DST13 | DST14 | DST15 | DST16 |
|
|
|
|
* +-------+-------+-------+-------+-------+-------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
buf[0]= 0x33;
|
|
|
|
buf[1]= 0x33;
|
|
|
|
|
|
|
|
memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf)
|
|
|
|
{
|
|
|
|
buf[0] = 0x00;
|
|
|
|
}
|
|
|
|
|
2007-12-11 03:38:41 +07:00
|
|
|
static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
|
|
|
|
const unsigned char *broadcast, char *buf)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-12-11 03:38:41 +07:00
|
|
|
unsigned char scope = broadcast[5] & 0xF;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
buf[0] = 0; /* Reserved */
|
|
|
|
buf[1] = 0xff; /* Multicast QPN */
|
|
|
|
buf[2] = 0xff;
|
|
|
|
buf[3] = 0xff;
|
|
|
|
buf[4] = 0xff;
|
2007-12-11 03:38:41 +07:00
|
|
|
buf[5] = 0x10 | scope; /* scope from broadcast address */
|
2005-04-17 05:20:36 +07:00
|
|
|
buf[6] = 0x60; /* IPv6 signature */
|
|
|
|
buf[7] = 0x1b;
|
2007-12-11 03:38:41 +07:00
|
|
|
buf[8] = broadcast[8]; /* P_Key */
|
|
|
|
buf[9] = broadcast[9];
|
2005-04-17 05:20:36 +07:00
|
|
|
memcpy(buf + 10, addr->s6_addr + 6, 10);
|
|
|
|
}
|
2011-03-29 05:40:53 +07:00
|
|
|
|
|
|
|
static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr,
|
|
|
|
const unsigned char *broadcast, char *buf)
|
|
|
|
{
|
|
|
|
if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) {
|
|
|
|
memcpy(buf, broadcast, 4);
|
|
|
|
} else {
|
|
|
|
/* v4mapped? */
|
|
|
|
if ((addr->s6_addr32[0] | addr->s6_addr32[1] |
|
|
|
|
(addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
memcpy(buf, &addr->s6_addr32[3], 4);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|