1 /* $OpenBSD: l2tp_local.h,v 1.6 2012/07/16 18:05:36 markus Exp $ */ 2 /*- 3 * Copyright (c) 2009 Internet Initiative Japan Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 #ifndef L2TP_LOCAL_H 28 #define L2TP_LOCAL_H 1 29 /* $Id: l2tp_local.h,v 1.6 2012/07/16 18:05:36 markus Exp $ */ 30 31 #ifndef GETSHORT 32 #define GETSHORT(s, cp) { \ 33 s = *(cp)++ << 8; \ 34 s |= *(cp)++; \ 35 } 36 #endif 37 38 struct l2tp_header { 39 #if BYTE_ORDER == LITTLE_ENDIAN 40 uint8_t p:1, 41 o:1, 42 x2:1, 43 s:1, 44 x1:2, 45 l:1, 46 t:1; 47 uint8_t ver:4, 48 x3:4; 49 #else 50 uint8_t t:1, 51 l:1, 52 x1:2, 53 s:1, 54 x2:1, 55 o:1, 56 p:1; 57 uint8_t x3:4, 58 ver:4; 59 #endif 60 uint16_t length; 61 uint16_t tunnel_id; 62 uint16_t session_id; 63 uint16_t ns; 64 uint16_t nr; 65 } __attribute__((__packed__)); 66 67 #ifndef countof 68 #define countof(x) (sizeof((x)) / sizeof((x)[0])) 69 #endif 70 71 #define LISTENER_SOCK(ctrl) \ 72 ((l2tpd_listener *)slist_get(&(ctrl)->l2tpd->listener, \ 73 (ctrl)->listener_index))->sock 74 #ifndef SIN 75 #define SIN(ss) ((struct sockaddr_in *)(ss)) 76 #endif 77 #define SIN6(ss) ((struct sockaddr_in6 *)(ss)) 78 79 #define L2TP_SESSION_ID_MASK 0x00007fff 80 #define L2TP_SESSION_ID_SHUFFLE_MARK 0x10000000 81 82 #ifndef L2TP_NCALL 83 #define L2TP_NCALL 10000 84 #endif 85 86 #if L2TP_NCALL > 0xffff 87 #error L2TP_NCALL must be less than 65536 88 #endif 89 90 #ifndef USE_LIBSOCKUTIL 91 struct in_ipsec_sa_cookie { 92 u_int32_t ipsecflow; 93 }; 94 #endif 95 96 #endif 97