structs.h
来自「linux 内核源代码」· C头文件 代码 · 共 1,965 行 · 第 1/5 页
H
1,965 行
*/ __u16 my_port; __u8 prsctp_capable; /* Padding for future use */ __u8 padding; __u32 adaptation_ind; __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH]; __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS + 2]; __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS]; /* 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]; __u32 __pad; /* force sctp_cookie alignment to 64 bits */ struct sctp_cookie c;} __attribute__((packed));/* 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_paramhdr p; 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_adaptation_ind_param *aind; struct sctp_supported_ext_param *ext; struct sctp_random_param *random; struct sctp_chunks_param *chunks; struct sctp_hmac_algo_param *hmac_algo;};/* 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; __u64 hb_nonce;} __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, gfp_t 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, __u16 ssn){ stream->ssn[id] = ssn+1;} /* * Pointers to address related SCTP functions. * (i.e. things that depend on the address family.) */struct sctp_af { int (*sctp_xmit) (struct sk_buff *skb, struct sctp_transport *, int ipfragok); int (*setsockopt) (struct sock *sk, int level, int optname, char __user *optval, int optlen); int (*getsockopt) (struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); int (*compat_setsockopt) (struct sock *sk, int level, int optname, char __user *optval, int optlen); int (*compat_getsockopt) (struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); struct dst_entry *(*get_dst) (struct sctp_association *asoc, union sctp_addr *daddr, union sctp_addr *saddr); void (*get_saddr) (struct sctp_association *asoc, struct dst_entry *dst, union sctp_addr *daddr, union sctp_addr *saddr); void (*copy_addrlist) (struct list_head *, struct net_device *); void (*dst_saddr) (union sctp_addr *saddr, struct dst_entry *dst, __be16 port); int (*cmp_addr) (const union sctp_addr *addr1, const union sctp_addr *addr2); void (*addr_copy) (union sctp_addr *dst, union sctp_addr *src); void (*from_skb) (union sctp_addr *, struct sk_buff *skb, int saddr); void (*from_sk) (union sctp_addr *, struct sock *sk); void (*to_sk_saddr) (union sctp_addr *, struct sock *sk); void (*to_sk_daddr) (union sctp_addr *, struct sock *sk); void (*from_addr_param) (union sctp_addr *, union sctp_addr_param *, __be16 port, int iif); int (*to_addr_param) (const union sctp_addr *, union sctp_addr_param *); int (*addr_valid) (union sctp_addr *, struct sctp_sock *, const struct sk_buff *); sctp_scope_t (*scope) (union sctp_addr *); void (*inaddr_any) (union sctp_addr *, __be16); int (*is_any) (const union sctp_addr *); int (*available) (union sctp_addr *, struct sctp_sock *); int (*skb_iif) (const struct sk_buff *sk); int (*is_ce) (const struct sk_buff *sk); void (*seq_dump_addr)(struct seq_file *seq, union sctp_addr *addr); __u16 net_header_len; int sockaddr_len; sa_family_t sa_family; struct list_head list;};struct sctp_af *sctp_get_af_specific(sa_family_t);int sctp_register_af(struct sctp_af *);/* Protocol family functions. */struct sctp_pf { void (*event_msgname)(struct sctp_ulpevent *, char *, int *); void (*skb_msgname) (struct sk_buff *, char *, int *); int (*af_supported) (sa_family_t, struct sctp_sock *); int (*cmp_addr) (const union sctp_addr *, const union sctp_addr *, struct sctp_sock *); int (*bind_verify) (struct sctp_sock *, union sctp_addr *); int (*send_verify) (struct sctp_sock *, union sctp_addr *); int (*supported_addrs)(const struct sctp_sock *, __be16 *); struct sock *(*create_accept_sk) (struct sock *sk, struct sctp_association *asoc); void (*addr_v4map) (struct sctp_sock *, union sctp_addr *); struct sctp_af *af;};/* Structure to track chunk fragments that have been acked, but peer * fragments of the same message have not. */struct sctp_datamsg { /* Chunks waiting to be submitted to lower layer. */ struct list_head chunks; /* Chunks that have been transmitted. */ struct list_head track; /* Reference counting. */ atomic_t refcnt; /* When is this message no longer interesting to the peer? */ unsigned long expires_at; /* Did the messenge fail to send? */ int send_error; char send_failed; /* Control whether chunks from this message can be abandoned. */ char can_abandon;};struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *, struct sctp_sndrcvinfo *, struct msghdr *, int len);void sctp_datamsg_put(struct sctp_datamsg *);void sctp_datamsg_free(struct sctp_datamsg *);void sctp_datamsg_track(struct sctp_chunk *);void sctp_chunk_fail(struct sctp_chunk *, int error);int sctp_chunk_abandoned(struct sctp_chunk *);/* RFC2960 1.4 Key Terms * * o Chunk: A unit of information within an SCTP packet, consisting of * a chunk header and chunk-specific content. * * As a matter of convenience, we remember the SCTP common header for * each chunk as well as a few other header pointers... */struct sctp_chunk { struct list_head list; atomic_t refcnt; /* This is our link to the per-transport transmitted list. */ struct list_head transmitted_list; /* This field is used by chunks that hold fragmented data. * For the first fragment this is the list that holds the rest of * fragments. For the remaining fragments, this is the link to the * frag_list maintained in the first fragment. */ struct list_head frag_list; /* This points to the sk_buff containing the actual data. */ struct sk_buff *skb; /* These are the SCTP headers by reverse order in a packet. * Note that some of these may happen more than once. In that * case, we point at the "current" one, whatever that means * for that level of header. */ /* We point this at the FIRST TLV parameter to chunk_hdr. */ union sctp_params param_hdr; union { __u8 *v; struct sctp_datahdr *data_hdr; struct sctp_inithdr *init_hdr; struct sctp_sackhdr *sack_hdr; struct sctp_heartbeathdr *hb_hdr; struct sctp_sender_hb_info *hbs_hdr; struct sctp_shutdownhdr *shutdown_hdr; struct sctp_signed_cookie *cookie_hdr; struct sctp_ecnehdr *ecne_hdr; struct sctp_cwrhdr *ecn_cwr_hdr; struct sctp_errhdr *err_hdr; struct sctp_addiphdr *addip_hdr; struct sctp_fwdtsn_hdr *fwdtsn_hdr; struct sctp_authhdr *auth_hdr; } subh; __u8 *chunk_end; struct sctp_chunkhdr *chunk_hdr; struct sctphdr *sctp_hdr; /* This needs to be recoverable for SCTP_SEND_FAILED events. */ struct sctp_sndrcvinfo sinfo; /* Which association does this belong to? */ struct sctp_association *asoc; /* What endpoint received this chunk? */ struct sctp_ep_common *rcvr; /* We fill this in if we are calculating RTT. */ unsigned long sent_at; /* What is the origin IP address for this chunk? */ union sctp_addr source; /* Destination address for this chunk. */ union sctp_addr dest; /* For outbound message, track all fragments for SEND_FAILED. */ struct sctp_datamsg *msg; /* For an inbound chunk, this tells us where it came from. * For an outbound chunk, it tells us where we'd like it to * go. It is NULL if we have no preference. */ struct sctp_transport *transport; /* SCTP-AUTH: For the special case inbound processing of COOKIE-ECHO * we need save a pointer to the AUTH chunk, since the SCTP-AUTH * spec violates the principle premis that all chunks are processed * in order. */ struct sk_buff *auth_chunk; __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */ __u8 resent; /* Has this chunk ever been retransmitted. */ __u8 has_tsn; /* Does this chunk have a TSN yet? */ __u8 has_ssn; /* Does this chunk have a SSN yet? */ __u8 singleton; /* Was this the only chunk in the packet? */ __u8 end_of_packet; /* Was this the last chunk in the packet? */ __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */ __u8 pdiscard; /* Discard the whole packet now? */ __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */ __s8 fast_retransmit; /* Is this chunk fast retransmitted? */ __u8 tsn_missing_report; /* Data chunk missing counter. */ __u8 data_accepted; /* At least 1 chunk in this packet accepted */ __u8 auth; /* IN: was auth'ed | OUT: needs auth */};void sctp_chunk_hold(struct sctp_chunk *);void sctp_chunk_put(struct sctp_chunk *);int sctp_user_addto_chunk(struct sctp_chunk *chunk, int off, int len, struct iovec *data);void sctp_chunk_free(struct sctp_chunk *);void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data);struct sctp_chunk *sctp_chunkify(struct sk_buff *, const struct sctp_association *, struct sock *);void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *, union sctp_addr *);const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);/* This is a structure for holding either an IPv6 or an IPv4 address. */struct sctp_sockaddr_entry { struct list_head list; struct rcu_head rcu; union sctp_addr a; __u8 use_as_src; __u8 valid;};typedef struct sctp_chunk *(sctp_packet_phandler_t)(struct sctp_association *);/* This structure holds lists of chunks as we are assembling for * transmission. */struct sctp_packet { /* These are the SCTP header values (host order) for the packet. */ __u16 source_port; __u16 destination_port; __u32 vtag; /* This contains the payload chunks. */ struct list_head chunk_list; /* This is the overhead of the sctp and ip headers. */ size_t overhead; /* This is the total size of all chunks INCLUDING padding. */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?