sm.h
来自「优龙2410linux2.6.8内核源代码」· C头文件 代码 · 共 496 行 · 第 1/2 页
H
496 行
struct sctp_chunk *sctp_make_asconf(struct sctp_association *asoc, union sctp_addr *addr, int vparam_len);struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *, union sctp_addr *, struct sockaddr *, int, __u16);struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc, union sctp_addr *addr);struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc, __u32 serial, int vparam_len);struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, struct sctp_chunk *asconf);int sctp_process_asconf_ack(struct sctp_association *asoc, struct sctp_chunk *asconf_ack);struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, __u32 new_cum_tsn, size_t nstreams, struct sctp_fwdtsn_skip *skiplist);void sctp_chunk_assign_tsn(struct sctp_chunk *);void sctp_chunk_assign_ssn(struct sctp_chunk *);/* Prototypes for statetable processing. */int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, sctp_state_t state, struct sctp_endpoint *, struct sctp_association *asoc, void *event_arg, int gfp);int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, sctp_state_t state, struct sctp_endpoint *, struct sctp_association *asoc, void *event_arg, sctp_disposition_t status, sctp_cmd_seq_t *commands, int gfp);/* 2nd level prototypes */int sctp_cmd_interpreter(sctp_event_t, sctp_subtype_t, sctp_state_t, struct sctp_endpoint *, struct sctp_association *, void *event_arg, sctp_disposition_t, sctp_cmd_seq_t *retval, int gfp);int sctp_gen_sack(struct sctp_association *, int force, sctp_cmd_seq_t *);void sctp_generate_t3_rtx_event(unsigned long peer);void sctp_generate_heartbeat_event(unsigned long peer);sctp_sackhdr_t *sctp_sm_pull_sack(struct sctp_chunk *);struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *, const struct sctp_association *, struct sctp_chunk *chunk, const void *payload, size_t paylen);struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *, const struct sctp_chunk *);void sctp_ootb_pkt_free(struct sctp_packet *);struct sctp_cookie_param *sctp_pack_cookie(const struct sctp_endpoint *, const struct sctp_association *, const struct sctp_chunk *, int *cookie_len, const __u8 *, int addrs_len);struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *, const struct sctp_association *, struct sctp_chunk *, int gfp, int *err, struct sctp_chunk **err_chk_p);int sctp_addip_addr_config(struct sctp_association *, sctp_param_t, struct sockaddr_storage*, int);void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const struct sctp_chunk *chunk, sctp_cmd_seq_t *commands, struct sctp_chunk *err_chunk);int sctp_eat_data(const struct sctp_association *asoc, struct sctp_chunk *chunk, sctp_cmd_seq_t *commands);/* 3rd level prototypes */__u32 sctp_generate_tag(const struct sctp_endpoint *);__u32 sctp_generate_tsn(const struct sctp_endpoint *);/* Extern declarations for major data structures. */const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t, sctp_state_t);extern const sctp_sm_table_entry_tprimitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];extern const sctp_sm_table_entry_tother_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];extern const sctp_sm_table_entry_ttimeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];/* These are some handy utility macros... *//* Get the size of a DATA chunk payload. */static inline __u16 sctp_data_size(struct sctp_chunk *chunk){ __u16 size; size = ntohs(chunk->chunk_hdr->length); size -= sizeof(sctp_data_chunk_t); return size;}/* Compare two TSNs *//* RFC 1982 - Serial Number Arithmetic * * 2. Comparison * Then, s1 is said to be equal to s2 if and only if i1 is equal to i2, * in all other cases, s1 is not equal to s2. * * s1 is said to be less than s2 if, and only if, s1 is not equal to s2, * and * * (i1 < i2 and i2 - i1 < 2^(SERIAL_BITS - 1)) or * (i1 > i2 and i1 - i2 > 2^(SERIAL_BITS - 1)) * * s1 is said to be greater than s2 if, and only if, s1 is not equal to * s2, and * * (i1 < i2 and i2 - i1 > 2^(SERIAL_BITS - 1)) or * (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1)) *//* * RFC 2960 * 1.6 Serial Number Arithmetic * * Comparisons and arithmetic on TSNs in this document SHOULD use Serial * Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 32. */enum { TSN_SIGN_BIT = (1<<31)};static inline int TSN_lt(__u32 s, __u32 t){ return (((s) - (t)) & TSN_SIGN_BIT);}static inline int TSN_lte(__u32 s, __u32 t){ return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT));}/* Compare two SSNs *//* * RFC 2960 * 1.6 Serial Number Arithmetic * * Comparisons and arithmetic on Stream Sequence Numbers in this document * SHOULD use Serial Number Arithmetic as defined in [RFC1982] where * SERIAL_BITS = 16. */enum { SSN_SIGN_BIT = (1<<15)};static inline int SSN_lt(__u16 s, __u16 t){ return (((s) - (t)) & SSN_SIGN_BIT);}static inline int SSN_lte(__u16 s, __u16 t){ return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT));}/* * ADDIP 3.1.1 * The valid range of Serial Number is from 0 to 4294967295 (2**32 - 1). Serial * Numbers wrap back to 0 after reaching 4294967295. */enum { ADDIP_SERIAL_SIGN_BIT = (1<<31)};static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t){ return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT));}/* Run sctp_add_cmd() generating a BUG() if there is a failure. */static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj){ if (unlikely(!sctp_add_cmd(seq, verb, obj))) BUG();}/* Check VTAG of the packet matches the sender's own tag. */static inline intsctp_vtag_verify(const struct sctp_chunk *chunk, const struct sctp_association *asoc){ /* RFC 2960 Sec 8.5 When receiving an SCTP packet, the endpoint * MUST ensure that the value in the Verification Tag field of * the received SCTP packet matches its own Tag. If the received * Verification Tag value does not match the receiver's own * tag value, the receiver shall silently discard the packet... */ if (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag) return 1; return 0;}/* Check VTAG of the packet matches the sender's own tag OR its peer's * tag and the T bit is set in the Chunk Flags. */static inline intsctp_vtag_verify_either(const struct sctp_chunk *chunk, const struct sctp_association *asoc){ /* RFC 2960 Section 8.5.1, sctpimpguide-06 Section 2.13.2 * * B) The receiver of a ABORT shall accept the packet if the * Verification Tag field of the packet matches its own tag OR it * is set to its peer's tag and the T bit is set in the Chunk * Flags. Otherwise, the receiver MUST silently discard the packet * and take no further action. * * (C) The receiver of a SHUTDOWN COMPLETE shall accept the * packet if the Verification Tag field of the packet * matches its own tag OR it is set to its peer's tag and * the T bit is set in the Chunk Flags. Otherwise, the * receiver MUST silently discard the packet and take no * further action.... * */ if ((ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag) || (sctp_test_T_bit(chunk) && (ntohl(chunk->sctp_hdr->vtag) == asoc->c.peer_vtag))) { return 1; } return 0;}#endif /* __sctp_sm_h__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?