📄 sm.h
字号:
const struct msghdr *);struct sctp_chunk *sctp_make_abort_violation(const struct sctp_association *, const struct sctp_chunk *, const __u8 *, const size_t );struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, const struct sctp_transport *, const void *payload, const size_t paylen);struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, const struct sctp_chunk *, const void *payload, const size_t paylen);struct sctp_chunk *sctp_make_op_error(const struct sctp_association *, const struct sctp_chunk *chunk, __u16 cause_code, const void *payload, size_t paylen);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_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, gfp_t gfp);/* 2nd level prototypes */void sctp_generate_t3_rtx_event(unsigned long peer);void sctp_generate_heartbeat_event(unsigned long peer);void sctp_ootb_pkt_free(struct sctp_packet *);struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *, const struct sctp_association *, struct sctp_chunk *, gfp_t gfp, int *err, struct sctp_chunk **err_chk_p);int sctp_addip_addr_config(struct sctp_association *, sctp_param_t, struct sockaddr_storage*, int);/* 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. */extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];/* 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 and the T bit is * not set, 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 Section 2.41 * * B) The receiver of a ABORT MUST accept the packet * if the Verification Tag field of the packet matches its own tag * and the T bit is not set * 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 * and the T bit is not set * 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. An endpoint MUST ignore the * SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state. */ if ((!sctp_test_T_bit(chunk) && (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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -