structs.h

来自「linux 内核源代码」· C头文件 代码 · 共 1,965 行 · 第 1/5 页

H
1,965
字号
void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port);void sctp_bind_addr_free(struct sctp_bind_addr *);int sctp_bind_addr_copy(struct sctp_bind_addr *dest,			const struct sctp_bind_addr *src,			sctp_scope_t scope, gfp_t gfp,			int flags);int sctp_bind_addr_dup(struct sctp_bind_addr *dest,			const struct sctp_bind_addr *src,			gfp_t gfp);int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,		       __u8 use_as_src, gfp_t gfp);int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,			 struct sctp_sock *);union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr	*bp,					const union sctp_addr	*addrs,					int			addrcnt,					struct sctp_sock	*opt);union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,					 int *addrs_len,					 gfp_t gfp);int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,			   __u16 port, gfp_t gfp);sctp_scope_t sctp_scope(const union sctp_addr *);int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);int sctp_is_any(const union sctp_addr *addr);int sctp_addr_is_valid(const union sctp_addr *addr);/* What type of endpoint?  */typedef enum {	SCTP_EP_TYPE_SOCKET,	SCTP_EP_TYPE_ASSOCIATION,} sctp_endpoint_type_t;/* * A common base class to bridge the implmentation view of a * socket (usually listening) endpoint versus an association's * local endpoint. * This common structure is useful for several purposes: *   1) Common interface for lookup routines. *	a) Subfunctions work for either endpoint or association *	b) Single interface to lookup allows hiding the lookup lock rather *	   than acquiring it externally. *   2) Common interface for the inbound chunk handling/state machine. *   3) Common object handling routines for reference counting, etc. *   4) Disentangle association lookup from endpoint lookup, where we *	do not have to find our endpoint to find our association. * */struct sctp_ep_common {	/* Fields to help us manage our entries in the hash tables. */	struct hlist_node node;	int hashent;	/* Runtime type information.  What kind of endpoint is this? */	sctp_endpoint_type_t type;	/* Some fields to help us manage this object.	 *   refcnt   - Reference count access to this object.	 *   dead     - Do not attempt to use this object.	 *   malloced - Do we need to kfree this object?	 */	atomic_t    refcnt;	char	    dead;	char	    malloced;	/* What socket does this endpoint belong to?  */	struct sock *sk;	/* This is where we receive inbound chunks.  */	struct sctp_inq	  inqueue;	/* This substructure includes the defining parameters of the	 * endpoint:	 * bind_addr.port is our shared port number.	 * bind_addr.address_list is our set of local IP addresses.	 */	struct sctp_bind_addr bind_addr;};/* RFC Section 1.4 Key Terms * * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a *   multi-homed host, an SCTP endpoint is represented to its peers as a *   combination of a set of eligible destination transport addresses to *   which SCTP packets can be sent and a set of eligible source *   transport addresses from which SCTP packets can be received. *   All transport addresses used by an SCTP endpoint must use the *   same port number, but can use multiple IP addresses. A transport *   address used by an SCTP endpoint must not be used by another *   SCTP endpoint. In other words, a transport address is unique *   to an SCTP endpoint. * * From an implementation perspective, each socket has one of these. * A TCP-style socket will have exactly one association on one of * these.  An UDP-style socket will have multiple associations hanging * off one of these. */struct sctp_endpoint {	/* Common substructure for endpoint and association. */	struct sctp_ep_common base;	/* Associations: A list of current associations and mappings	 *	      to the data consumers for each association. This	 *	      may be in the form of a hash table or other	 *	      implementation dependent structure. The data	 *	      consumers may be process identification	 *	      information such as file descriptors, named pipe	 *	      pointer, or table pointers dependent on how SCTP	 *	      is implemented.	 */	/* This is really a list of struct sctp_association entries. */	struct list_head asocs;	/* Secret Key: A secret key used by this endpoint to compute	 *	      the MAC.	This SHOULD be a cryptographic quality	 *	      random number with a sufficient length.	 *	      Discussion in [RFC1750] can be helpful in	 *	      selection of the key.	 */	__u8 secret_key[SCTP_HOW_MANY_SECRETS][SCTP_SECRET_SIZE];	int current_key;	int last_key;	int key_changed_at; 	/* digest:  This is a digest of the sctp cookie.  This field is 	 * 	    only used on the receive path when we try to validate 	 * 	    that the cookie has not been tampered with.  We put 	 * 	    this here so we pre-allocate this once and can re-use 	 * 	    on every receive. 	 */ 	__u8 *digest; 	/* sendbuf acct. policy.	*/	__u32 sndbuf_policy;	/* rcvbuf acct. policy.	*/	__u32 rcvbuf_policy;	/* SCTP AUTH: array of the HMACs that will be allocated	 * we need this per association so that we don't serialize	 */	struct crypto_hash **auth_hmacs;	/* SCTP-AUTH: hmacs for the endpoint encoded into parameter */	 struct sctp_hmac_algo_param *auth_hmacs_list;	/* SCTP-AUTH: chunks to authenticate encoded into parameter */	struct sctp_chunks_param *auth_chunk_list;	/* SCTP-AUTH: endpoint shared keys */	struct list_head endpoint_shared_keys;	__u16 active_key_id;};/* Recover the outter endpoint structure. */static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base){	struct sctp_endpoint *ep;	ep = container_of(base, struct sctp_endpoint, base);	return ep;}/* These are function signatures for manipulating endpoints.  */struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t);void sctp_endpoint_free(struct sctp_endpoint *);void sctp_endpoint_put(struct sctp_endpoint *);void sctp_endpoint_hold(struct sctp_endpoint *);void sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *);struct sctp_association *sctp_endpoint_lookup_assoc(	const struct sctp_endpoint *ep,	const union sctp_addr *paddr,	struct sctp_transport **);int sctp_endpoint_is_peeled_off(struct sctp_endpoint *,				const union sctp_addr *);struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *,					const union sctp_addr *);int sctp_has_association(const union sctp_addr *laddr,			 const union sctp_addr *paddr);int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t,		     sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk,		     struct sctp_chunk **err_chunk);int sctp_process_init(struct sctp_association *, sctp_cid_t cid,		      const union sctp_addr *peer,		      sctp_init_chunk_t *init, gfp_t gfp);__u32 sctp_generate_tag(const struct sctp_endpoint *);__u32 sctp_generate_tsn(const struct sctp_endpoint *);struct sctp_inithdr_host {	__u32 init_tag;	__u32 a_rwnd;	__u16 num_outbound_streams;	__u16 num_inbound_streams;	__u32 initial_tsn;};/* RFC2960 * * 12. Recommended Transmission Control Block (TCB) Parameters * * This section details a recommended set of parameters that should * be contained within the TCB for an implementation. This section is * for illustrative purposes and should not be deemed as requirements * on an implementation or as an exhaustive list of all parameters * inside an SCTP TCB. Each implementation may need its own additional * parameters for optimization. *//* Here we have information about each individual association. */struct sctp_association {	/* A base structure common to endpoint and association.	 * In this context, it represents the associations's view	 * of the local endpoint of the association.	 */	struct sctp_ep_common base;	/* Associations on the same socket. */	struct list_head asocs;	/* association id. */	sctp_assoc_t assoc_id;	/* This is our parent endpoint.	 */	struct sctp_endpoint *ep;	/* These are those association elements needed in the cookie.  */	struct sctp_cookie c;	/* This is all information about our peer.  */	struct {		/* rwnd		 *		 * Peer Rwnd   : Current calculated value of the peer's rwnd.		 */		__u32 rwnd;		/* transport_addr_list		 *		 * Peer	       : A list of SCTP transport addresses that the		 * Transport   : peer is bound to. This information is derived		 * Address     : from the INIT or INIT ACK and is used to		 * List	       : associate an inbound packet with a given		 *	       : association. Normally this information is		 *	       : hashed or keyed for quick lookup and access		 *	       : of the TCB.		 *	       : The list is also initialized with the list		 *	       : of addresses passed with the sctp_connectx()		 *	       : call.		 *		 * It is a list of SCTP_transport's.		 */		struct list_head transport_addr_list;		/* transport_count		 *		 * Peer        : A count of the number of peer addresses		 * Transport   : in the Peer Transport Address List.		 * Address     :		 * Count       :		 */		__u16 transport_count;		/* port		 *   The transport layer port number.		 */		__u16 port;		/* primary_path		 *		 * Primary     : This is the current primary destination		 * Path	       : transport address of the peer endpoint.  It		 *	       : may also specify a source transport address		 *	       : on this endpoint.		 *		 * All of these paths live on transport_addr_list.		 *		 * At the bakeoffs, we discovered that the intent of		 * primaryPath is that it only changes when the ULP		 * asks to have it changed.  We add the activePath to		 * designate the connection we are currently using to		 * transmit new data and most control chunks.		 */		struct sctp_transport *primary_path;		/* Cache the primary path address here, when we		 * need a an address for msg_name.		 */		union sctp_addr primary_addr;		/* active_path		 *   The path that we are currently using to		 *   transmit new data and most control chunks.		 */		struct sctp_transport *active_path;		/* retran_path		 *		 * RFC2960 6.4 Multi-homed SCTP Endpoints		 * ...		 * Furthermore, when its peer is multi-homed, an		 * endpoint SHOULD try to retransmit a chunk to an		 * active destination transport address that is		 * different from the last destination address to		 * which the DATA chunk was sent.		 */		struct sctp_transport *retran_path;		/* Pointer to last transport I have sent on.  */		struct sctp_transport *last_sent_to;		/* This is the last transport I have received DATA on.	*/		struct sctp_transport *last_data_from;		/*		 * Mapping  An array of bits or bytes indicating which out of		 * Array    order TSN's have been received (relative to the		 *	    Last Rcvd TSN). If no gaps exist, i.e. no out of		 *	    order packets have been received, this array		 *	    will be set to all zero. This structure may be		 *	    in the form of a circular buffer or bit array.		 *		 * Last Rcvd   : This is the last TSN received in		 * TSN	       : sequence. This value is set initially by		 *	       : taking the peer's Initial TSN, received in		 *	       : the INIT or INIT ACK chunk, and subtracting		 *	       : one from it.		 *		 * Throughout most of the specification this is called the		 * "Cumulative TSN ACK Point".	In this case, we		 * ignore the advice in 12.2 in favour of the term		 * used in the bulk of the text.  This value is hidden		 * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().		 */		struct sctp_tsnmap tsn_map;		__u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)];		/* Ack State   : This flag indicates if the next received		 *             : packet is to be responded to with a		 *             : SACK. This is initializedto 0.  When a packet		 *             : is received it is incremented. If this value		 *             : reaches 2 or more, a SACK is sent and the		 *             : value is reset to 0. Note: This is used only		 *             : when no DATA chunks are received out of		 *             : order.  When DATA chunks are out of order,		 *             : SACK's are not delayed (see Section 6).		 */		__u8    sack_needed;     /* Do we need to sack the peer? */		/* These are capabilities which our peer advertised.  */		__u8	ecn_capable;	 /* Can peer do ECN? */		__u8	ipv4_address;	 /* Peer understands IPv4 addresses? */		__u8	ipv6_address;	 /* Peer understands IPv6 addresses? */		__u8	hostname_address;/* Peer understands DNS addresses? */		__u8    asconf_capable;  /* Does peer support ADDIP? */		__u8    prsctp_capable;  /* Can peer do PR-SCTP? */		__u8	auth_capable;	 /* Is peer doing SCTP-AUTH? */		__u32   adaptation_ind;	 /* Adaptation Code point. */		/* This mask is used to disable sending the ASCONF chunk		 * with specified parameter to peer.		 */		__be16 addip_disabled_mask;		struct sctp_inithdr_host i;		int cookie_len;		void *cookie;		/* ADDIP Section 4.2 Upon reception of an ASCONF Chunk.		 * C1) ... "Peer-Serial-Number'. This value MUST be initialized to the		 * Initial TSN Value minus 1		 */		__u32 addip_serial;		/* SCTP-AUTH: We need to know pears random number, hmac list		 * and authenticated chunk list.  All that is part of the		 * cookie and these are just pointers to those locations		 */		sctp_random_param_t *peer_random;		sctp_chunks_param_t *peer_chunks;		sctp_hmac_algo_param_t *peer_hmacs;	} peer;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?