FreeBSD kernel IPv4 code
alias_sctp.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2008
5 * Swinburne University of Technology, Melbourne, Australia.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/*
30 * Alias_sctp forms part of the libalias kernel module to handle
31 * Network Address Translation (NAT) for the SCTP protocol.
32 *
33 * This software was developed by David A. Hayes
34 * with leadership and advice from Jason But
35 *
36 * The design is outlined in CAIA technical report number 080618A
37 * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW")
38 *
39 * Development is part of the CAIA SONATA project,
40 * proposed by Jason But and Grenville Armitage:
41 * http://caia.swin.edu.au/urp/sonata/
42 *
43 *
44 * This project has been made possible in part by a grant from
45 * the Cisco University Research Program Fund at Community
46 * Foundation Silicon Valley.
47 *
48 */
49
50/* $FreeBSD$ */
51
52#ifndef _ALIAS_SCTP_H_
53#define _ALIAS_SCTP_H_
54
55#include <sys/param.h>
56#ifdef _KERNEL
57#include <sys/malloc.h>
58#include <sys/module.h>
59#include <sys/kernel.h>
60#include <sys/proc.h>
61#include <sys/uio.h>
62#include <sys/socketvar.h>
63#include <sys/syslog.h>
64#endif // #ifdef _KERNEL
65#include <sys/types.h>
66
67#include <sys/queue.h>
68#include <sys/types.h>
69#include <sys/time.h>
70
71#include <netinet/in_systm.h>
72#include <netinet/in.h>
73#include <netinet/ip.h>
74
80#include <machine/cpufunc.h>
81/* The packed define for 64 bit platforms */
82#ifndef SCTP_PACKED
83#define SCTP_PACKED __attribute__((packed))
84#endif //#ifndef SCTP_PACKED
85#ifndef SCTP_UNUSED
86#define SCTP_UNUSED __attribute__((unused))
87#endif //#ifndef SCTP_UNUSED
88
89#include <netinet/sctp.h>
90//#include <netinet/sctp_os_bsd.h> --might be needed later for mbuf stuff
91#include <netinet/sctp_header.h>
92
93#ifndef _KERNEL
94#include <stdlib.h>
95#include <stdio.h>
96#endif //#ifdef _KERNEL
97
98#define LINK_SCTP IPPROTO_SCTP
99
100#define SN_TO_LOCAL 0
101#define SN_TO_GLOBAL 1
102#define SN_TO_NODIR 99
104#define SN_NAT_PKT 0x0000
105#define SN_DROP_PKT 0x0001
106#define SN_PROCESSING_ERROR 0x0003
107#define SN_REPLY_ABORT 0x0010
108#define SN_SEND_ABORT 0x0020
109#define SN_TX_ABORT 0x0030
110#define SN_REFLECT_ERROR 0x0100
111#define SN_REPLY_ERROR 0x0200
112#define SN_TX_ERROR 0x0300
114#define PKT_ALIAS_RESPOND 0x1000
115/*
116 * Data structures
117 */
118
133 int state;
135 int exp;
138 LIST_HEAD(sctpGlobalAddresshead,sctp_GlobalAddress) Gaddr;
142 //Using libalias locking
143};
144
148};
149
156 struct sctp_init *Init;
159};
160
168#ifdef INET6
169 // struct ip6_hdr *ip_hdr; /**< pointer to ip packet header */ /*no inet6 support yet*/
170#else
171 struct ip *ip_hdr;
172#endif //#ifdef INET6
176};
177
186 LIST_HEAD(sctpTimerQ,sctp_nat_assoc) *TimerQ;
187};
188
189#endif //#ifndef _ALIAS_SCTP_H
__uint32_t uint32_t
Definition: in.h:62
__uint16_t uint16_t
Definition: in.h:57
#define sctp_init_ack
Definition: sctp_header.h:234
Definition: in.h:83
Definition: ip.h:51
struct in_addr g_addr
Definition: alias_sctp.h:146
LIST_ENTRY(sctp_GlobalAddress) list_Gaddr
sctp association information
Definition: alias_sctp.h:126
LIST_ENTRY(sctp_nat_assoc) list_L
struct in_addr a_addr
Definition: alias_sctp.h:132
LIST_ENTRY(sctp_nat_assoc) timer_Q
uint16_t g_port
Definition: alias_sctp.h:130
struct in_addr l_addr
Definition: alias_sctp.h:131
LIST_ENTRY(sctp_nat_assoc) list_G
uint32_t l_vtag
Definition: alias_sctp.h:127
uint16_t l_port
Definition: alias_sctp.h:128
uint32_t g_vtag
Definition: alias_sctp.h:129
LIST_HEAD(sctpGlobalAddresshead, sctp_GlobalAddress) Gaddr
SCTP message.
Definition: alias_sctp.h:166
int chunk_length
Definition: alias_sctp.h:175
union sctpChunkOfInt sctpchnk
Definition: alias_sctp.h:174
uint16_t msg
Definition: alias_sctp.h:167
struct ip * ip_hdr
Definition: alias_sctp.h:171
struct sctphdr * sctp_hdr
Definition: alias_sctp.h:173
sctp nat timer queue structure
Definition: alias_sctp.h:183
LIST_HEAD(sctpTimerQ, sctp_nat_assoc) *TimerQ
Definition: sctp.h:48
SCTP chunk of interest.
Definition: alias_sctp.h:155
struct sctp_init_ack * InitAck
Definition: alias_sctp.h:157
struct sctp_paramhdr * Asconf
Definition: alias_sctp.h:158
struct sctp_init * Init
Definition: alias_sctp.h:156