terom@24: """ terom@24: The socket-based interface for SCTP. terom@24: terom@24: http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-15 terom@24: """ terom@24: terom@24: #from qmsk.net.libc cimport __u8, __u16, __u32, __s8, __s16, __s32, ssize_t terom@24: from qmsk.net.libc cimport * terom@24: terom@24: cimport qmsk.net.socket.platform as platform terom@24: cimport qmsk.net.socket.socket as socket terom@24: terom@24: # terom@24: # this defines the kernel SCTP -> userspace API extensions, such as structure types etc. terom@24: cdef extern from "netinet/sctp.h" : terom@24: ## types terom@24: ctypedef __s32 sctp_assoc_t terom@24: terom@24: ## constants terom@24: # sockapi terom@24: enum : terom@24: SOL_SCTP terom@24: IPPROTO_SCTP terom@24: terom@24: # sockopts terom@24: enum : terom@24: SCTP_RTOINFO terom@24: SCTP_ASSOCINFO terom@24: SCTP_INITMSG terom@24: SCTP_NODELAY terom@24: SCTP_AUTOCLOSE terom@24: SCTP_SET_PEER_PRIMARY_ADDR terom@24: SCTP_PRIMARY_ADDR terom@24: SCTP_ADAPTATION_LAYER terom@24: SCTP_DISABLE_FRAGMENTS terom@24: SCTP_PEER_ADDR_PARAMS terom@24: SCTP_DEFAULT_SEND_PARAM terom@24: SCTP_EVENTS terom@24: SCTP_I_WANT_MAPPED_V4_ADDR terom@24: SCTP_MAXSEG terom@24: SCTP_STATUS terom@24: SCTP_GET_PEER_ADDR_INFO terom@24: SCTP_DELAYED_ACK_TIME terom@24: SCTP_CONTEXT terom@24: SCTP_FRAGMENT_INTERLEAVE terom@24: SCTP_PARTIAL_DELIVERY_POINT terom@24: SCTP_MAX_BURST terom@24: terom@24: ## send/recv-msg cmsghdr's terom@24: struct sctp_initmsg : terom@24: __u16 sinit_num_ostreams terom@24: __u16 sinit_max_instreams terom@24: __u16 sinit_max_attempts terom@24: __u16 sinit_max_init_timeo terom@24: terom@24: struct sctp_sndrcvinfo : terom@24: __u16 sinfo_stream terom@24: __u16 sinfo_ssn terom@24: __u16 sinfo_flags terom@24: __u32 sinfo_ppid terom@24: __u32 sinfo_context terom@24: __u32 sinfo_timetolive terom@24: __u32 sinfo_tsn terom@24: __u32 sinfo_cumtsn terom@24: sctp_assoc_t sinfo_assoc_id terom@24: terom@24: # XXX: missing sctp_extrcvinfo terom@24: terom@24: # sctp_sndrcvinfo.sinfo_flags values terom@24: enum sctp_sinfo_flags : terom@24: SCTP_UNORDERED # Send/receive message unordered terom@24: SCTP_ADDR_OVER # Override the primary destination terom@24: SCTP_ABORT # Send an ABORT message to the peer terom@24: SCTP_EOF # Initiate graceful shutdown process terom@24: terom@24: ## notifications terom@24: struct sctp_assoc_change : terom@24: __u16 sac_type terom@24: __u16 sac_flags terom@24: __u32 sac_length terom@24: __u16 sac_state terom@24: __u16 sac_error terom@24: __u16 sac_outbound_streams terom@24: __u16 sac_inbound_streams terom@24: sctp_assoc_t sac_assoc_id terom@24: __u8 sac_info[0] terom@24: terom@24: # sctp_assoc_change.sac_state terom@24: enum sctp_sac_state : terom@24: SCTP_COMM_UP terom@24: SCTP_COMM_LOST terom@24: SCTP_RESTART terom@24: SCTP_SHUTDOWN_COMP terom@24: SCTP_CANT_STR_ASSOC terom@24: terom@24: struct sctp_paddr_change : terom@24: __u16 spc_type terom@24: __u16 spc_flags terom@24: __u32 spc_length terom@24: platform.sockaddr_storage spc_aaddr terom@24: int spc_state terom@24: int spc_error terom@24: sctp_assoc_t spc_assoc_id terom@24: terom@24: enum sctp_spc_state : terom@24: SCTP_ADDR_AVAILABLE terom@24: SCTP_ADDR_UNREACHABLE terom@24: SCTP_ADDR_REMOVED terom@24: SCTP_ADDR_ADDED terom@24: SCTP_ADDR_MADE_PRIM terom@24: SCTP_ADDR_CONFIRMED terom@24: terom@24: struct sctp_remote_error : terom@24: __u16 sre_type terom@24: __u16 sre_flags terom@24: __u32 sre_length terom@24: __u16 sre_error terom@24: sctp_assoc_t sre_assoc_id terom@24: __u8 sre_data[0] terom@24: terom@24: terom@24: struct sctp_send_failed : terom@24: __u16 ssf_type terom@24: __u16 ssf_flags terom@24: __u32 ssf_length terom@24: __u32 ssf_error terom@24: sctp_sndrcvinfo ssf_info terom@24: sctp_assoc_t ssf_assoc_id terom@24: __u8 ssf_data[0] terom@24: terom@24: enum sctp_ssf_flags : terom@24: SCTP_DATA_UNSENT terom@24: SCTP_DATA_SENT terom@24: terom@24: struct sctp_shutdown_event : terom@24: __u16 sse_type terom@24: __u16 sse_flags terom@24: __u32 sse_length terom@24: sctp_assoc_t sse_assoc_id terom@24: terom@24: struct sctp_adaptation_event : terom@24: __u16 sai_type terom@24: __u16 sai_flags terom@24: __u32 sai_length terom@24: __u32 sai_adaptation_ind terom@24: sctp_assoc_t sai_assoc_id terom@24: terom@24: struct sctp_pdapi_event : terom@24: __u16 pdapi_type terom@24: __u16 pdapi_flags terom@24: __u32 pdapi_length terom@24: __u32 pdapi_indication terom@24: sctp_assoc_t pdapi_assoc_id terom@24: terom@24: enum : terom@24: SCTP_PARTIAL_DELIVERY_ABORTED terom@24: terom@24: struct sctp_event_subscribe : terom@24: __u8 sctp_data_io_event terom@24: __u8 sctp_association_event terom@24: __u8 sctp_address_event terom@24: __u8 sctp_send_failure_event terom@24: __u8 sctp_peer_error_event terom@24: __u8 sctp_shutdown_event terom@24: __u8 sctp_partial_delivery_event terom@24: __u8 sctp_adaptation_layer_event terom@24: terom@24: struct sn_header : terom@24: __u16 sn_type terom@24: __u16 sn_flags terom@24: __u32 sn_length terom@24: terom@24: union sctp_notification : terom@24: sn_header sn_header terom@24: terom@24: sctp_assoc_change sn_assoc_change terom@24: sctp_paddr_change sn_paddr_change terom@24: sctp_remote_error sn_remote_error terom@24: sctp_send_failed sn_send_failed terom@24: sctp_shutdown_event sn_shutdown_event terom@24: sctp_adaptation_event sn_adaptation_event terom@24: sctp_pdapi_event sn_pdapi_event terom@24: terom@24: enum sctp_sn_type : terom@24: SCTP_SN_TYPE_BASE terom@24: SCTP_ASSOC_CHANGE terom@24: SCTP_PEER_ADDR_CHANGE terom@24: SCTP_SEND_FAILED terom@24: SCTP_REMOTE_ERROR terom@24: SCTP_SHUTDOWN_EVENT terom@24: SCTP_PARTIAL_DELIVERY_EVENT terom@24: SCTP_ADAPTATION_INDICATION terom@24: terom@24: enum sctp_sn_error : terom@24: SCTP_FAILED_THRESHOLD terom@24: SCTP_RECEIVED_SACK terom@24: SCTP_HEARTBEAT_SUCCESS terom@24: SCTP_RESPONSE_TO_USER_REQ terom@24: SCTP_INTERNAL_ERROR terom@24: SCTP_SHUTDOWN_GUARD_EXPIRES terom@24: SCTP_PEER_FAULTY terom@24: terom@24: ctypedef sctp_sn_error sctp_sn_error_t terom@24: terom@24: terom@24: ### terom@24: ### 8 New Interfaces terom@24: ### terom@24: terom@24: ## 8.1 sctp_bindx terom@24: enum : terom@24: SCTP_BINDX_ADD_ADDR terom@24: SCTP_BINDX_REM_ADDR terom@24: terom@24: int sctp_bindx (int sd, platform.sockaddr *addrs, int addrcnt, int flags) terom@24: terom@24: ## 8.2 sctp_peeloff terom@24: int sctp_peeloff (int sd, sctp_assoc_t assoc_id) terom@24: terom@24: ## 8.3 sctp_getpaddrs terom@24: int sctp_getpaddrs (int sd, sctp_assoc_t assoc_id, platform.sockaddr **addrs) terom@24: ## 8.4 sctp_freepaddrs terom@24: void sctp_freepaddrs (platform.sockaddr *addrs) terom@24: terom@24: ## 8.5 sctp_getladdrs terom@24: int sctp_getladdrs (int sd, sctp_assoc_t id, platform.sockaddr **ss) terom@24: ## 8.6 sctp_freeladdrs terom@24: void sctp_freeladdrs (platform.sockaddr **ss) terom@24: terom@24: ## 8.7 sctp_sendmsg terom@24: ssize_t sctp_sendmsg ( terom@24: int sd, terom@24: void *msg, size_t len, terom@24: platform.sockaddr *dst, platform.socklen_t dstlen, terom@24: uint32_t ppid, uint32_t flags, uint16_t stream_no, uint32_t timetolive, uint32_t context terom@24: ) terom@24: terom@24: ## 8.8 sctp_Recvmsg terom@24: ssize_t sctp_recvmsg ( terom@24: int sd, terom@24: void *msg, size_t len, terom@24: platform.sockaddr *src, platform.socklen_t *srclen, terom@24: sctp_sndrcvinfo *sinfo, terom@24: int *msg_flags terom@24: ) terom@24: terom@24: terom@24: ## 8.9 sctp_connectx terom@24: # XXX: missing return-sctp_assoc_t-id argument from RFC! terom@24: int sctp_connectx (int sd, platform.sockaddr *addrs, int addrcnt) terom@24: terom@24: ## 8.10 sctp_send terom@24: int sctp_send ( terom@24: int sd, terom@24: void *msg, size_t len, terom@24: sctp_sndrcvinfo *sinfo, terom@24: int flags terom@24: ) terom@24: terom@24: ## 8.11 sctp_sendx terom@24: int sctp_sendx ( terom@24: int sd, terom@24: void *msg, size_t len, terom@24: platform.sockaddr *addrs, int addrcnt, terom@24: sctp_sndrcvinfo *sinfo, terom@24: int flags terom@24: ) terom@24: terom@24: ## 8.12 sctp_getaddrlen terom@24: int sctp_getaddrlen (platform.sa_family_t family) terom@24: terom@24: cdef class sctp_socket (socket.socket) : terom@24: """ terom@24: SCTP-specific methods and functionality, built on top of the generic socket interface. terom@24: """ terom@24: terom@24: