2015-03-04 01:10:47 +00:00
|
|
|
#ifndef MPLS_INTERNAL_H
|
|
|
|
#define MPLS_INTERNAL_H
|
|
|
|
|
|
|
|
struct mpls_shim_hdr {
|
|
|
|
__be32 label_stack_entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mpls_entry_decoded {
|
|
|
|
u32 label;
|
|
|
|
u8 ttl;
|
|
|
|
u8 tc;
|
|
|
|
u8 bos;
|
|
|
|
};
|
|
|
|
|
2015-04-22 10:14:37 +00:00
|
|
|
struct mpls_dev {
|
2015-04-22 10:14:38 +00:00
|
|
|
int input_enabled;
|
|
|
|
|
|
|
|
struct ctl_table_header *sysctl;
|
2015-06-05 17:54:45 +00:00
|
|
|
struct rcu_head rcu;
|
2015-04-22 10:14:37 +00:00
|
|
|
};
|
|
|
|
|
2015-03-04 01:10:47 +00:00
|
|
|
struct sk_buff;
|
|
|
|
|
|
|
|
static inline struct mpls_shim_hdr *mpls_hdr(const struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
return (struct mpls_shim_hdr *)skb_network_header(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mpls_shim_hdr mpls_entry_encode(u32 label, unsigned ttl, unsigned tc, bool bos)
|
|
|
|
{
|
|
|
|
struct mpls_shim_hdr result;
|
|
|
|
result.label_stack_entry =
|
|
|
|
cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) |
|
|
|
|
(tc << MPLS_LS_TC_SHIFT) |
|
|
|
|
(bos ? (1 << MPLS_LS_S_SHIFT) : 0) |
|
|
|
|
(ttl << MPLS_LS_TTL_SHIFT));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mpls_entry_decoded mpls_entry_decode(struct mpls_shim_hdr *hdr)
|
|
|
|
{
|
|
|
|
struct mpls_entry_decoded result;
|
|
|
|
unsigned entry = be32_to_cpu(hdr->label_stack_entry);
|
|
|
|
|
|
|
|
result.label = (entry & MPLS_LS_LABEL_MASK) >> MPLS_LS_LABEL_SHIFT;
|
|
|
|
result.ttl = (entry & MPLS_LS_TTL_MASK) >> MPLS_LS_TTL_SHIFT;
|
|
|
|
result.tc = (entry & MPLS_LS_TC_MASK) >> MPLS_LS_TC_SHIFT;
|
|
|
|
result.bos = (entry & MPLS_LS_S_MASK) >> MPLS_LS_S_SHIFT;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-21 08:43:52 +00:00
|
|
|
int nla_put_labels(struct sk_buff *skb, int attrtype, u8 labels,
|
|
|
|
const u32 label[]);
|
|
|
|
int nla_get_labels(const struct nlattr *nla, u32 max_labels, u32 *labels,
|
|
|
|
u32 label[]);
|
|
|
|
bool mpls_output_possible(const struct net_device *dev);
|
|
|
|
unsigned int mpls_dev_mtu(const struct net_device *dev);
|
|
|
|
bool mpls_pkt_too_big(const struct sk_buff *skb, unsigned int mtu);
|
2015-03-04 01:13:19 +00:00
|
|
|
|
2015-03-04 01:10:47 +00:00
|
|
|
#endif /* MPLS_INTERNAL_H */
|