ila: xlat changes
[deliverable/linux.git] / net / ipv6 / ila / ila.h
CommitLineData
33f11d16
TH
1/*
2 * Copyright (c) 2015 Tom Herbert <tom@herbertland.com>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 */
10
11#ifndef __ILA_H
12#define __ILA_H
13
14#include <linux/errno.h>
15#include <linux/ip.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/socket.h>
19#include <linux/skbuff.h>
20#include <linux/types.h>
21#include <net/checksum.h>
22#include <net/ip.h>
23#include <net/protocol.h>
24#include <uapi/linux/ila.h>
25
351596aa
TH
26struct ila_locator {
27 union {
28 __u8 v8[8];
29 __be16 v16[4];
30 __be32 v32[2];
31 __be64 v64;
32 };
33};
34
35struct ila_identifier {
36 union {
37 struct {
38#if defined(__LITTLE_ENDIAN_BITFIELD)
39 u8 __space:5;
40 u8 type:3;
41#elif defined(__BIG_ENDIAN_BITFIELD)
42 u8 type:3;
43 u8 __space:5;
44#else
45#error "Adjust your <asm/byteorder.h> defines"
46#endif
47 u8 __space2[7];
48 };
49 __u8 v8[8];
50 __be16 v16[4];
51 __be32 v32[2];
52 __be64 v64;
53 };
54};
55
56enum {
57 ILA_ATYPE_IID = 0,
58 ILA_ATYPE_LUID,
59 ILA_ATYPE_VIRT_V4,
60 ILA_ATYPE_VIRT_UNI_V6,
61 ILA_ATYPE_VIRT_MULTI_V6,
62 ILA_ATYPE_RSVD_1,
63 ILA_ATYPE_RSVD_2,
64 ILA_ATYPE_RSVD_3,
65};
66
67struct ila_addr {
68 union {
69 struct in6_addr addr;
70 struct {
71 struct ila_locator loc;
72 struct ila_identifier ident;
73 };
74 };
75};
76
77static inline struct ila_addr *ila_a2i(struct in6_addr *addr)
78{
79 return (struct ila_addr *)addr;
80}
81
82static inline bool ila_addr_is_ila(struct ila_addr *iaddr)
83{
84 return (iaddr->ident.type != ILA_ATYPE_IID);
85}
86
33f11d16 87struct ila_params {
351596aa
TH
88 struct ila_locator locator;
89 struct ila_locator locator_match;
33f11d16
TH
90 __wsum csum_diff;
91};
92
93static inline __wsum compute_csum_diff8(const __be32 *from, const __be32 *to)
94{
95 __be32 diff[] = {
96 ~from[0], ~from[1], to[0], to[1],
97 };
98
99 return csum_partial(diff, sizeof(diff), 0);
100}
101
351596aa 102void ila_update_ipv6_locator(struct sk_buff *skb, struct ila_params *p);
33f11d16
TH
103
104int ila_lwt_init(void);
105void ila_lwt_fini(void);
7f00feaf
TH
106int ila_xlat_init(void);
107void ila_xlat_fini(void);
33f11d16
TH
108
109#endif /* __ILA_H */
This page took 0.049242 seconds and 5 git commands to generate.