📄 structs.h
字号:
/* SCTP kernel reference Implementation * (C) Copyright IBM Corp. 2001, 2003 * Copyright (c) 1999-2000 Cisco, Inc. * Copyright (c) 1999-2001 Motorola, Inc. * Copyright (c) 2001 Intel Corp. * * This file is part of the SCTP kernel reference Implementation * * The SCTP reference implementation is free software; * you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * The SCTP reference implementation is distributed in the hope that it * will be useful, but WITHOUT ANY WARRANTY; without even the implied * ************************ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNU CC; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Please send any bug reports or fixes you make to the * email addresses: * lksctp developers <lksctp-developers@lists.sourceforge.net> * * Or submit a bug report through the following website: * http://www.sf.net/projects/lksctp * * Written or modified by: * Randall Stewart <randall@sctp.chicago.il.us> * Ken Morneau <kmorneau@cisco.com> * Qiaobing Xie <qxie1@email.mot.com> * La Monte H.P. Yarroll <piggy@acm.org> * Karl Knutson <karl@athena.chicago.il.us> * Jon Grimm <jgrimm@us.ibm.com> * Xingang Guo <xingang.guo@intel.com> * Hui Huang <hui.huang@nokia.com> * Sridhar Samudrala <sri@us.ibm.com> * Daisy Chang <daisyc@us.ibm.com> * Dajiang Zhang <dajiang.zhang@nokia.com> * Ardelle Fan <ardelle.fan@intel.com> * Ryan Layer <rmlayer@us.ibm.com> * Anup Pemmaiah <pemmaiah@cc.usu.edu> * Kevin Gao <kevin.gao@intel.com> * * Any bugs reported given to us we will try to fix... any fixes shared will * be incorporated into the next SCTP release. */#ifndef __sctp_structs_h__#define __sctp_structs_h__#include <linux/time.h> /* We get struct timespec. */#include <linux/socket.h> /* linux/in.h needs this!! */#include <linux/in.h> /* We get struct sockaddr_in. */#include <linux/in6.h> /* We get struct in6_addr */#include <asm/param.h> /* We get MAXHOSTNAMELEN. */#include <asm/atomic.h> /* This gets us atomic counters. */#include <linux/skbuff.h> /* We need sk_buff_head. */#include <linux/tqueue.h> /* We need tq_struct. */#include <linux/sctp.h> /* We need sctp* header structs. *//* A convenience structure for handling sockaddr structures. * We should wean ourselves off this. */union sctp_addr { struct sockaddr_in v4; struct sockaddr_in6 v6; struct sockaddr sa;};/* Forward declarations for data structures. */struct sctp_globals;struct sctp_endpoint;struct sctp_association;struct sctp_transport;struct sctp_packet;struct sctp_chunk;struct sctp_inq;struct sctp_outq;struct sctp_bind_addr;struct sctp_ulpq;struct sctp_opt;struct sctp_ep_common;struct sctp_ssnmap;#include <net/sctp/compat.h>#include <net/sctp/tsnmap.h>#include <net/sctp/ulpevent.h>#include <net/sctp/ulpqueue.h>/* Structures useful for managing bind/connect. */struct sctp_bind_bucket { unsigned short port; unsigned short fastreuse; struct sctp_bind_bucket *next; struct sctp_bind_bucket **pprev; struct sock *sk;};struct sctp_bind_hashbucket { spinlock_t lock; struct sctp_bind_bucket *chain;};/* Used for hashing all associations. */struct sctp_hashbucket { rwlock_t lock; struct sctp_ep_common *chain;} __attribute__((__aligned__(8)));/* The SCTP globals structure. */extern struct sctp_globals { /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values * * The following protocol parameters are RECOMMENDED: * * RTO.Initial - 3 seconds * RTO.Min - 1 second * RTO.Max - 60 seconds * RTO.Alpha - 1/8 (3 when converted to right shifts.) * RTO.Beta - 1/4 (2 when converted to right shifts.) */ __u32 rto_initial; __u32 rto_min; __u32 rto_max; /* Note: rto_alpha and rto_beta are really defined as inverse * powers of two to facilitate integer operations. */ int rto_alpha; int rto_beta; /* Max.Burst - 4 */ int max_burst; /* Valid.Cookie.Life - 60 seconds */ int valid_cookie_life; /* Whether Cookie Preservative is enabled(1) or not(0) */ int cookie_preserve_enable; /* Association.Max.Retrans - 10 attempts * Path.Max.Retrans - 5 attempts (per destination address) * Max.Init.Retransmits - 8 attempts */ int max_retrans_association; int max_retrans_path; int max_retrans_init; /* HB.interval - 30 seconds */ int hb_interval; /* The following variables are implementation specific. */ /* Default initialization values to be applied to new associations. */ __u16 max_instreams; __u16 max_outstreams; /* This is a list of groups of functions for each address * family that we support. */ struct list_head address_families; /* This is the hash of all endpoints. */ int ep_hashsize; struct sctp_hashbucket *ep_hashtable; /* This is the hash of all associations. */ int assoc_hashsize; struct sctp_hashbucket *assoc_hashtable; /* This is the sctp port control hash. */ int port_hashsize; int port_rover; spinlock_t port_alloc_lock; /* Protects port_rover. */ struct sctp_bind_hashbucket *port_hashtable; /* This is the global local address list. * We actively maintain this complete list of interfaces on * the system by catching routing events. * * It is a list of sctp_sockaddr_entry. */ struct list_head local_addr_list; spinlock_t local_addr_lock; /* Flag to indicate if addip is enabled. */ int addip_enable; /* Flag to indicate if PR-SCTP is enabled. */ int prsctp_enable;} sctp_globals;#define sctp_rto_initial (sctp_globals.rto_initial)#define sctp_rto_min (sctp_globals.rto_min)#define sctp_rto_max (sctp_globals.rto_max)#define sctp_rto_alpha (sctp_globals.rto_alpha)#define sctp_rto_beta (sctp_globals.rto_beta)#define sctp_max_burst (sctp_globals.max_burst)#define sctp_valid_cookie_life (sctp_globals.valid_cookie_life)#define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable)#define sctp_max_retrans_association (sctp_globals.max_retrans_association)#define sctp_max_retrans_path (sctp_globals.max_retrans_path)#define sctp_max_retrans_init (sctp_globals.max_retrans_init)#define sctp_hb_interval (sctp_globals.hb_interval)#define sctp_max_instreams (sctp_globals.max_instreams)#define sctp_max_outstreams (sctp_globals.max_outstreams)#define sctp_address_families (sctp_globals.address_families)#define sctp_ep_hashsize (sctp_globals.ep_hashsize)#define sctp_ep_hashtable (sctp_globals.ep_hashtable)#define sctp_assoc_hashsize (sctp_globals.assoc_hashsize)#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)#define sctp_port_hashsize (sctp_globals.port_hashsize)#define sctp_port_rover (sctp_globals.port_rover)#define sctp_port_alloc_lock (sctp_globals.port_alloc_lock)#define sctp_port_hashtable (sctp_globals.port_hashtable)#define sctp_local_addr_list (sctp_globals.local_addr_list)#define sctp_local_addr_lock (sctp_globals.local_addr_lock)#define sctp_addip_enable (sctp_globals.addip_enable)#define sctp_prsctp_enable (sctp_globals.prsctp_enable)/* SCTP Socket type: UDP or TCP style. */typedef enum { SCTP_SOCKET_UDP = 0, SCTP_SOCKET_UDP_HIGH_BANDWIDTH, SCTP_SOCKET_TCP} sctp_socket_type_t;/* Per socket SCTP information. */struct sctp_opt { /* What kind of a socket is this? */ sctp_socket_type_t type; /* PF_ family specific functions. */ struct sctp_pf *pf; /* Access to HMAC transform. */ struct crypto_tfm *hmac; /* What is our base endpointer? */ struct sctp_endpoint *ep; /* Various Socket Options. */ __u16 default_stream; __u32 default_ppid; __u16 default_flags; __u32 default_context; __u32 default_timetolive; struct sctp_initmsg initmsg; struct sctp_rtoinfo rtoinfo; struct sctp_paddrparams paddrparam; struct sctp_event_subscribe subscribe; struct sctp_assocparams assocparams; int user_frag; __u32 autoclose; __u8 nodelay; __u8 disable_fragments; __u8 pd_mode; __u8 v4mapped; __u32 adaption_ind; /* Receive to here while partial delivery is in effect. */ struct sk_buff_head pd_lobby;};/* This is our APPLICATION-SPECIFIC state cookie. * THIS IS NOT DICTATED BY THE SPECIFICATION. *//* These are the parts of an association which we send in the cookie. * Most of these are straight out of: * RFC2960 12.2 Parameters necessary per association (i.e. the TCB) * */struct sctp_cookie { /* My : Tag expected in every inbound packet and sent * Verification: in the INIT or INIT ACK chunk. * Tag : */ __u32 my_vtag; /* Peer's : Tag expected in every outbound packet except * Verification: in the INIT chunk. * Tag : */ __u32 peer_vtag; /* The rest of these are not from the spec, but really need to * be in the cookie. */ /* My Tie Tag : Assist in discovering a restarting association. */ __u32 my_ttag; /* Peer's Tie Tag: Assist in discovering a restarting association. */ __u32 peer_ttag; /* When does this cookie expire? */ struct timeval expiration; /* Number of inbound/outbound streams which are set * and negotiated during the INIT process. */ __u16 sinit_num_ostreams; __u16 sinit_max_instreams; /* This is the first sequence number I used. */ __u32 initial_tsn; /* This holds the originating address of the INIT packet. */ union sctp_addr peer_addr; /* IG Section 2.35.3 * Include the source port of the INIT-ACK */ __u16 my_port; __u8 prsctp_capable; /* Padding for future use */ __u8 padding; __u32 adaption_ind; /* This is a shim for my peer's INIT packet, followed by * a copy of the raw address list of the association. * The length of the raw address list is saved in the * raw_addr_list_len field, which will be used at the time when * the association TCB is re-constructed from the cookie. */ __u32 raw_addr_list_len; struct sctp_init_chunk peer_init[0];};/* The format of our cookie that we send to our peer. */struct sctp_signed_cookie { __u8 signature[SCTP_SECRET_SIZE]; struct sctp_cookie c;};/* This is another convenience type to allocate memory for address * params for the maximum size and pass such structures around * internally. */union sctp_addr_param { struct sctp_ipv4addr_param v4; struct sctp_ipv6addr_param v6;};/* A convenience type to allow walking through the various * parameters and avoid casting all over the place. */union sctp_params { void *v; struct sctp_paramhdr *p; struct sctp_cookie_preserve_param *life; struct sctp_hostname_param *dns; struct sctp_cookie_param *cookie; struct sctp_supported_addrs_param *sat; struct sctp_ipv4addr_param *v4; struct sctp_ipv6addr_param *v6; union sctp_addr_param *addr; struct sctp_adaption_ind_param *aind;};/* RFC 2960. Section 3.3.5 Heartbeat. * Heartbeat Information: variable length * The Sender-specific Heartbeat Info field should normally include * information about the sender's current time when this HEARTBEAT * chunk is sent and the destination transport address to which this * HEARTBEAT is sent (see Section 8.3). */typedef struct sctp_sender_hb_info { struct sctp_paramhdr param_hdr; union sctp_addr daddr; unsigned long sent_at;} __attribute__((packed)) sctp_sender_hb_info_t;/* * RFC 2960 1.3.2 Sequenced Delivery within Streams * * The term "stream" is used in SCTP to refer to a sequence of user * messages that are to be delivered to the upper-layer protocol in * order with respect to other messages within the same stream. This is * in contrast to its usage in TCP, where it refers to a sequence of * bytes (in this document a byte is assumed to be eight bits). * ... * * This is the structure we use to track both our outbound and inbound * SSN, or Stream Sequence Numbers. */struct sctp_stream { __u16 *ssn; unsigned int len;};struct sctp_ssnmap { struct sctp_stream in; struct sctp_stream out; int malloced;};struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, int gfp);void sctp_ssnmap_free(struct sctp_ssnmap *map);void sctp_ssnmap_clear(struct sctp_ssnmap *map);/* What is the current SSN number for this stream? */static inline __u16 sctp_ssn_peek(struct sctp_stream *stream, __u16 id){ return stream->ssn[id];}/* Return the next SSN number for this stream. */static inline __u16 sctp_ssn_next(struct sctp_stream *stream, __u16 id){ return stream->ssn[id]++;}/* Skip over this ssn and all below. */static inline void sctp_ssn_skip(struct sctp_stream *stream, __u16 id,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -