OMAP3430SDP: Enable config options CONFIG_OMAP_RESET_CLOCKS and CONFIG_SUSPEND
[linux-ginger.git] / net / ipv4 / ipvs / ip_vs_proto_ah.c
blob4bf835e1d86de7535667ebb1357e1237e0849e81
1 /*
2 * ip_vs_proto_ah.c: AH IPSec load balancing support for IPVS
4 * Version: $Id: ip_vs_proto_ah.c,v 1.1 2003/07/04 15:04:37 wensong Exp $
6 * Authors: Julian Anastasov <ja@ssi.bg>, February 2002
7 * Wensong Zhang <wensong@linuxvirtualserver.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation;
15 #include <linux/in.h>
16 #include <linux/ip.h>
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/netfilter.h>
20 #include <linux/netfilter_ipv4.h>
22 #include <net/ip_vs.h>
25 /* TODO:
27 struct isakmp_hdr {
28 __u8 icookie[8];
29 __u8 rcookie[8];
30 __u8 np;
31 __u8 version;
32 __u8 xchgtype;
33 __u8 flags;
34 __u32 msgid;
35 __u32 length;
40 #define PORT_ISAKMP 500
43 static struct ip_vs_conn *
44 ah_conn_in_get(const struct sk_buff *skb,
45 struct ip_vs_protocol *pp,
46 const struct iphdr *iph,
47 unsigned int proto_off,
48 int inverse)
50 struct ip_vs_conn *cp;
52 if (likely(!inverse)) {
53 cp = ip_vs_conn_in_get(IPPROTO_UDP,
54 iph->saddr,
55 htons(PORT_ISAKMP),
56 iph->daddr,
57 htons(PORT_ISAKMP));
58 } else {
59 cp = ip_vs_conn_in_get(IPPROTO_UDP,
60 iph->daddr,
61 htons(PORT_ISAKMP),
62 iph->saddr,
63 htons(PORT_ISAKMP));
66 if (!cp) {
68 * We are not sure if the packet is from our
69 * service, so our conn_schedule hook should return NF_ACCEPT
71 IP_VS_DBG(12, "Unknown ISAKMP entry for outin packet "
72 "%s%s %u.%u.%u.%u->%u.%u.%u.%u\n",
73 inverse ? "ICMP+" : "",
74 pp->name,
75 NIPQUAD(iph->saddr),
76 NIPQUAD(iph->daddr));
79 return cp;
83 static struct ip_vs_conn *
84 ah_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
85 const struct iphdr *iph, unsigned int proto_off, int inverse)
87 struct ip_vs_conn *cp;
89 if (likely(!inverse)) {
90 cp = ip_vs_conn_out_get(IPPROTO_UDP,
91 iph->saddr,
92 htons(PORT_ISAKMP),
93 iph->daddr,
94 htons(PORT_ISAKMP));
95 } else {
96 cp = ip_vs_conn_out_get(IPPROTO_UDP,
97 iph->daddr,
98 htons(PORT_ISAKMP),
99 iph->saddr,
100 htons(PORT_ISAKMP));
103 if (!cp) {
104 IP_VS_DBG(12, "Unknown ISAKMP entry for inout packet "
105 "%s%s %u.%u.%u.%u->%u.%u.%u.%u\n",
106 inverse ? "ICMP+" : "",
107 pp->name,
108 NIPQUAD(iph->saddr),
109 NIPQUAD(iph->daddr));
112 return cp;
116 static int
117 ah_conn_schedule(struct sk_buff *skb,
118 struct ip_vs_protocol *pp,
119 int *verdict, struct ip_vs_conn **cpp)
122 * AH is only related traffic. Pass the packet to IP stack.
124 *verdict = NF_ACCEPT;
125 return 0;
129 static void
130 ah_debug_packet(struct ip_vs_protocol *pp, const struct sk_buff *skb,
131 int offset, const char *msg)
133 char buf[256];
134 struct iphdr _iph, *ih;
136 ih = skb_header_pointer(skb, offset, sizeof(_iph), &_iph);
137 if (ih == NULL)
138 sprintf(buf, "%s TRUNCATED", pp->name);
139 else
140 sprintf(buf, "%s %u.%u.%u.%u->%u.%u.%u.%u",
141 pp->name, NIPQUAD(ih->saddr),
142 NIPQUAD(ih->daddr));
144 printk(KERN_DEBUG "IPVS: %s: %s\n", msg, buf);
148 static void ah_init(struct ip_vs_protocol *pp)
150 /* nothing to do now */
154 static void ah_exit(struct ip_vs_protocol *pp)
156 /* nothing to do now */
160 struct ip_vs_protocol ip_vs_protocol_ah = {
161 .name = "AH",
162 .protocol = IPPROTO_AH,
163 .num_states = 1,
164 .dont_defrag = 1,
165 .init = ah_init,
166 .exit = ah_exit,
167 .conn_schedule = ah_conn_schedule,
168 .conn_in_get = ah_conn_in_get,
169 .conn_out_get = ah_conn_out_get,
170 .snat_handler = NULL,
171 .dnat_handler = NULL,
172 .csum_check = NULL,
173 .state_transition = NULL,
174 .register_app = NULL,
175 .unregister_app = NULL,
176 .app_conn_bind = NULL,
177 .debug_packet = ah_debug_packet,
178 .timeout_change = NULL, /* ISAKMP */
179 .set_state_timeout = NULL,