ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / net / xfrm / xfrm_output.c
1 /* 
2  * generic xfrm output routines
3  *
4  * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; either version 2 of the License, or (at your option) 
9  * any later version.
10  */
11 #include <linux/config.h>
12 #include <linux/kernel.h>
13 #include <linux/skbuff.h>
14 #include <net/xfrm.h>
15
16 int xfrm_check_output(struct xfrm_state *x,
17                       struct sk_buff *skb, unsigned short family)
18 {
19         int err;
20         
21         err = xfrm_state_check_expire(x);
22         if (err)
23                 goto out;
24                 
25         if (x->props.mode) {
26                 switch (family) {
27                 case AF_INET:
28                         err = xfrm4_tunnel_check_size(skb);
29                         break;
30                         
31                 case AF_INET6:
32                         err = xfrm6_tunnel_check_size(skb);
33                         break;
34                         
35                 default:
36                         err = -EINVAL;
37                 }
38                 
39                 if (err)
40                         goto out;
41         }
42
43         err = xfrm_state_check_space(x, skb);
44 out:
45         return err;
46 }