The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/libalias/alias_sctp.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 
   75 /**
   76  * These are defined in sctp_os_bsd.h, but it can't be included due to its local file
   77  * inclusion, so I'm defining them here.
   78  *
   79  */
   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   /**< packet traveling from global to local */
  101 #define SN_TO_GLOBAL             1   /**< packet traveling from local to global */
  102 #define SN_TO_NODIR             99   /**< used where direction is not important */
  103 
  104 #define SN_NAT_PKT          0x0000   /**< Network Address Translate packet */
  105 #define SN_DROP_PKT         0x0001   /**< drop packet (don't forward it) */
  106 #define SN_PROCESSING_ERROR 0x0003   /**< Packet processing error */
  107 #define SN_REPLY_ABORT      0x0010   /**< Reply with ABORT to sender (don't forward it) */
  108 #define SN_SEND_ABORT       0x0020   /**< Send ABORT to destination */
  109 #define SN_TX_ABORT         0x0030   /**< mask for transmitting abort */
  110 #define SN_REFLECT_ERROR    0x0100   /**< Reply with ERROR to sender on OOTB packet Tbit set */
  111 #define SN_REPLY_ERROR      0x0200   /**< Reply with ERROR to sender on ASCONF clash */
  112 #define SN_TX_ERROR         0x0300   /**< mask for transmitting error */
  113 
  114 #define PKT_ALIAS_RESPOND   0x1000   /**< Signal to libalias that there is a response packet to send */
  115 /*
  116  * Data structures
  117  */
  118 
  119 /**
  120  * @brief sctp association information
  121  *
  122  * Structure that contains information about a particular sctp association
  123  * currently under Network Address Translation.
  124  * Information is stored in network byte order (as is libalias)***
  125  */
  126 struct sctp_nat_assoc {
  127         uint32_t l_vtag;                /**< local side verification tag */
  128         uint16_t l_port;                /**< local side port number */
  129         uint32_t g_vtag;                /**< global side verification tag */
  130         uint16_t g_port;                /**< global side port number */
  131         struct in_addr l_addr;          /**< local ip address */
  132         struct in_addr a_addr;          /**< alias ip address */
  133         int state;                      /**< current state of NAT association */
  134         int TableRegister;              /**< stores which look up tables association is registered in */
  135         int exp;                        /**< timer expiration in seconds from uptime */
  136         int exp_loc;                    /**< current location in timer_Q */
  137         int num_Gaddr;                  /**< number of global IP addresses in the list */
  138         LIST_HEAD(sctpGlobalAddresshead,sctp_GlobalAddress) Gaddr; /**< List of global addresses */
  139         LIST_ENTRY (sctp_nat_assoc) list_L; /**< Linked list of pointers for Local table*/
  140         LIST_ENTRY (sctp_nat_assoc) list_G; /**< Linked list of pointers for Global table */
  141         LIST_ENTRY (sctp_nat_assoc) timer_Q; /**< Linked list of pointers for timer Q */
  142         //Using libalias locking
  143 };
  144 
  145 struct sctp_GlobalAddress {
  146         struct in_addr g_addr;
  147         LIST_ENTRY (sctp_GlobalAddress) list_Gaddr; /**< Linked list of pointers for Global table */
  148 };
  149 
  150 /**
  151  * @brief SCTP chunk of interest
  152  *
  153  * The only chunks whose contents are of any interest are the INIT and ASCONF_AddIP
  154  */
  155 union sctpChunkOfInt {
  156         struct sctp_init *Init;         /**< Pointer to Init Chunk */
  157         struct sctp_init_ack *InitAck;  /**< Pointer to Init Chunk */
  158         struct sctp_paramhdr *Asconf;   /**< Pointer to ASCONF chunk */
  159 };
  160 
  161 /**
  162  * @brief SCTP message
  163  *
  164  * Structure containing the relevant information from the SCTP message
  165  */
  166 struct sctp_nat_msg {
  167         uint16_t msg;                   /**< one of the key messages defined above */
  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;              /**< pointer to ip packet header */
  172 #endif //#ifdef INET6
  173         struct sctphdr *sctp_hdr;       /**< pointer to sctp common header */
  174         union sctpChunkOfInt sctpchnk; /**< union of pointers to the chunk of interest */
  175         int chunk_length;               /**< length of chunk of interest */
  176 };
  177 
  178 /**
  179  * @brief sctp nat timer queue structure
  180  *
  181  */
  182 
  183 struct sctp_nat_timer {
  184         int loc_time;                   /**< time in seconds for the current location in the queue */
  185         int cur_loc;                    /**< index of the current location in the circular queue */
  186         LIST_HEAD(sctpTimerQ,sctp_nat_assoc) *TimerQ; /**< List of associations at this position in the timer Q */
  187 };
  188 
  189 #endif //#ifndef _ALIAS_SCTP_H

Cache object: 95b81256e820e562e360737b094b7397


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.