📄 structs.h
字号:
* using SCTP_SET_PEER_ADDR_PARAMS socket option. */ int max_retrans; /* Per : A timer used by each destination. * Destination : * Timer : * * [Everywhere else in the text this is called T3-rtx. -ed] */ struct timer_list T3_rtx_timer; /* Heartbeat timer is per destination. */ struct timer_list hb_timer; /* Since we're using per-destination retransmission timers * (see above), we're also using per-destination "transmitted" * queues. This probably ought to be a private struct * accessible only within the outqueue, but it's not, yet. */ struct list_head transmitted; /* We build bundle-able packets for this transport here. */ struct sctp_packet packet; /* This is the list of transports that have chunks to send. */ struct list_head send_ready; int malloced; /* Is this structure kfree()able? */ /* State information saved for SFR_CACC algorithm. The key * idea in SFR_CACC is to maintain state at the sender on a * per-destination basis when a changeover happens. * char changeover_active; * char cycling_changeover; * __u32 next_tsn_at_change; * char cacc_saw_newack; */ struct { /* An unsigned integer, which stores the next TSN to be * used by the sender, at the moment of changeover. */ __u32 next_tsn_at_change; /* A flag which indicates the occurrence of a changeover */ char changeover_active; /* A flag which indicates whether the change of primary is * the first switch to this destination address during an * active switch. */ char cycling_changeover; /* A temporary flag, which is used during the processing of * a SACK to estimate the causative TSN(s)'s group. */ char cacc_saw_newack; } cacc;};struct sctp_transport *sctp_transport_new(const union sctp_addr *, int);void sctp_transport_set_owner(struct sctp_transport *, struct sctp_association *);void sctp_transport_route(struct sctp_transport *, union sctp_addr *, struct sctp_sock *);void sctp_transport_pmtu(struct sctp_transport *);void sctp_transport_free(struct sctp_transport *);void sctp_transport_reset_timers(struct sctp_transport *);void sctp_transport_hold(struct sctp_transport *);void sctp_transport_put(struct sctp_transport *);void sctp_transport_update_rto(struct sctp_transport *, __u32);void sctp_transport_raise_cwnd(struct sctp_transport *, __u32, __u32);void sctp_transport_lower_cwnd(struct sctp_transport *, sctp_lower_cwnd_t);unsigned long sctp_transport_timeout(struct sctp_transport *);/* This is the structure we use to queue packets as they come into * SCTP. We write packets to it and read chunks from it. */struct sctp_inq { /* This is actually a queue of sctp_chunk each * containing a partially decoded packet. */ struct sk_buff_head in; /* This is the packet which is currently off the in queue and is * being worked on through the inbound chunk processing. */ struct sctp_chunk *in_progress; /* This is the delayed task to finish delivering inbound * messages. */ struct work_struct immediate; int malloced; /* Is this structure kfree()able? */};void sctp_inq_init(struct sctp_inq *);void sctp_inq_free(struct sctp_inq *);void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);void sctp_inq_set_th_handler(struct sctp_inq *, void (*)(void *), void *);/* This is the structure we use to hold outbound chunks. You push * chunks in and they automatically pop out the other end as bundled * packets (it calls (*output_handler)()). * * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1, * and 8.2 of the v13 draft. * * It handles retransmissions. The connection to the timeout portion * of the state machine is through sctp_..._timeout() and timeout_handler. * * If you feed it SACKs, it will eat them. * * If you give it big chunks, it will fragment them. * * It assigns TSN's to data chunks. This happens at the last possible * instant before transmission. * * When free()'d, it empties itself out via output_handler(). */struct sctp_outq { struct sctp_association *asoc; /* Data pending that has never been transmitted. */ struct sk_buff_head out; unsigned out_qlen; /* Total length of queued data chunks. */ /* Error of send failed, may used in SCTP_SEND_FAILED event. */ unsigned error; /* These are control chunks we want to send. */ struct sk_buff_head control; /* These are chunks that have been sacked but are above the * CTSN, or cumulative tsn ack point. */ struct list_head sacked; /* Put chunks on this list to schedule them for * retransmission. */ struct list_head retransmit; /* Put chunks on this list to save them for FWD TSN processing as * they were abandoned. */ struct list_head abandoned; /* How many unackd bytes do we have in-flight? */ __u32 outstanding_bytes; /* Corked? */ char cork; /* Is this structure empty? */ char empty; /* Are we kfree()able? */ char malloced;};void sctp_outq_init(struct sctp_association *, struct sctp_outq *);void sctp_outq_teardown(struct sctp_outq *);void sctp_outq_free(struct sctp_outq*);int sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk);int sctp_outq_flush(struct sctp_outq *, int);int sctp_outq_sack(struct sctp_outq *, struct sctp_sackhdr *);int sctp_outq_is_empty(const struct sctp_outq *);void sctp_outq_restart(struct sctp_outq *);void sctp_retransmit(struct sctp_outq *, struct sctp_transport *, sctp_retransmit_reason_t);void sctp_retransmit_mark(struct sctp_outq *, struct sctp_transport *, __u8);int sctp_outq_uncork(struct sctp_outq *);/* Uncork and flush an outqueue. */static inline void sctp_outq_cork(struct sctp_outq *q){ q->cork = 1;}/* These bind address data fields common between endpoints and associations */struct sctp_bind_addr { /* RFC 2960 12.1 Parameters necessary for the SCTP instance * * SCTP Port: The local SCTP port number the endpoint is * bound to. */ __u16 port; /* RFC 2960 12.1 Parameters necessary for the SCTP instance * * Address List: The list of IP addresses that this instance * has bound. This information is passed to one's * peer(s) in INIT and INIT ACK chunks. */ struct list_head address_list; int malloced; /* Are we kfree()able? */};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, int gfp,int flags);int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, int 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, int gfp);int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, __u16 port, int 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 sctp_ep_common *next; struct sctp_ep_common **pprev; 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; /* Protection during address list comparisons. */ rwlock_t addr_lock;};/* 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; /* Default timeouts. */ int timeouts[SCTP_NUM_TIMEOUT_TYPES]; /* Various thresholds. */ /* Name for debugging output... */ char *debug_name;};/* 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 *, int);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, int gfp);__u32 sctp_generate_tag(const struct sctp_endpoint *);__u32 sctp_generate_tsn(const struct sctp_endpoint *);/* 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. * * It is a list of SCTP_transport's. */ struct list_head transport_addr_list; /* port * The transport layer port number. */ __u16 port;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -