sp_svc.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef SP_SVC_H
  2. #define SP_SVC_H
  3. #pragma once
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include "sp_iom.h"
  8. #include "sp_tmr.h"
  9. #include "sp_rsn.h"
  10. #include "threadpool.h"
  11. typedef struct sp_svc_t sp_svc_t;
  12. typedef int (*sp_svc_on_pkt)(sp_svc_t *,int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt, void *user_data);
  13. typedef void (*sp_svc_on_sys)(sp_svc_t *,int epid, int state, void *user_data);
  14. SPBASE_API int sp_svc_create(sp_iom_t *iom, int multithread, int svc_id, int devel_id, sp_svc_t **p_svc);
  15. SPBASE_API void sp_svc_destroy(sp_svc_t *svc);
  16. int sp_svc_add_pkt_handler(sp_svc_t *svc, int key, int pkt_type, sp_svc_on_pkt on_pkt, void *user_data);
  17. int sp_svc_add_sys_handler(sp_svc_t *svc, int key, sp_svc_on_sys on_sys, void *user_data);
  18. int sp_svc_remove_pkt_handler(sp_svc_t *svc, int key, int pkt_type);
  19. int sp_svc_remove_sys_handler(sp_svc_t *svc, int key);
  20. SPBASE_API int sp_svc_start(sp_svc_t *svc);
  21. SPBASE_API int sp_svc_stop(sp_svc_t *svc);
  22. int sp_svc_send(sp_svc_t *svc, int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt);
  23. int sp_svc_post(sp_svc_t *svc, int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt);
  24. int sp_svc_get_state(sp_svc_t *svc, int epid, int *state);
  25. sp_tmr_mgr_t* sp_svc_get_tmr_mgr(sp_svc_t *svc);
  26. sp_iom_t *sp_svc_get_iom(sp_svc_t *svc);
  27. threadpool_t *sp_svc_get_threadpool(sp_svc_t *svc);
  28. int sp_svc_get_id(sp_svc_t *svc);
  29. sp_uid_t sp_svc_new_runserial(sp_svc_t *svc);
  30. void sp_svc_push_runserial_context(sp_svc_t *svc, sp_rsn_context_t *rsn);
  31. void sp_svc_pop_runserial_context(sp_svc_t *svc);
  32. sp_rsn_context_t *sp_svc_get_runserial_context(sp_svc_t *svc);
  33. #ifdef __cplusplus
  34. } // extern "C" {
  35. #endif
  36. #endif // SP_SVC_H