123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- #ifndef SP_SES_H
- #define SP_SES_H
- #pragma once
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include "refcnt.h"
- #include "y2k_time.h"
- typedef struct sp_svc_t sp_svc_t;
- typedef struct iobuffer_t iobuffer_t;
- typedef struct sp_ses_mgr_t sp_ses_mgr_t;
- typedef struct sp_ses_uac_t sp_ses_uac_t;
- typedef struct sp_ses_uas_t sp_ses_uas_t;
- typedef struct sp_tsx_uac_t sp_tsx_uac_t;
- typedef struct sp_tsx_uas_t sp_tsx_uas_t;
- /** session mgr (both client session and server session ) */
- typedef struct sp_ses_mgr_callback_t {
- int (*on_accept)(sp_ses_mgr_t *mgr, int epid, int svc_id, int conn_id, iobuffer_t **conn_pkt, int *redirect_target, void *user_data);
- void (*on_destroy)(sp_ses_mgr_t *mgr, void *user_data);
- void *user_data;
- }sp_ses_mgr_callback_t;
- int sp_ses_mgr_create(sp_svc_t *svc, sp_ses_mgr_callback_t *cb, sp_ses_mgr_t **p_mgr);
- void sp_ses_mgr_destroy(sp_ses_mgr_t *mgr);
- int sp_ses_mgr_cancel_all(sp_ses_mgr_t *mgr);
- int sp_ses_mgr_get_conn_cnt(sp_ses_mgr_t *mgr);
- int sp_ses_mgr_start(sp_ses_mgr_t *mgr);
- int sp_ses_mgr_stop(sp_ses_mgr_t *mgr);
- sp_svc_t *sp_ses_mgr_get_svc(sp_ses_mgr_t *mgr);
- typedef struct sp_ses_info_t
- {
- int from_svc_id;
- int to_svc_id;
- y2k_time_t begin_time;
- int state;
- y2k_time_t state_begin_time;
- }sp_ses_info_t;
- sp_ses_info_t* sp_ses_mgr_get_ses_info(sp_ses_mgr_t *mgr, int *cnt);
- #define SP_SES_STATE_INIT 1
- #define SP_SES_STATE_CONNECTING 2
- #define SP_SES_STATE_CONNECTED 3
- #define SP_SES_STATE_TERM 4
- #define SP_SES_STATE_ERROR 5
- /** client session */
- typedef struct sp_ses_uac_callback {
- void (*on_connect)(sp_ses_uac_t *uac, int error, void *user_data);
- void (*on_close)(sp_ses_uac_t *uac, int error, void *user_data);
- void (*on_destroy)(sp_ses_uac_t *uac, void *user_data);
- void *user_data;
- }sp_ses_uac_callback;
- int sp_ses_uac_create(sp_ses_mgr_t *mgr, int remote_epid, int remote_svc_id, sp_ses_uac_callback *cb, sp_ses_uac_t **p_ses);
- void sp_ses_uac_destroy(sp_ses_uac_t *uac);
- int sp_ses_uac_async_connect(sp_ses_uac_t *uac, int timeout, iobuffer_t **conn_pkt);
- int sp_ses_uac_close(sp_ses_uac_t *uac);
- int sp_ses_uac_get_state(sp_ses_uac_t *uac);
- int sp_ses_uac_send_info(sp_ses_uac_t *uac, int method_id, int method_sig, iobuffer_t **info_pkt);
- int sp_ses_uac_get_remote_epid(sp_ses_uac_t *uac);
- int sp_ses_uac_get_remote_svc_id(sp_ses_uac_t *uac);
- int sp_ses_uac_get_conn_id(sp_ses_uac_t *uac);
- sp_ses_mgr_t *sp_ses_uac_get_mgr(sp_ses_uac_t *uac);
- int sp_ses_uac_get_tsx_cnt(sp_ses_uac_t *uac);
- /** server session */
- typedef struct sp_ses_uas_callback {
- int (*get_method_attr)(sp_ses_uas_t *uas, int method_id, int method_sig, int *overlap, void *user_data);
- void (*on_req)(sp_ses_uas_t *uas, int tsx_id, int method_id, int method_sig, int timeout, iobuffer_t **req_pkt, void *user_data);
- void (*on_info)(sp_ses_uas_t *uas, int method_id, int method_sig, iobuffer_t **info_pkt, void *user_data);
- void (*on_close)(sp_ses_uas_t *uas, int error, void *user_data);
- void (*on_destroy)(sp_ses_uas_t *uas, void *user_data);
- void *user_data;
- }sp_ses_uas_callback;
- int sp_ses_uas_create(sp_ses_mgr_t *mgr, int remote_epid, int remote_svc_id, int conn_id, int overlap, sp_ses_uas_callback *cb, sp_ses_uas_t **p_uas);
- void sp_ses_uas_destroy(sp_ses_uas_t *uas);
- int sp_ses_uas_close(sp_ses_uas_t *uas);
- int sp_ses_uas_get_remote_epid(sp_ses_uas_t *uas);
- int sp_ses_uas_get_remote_svc_id(sp_ses_uas_t *uas);
- int sp_ses_uas_get_conn_id(sp_ses_uas_t *uas);
- sp_ses_mgr_t *sp_ses_uas_get_mgr(sp_ses_uas_t *uas);
- int sp_ses_uas_get_state(sp_ses_uas_t *uas);
- int sp_ses_uas_get_tsx_cnt(sp_ses_uas_t *uas);
- int sp_ses_uas_accept(sp_ses_uas_t *uas);
- /* transaction */
- /* client side transaction */
- /*
- create +----------+ req +----------+ on_ans +----------+ on_ans +----------+ close +----------+
- --------> | INIT | --------> | REQ | --------> | TMPANS | --------> | ANS | --------> | TERM |
- +----------+ +----------+ +----------+ +----------+ +----------+
- */
- #define SP_TSX_UAC_STATE_INIT 1
- #define SP_TSX_UAC_STATE_TERM 2
- #define SP_TSX_UAC_STATE_REQ 3
- #define SP_TSX_UAC_STATE_ANS 4
- #define SP_TSX_UAC_STATE_TMPANS 5
- #define SP_TSX_UAC_STATE_ERROR 6
- typedef struct sp_tsx_uac_callback {
- void (*on_ans)(sp_tsx_uac_t *tsx, int error, int end, iobuffer_t **ans_pkt, void *user_data);
- void (*on_destroy)(sp_tsx_uac_t *tsx, void *user_data);
- void *user_data;
- }sp_tsx_uac_callback;
- int sp_tsx_uac_create(sp_ses_uac_t *uac, int tsx_id, int method_id, int method_sig, sp_tsx_uac_callback *cb, sp_tsx_uac_t **p_tsx);
- void sp_tsx_uac_destroy(sp_tsx_uac_t *tsx);
- int sp_tsx_uac_async_req(sp_tsx_uac_t *tsx, int timeout, iobuffer_t **req_pkt);
- int sp_tsx_uac_close(sp_tsx_uac_t *tsx);
- sp_ses_uac_t *sp_tsx_uac_get_session(sp_tsx_uac_t *tsx);
- int sp_tsx_uac_get_state(sp_tsx_uac_t *tsx);
- int sp_tsx_uac_get_id(sp_tsx_uac_t *tsx);
- /* server side transaction */
- /*
- create +----------+ answer +----------+ answer +----------+ close +----------+
- -------->| INIT | --------> | TMPANS | --------> | ANS | --------> | TERM |
- +----------+ +----------+ +----------+ +----------+
- */
- #define SP_TSX_UAS_STATE_INIT 1
- #define SP_TSX_UAS_STATE_TMPANS 2
- #define SP_TSX_UAS_STATE_ANS 3
- #define SP_TSX_UAS_STATE_TERM 4
- #define SP_TSX_UAS_STATE_ERROR 5
- typedef struct sp_tsx_uas_callback {
- void (*on_destroy)(sp_tsx_uas_t *tsx, void *user_data);
- void *user_data;
- }sp_tsx_uas_callback;
- int sp_tsx_uas_create(sp_ses_uas_t *uas, int tsx_id, sp_tsx_uas_callback *cb, sp_tsx_uas_t **p_tsx);
- void sp_tsx_uas_destroy(sp_tsx_uas_t *tsx);
- sp_ses_uas_t *sp_tsx_uas_get_session(sp_tsx_uas_t *tsx);
- int sp_tsx_uas_get_state(sp_tsx_uas_t *tsx);
- int sp_tsx_uas_get_id(sp_tsx_uas_t *tsx);
- int sp_tsx_uas_close(sp_tsx_uas_t *tsx);
- int sp_tsx_uas_answer(sp_tsx_uas_t *tsx, int end, iobuffer_t **ans_pkt);
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif // SP_SES_H
|