sp_iom.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef SP_IOM_H
  2. #define SP_IOM_H
  3. #pragma once
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /* IO management, provide network communication functions */
  8. #include "bus.h"
  9. #include "timerqueue.h"
  10. typedef struct sp_iom_t sp_iom_t;
  11. typedef int (*sp_iom_on_pkt)(sp_iom_t *, int to_svc_id, int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt, void *user_data);
  12. typedef void (*sp_iom_on_sys)(sp_iom_t *,int epid, int state, void *user_data);
  13. SPBASE_API int sp_iom_create(const char *url, int epid, sp_iom_t **p_iom);
  14. SPBASE_API void sp_iom_destroy(sp_iom_t *iom);
  15. int sp_iom_add_pkt_handler(sp_iom_t *iom, int key, sp_iom_on_pkt on_pkt, void *user_data);
  16. int sp_iom_remove_pkt_handler(sp_iom_t *iom, int key);
  17. int sp_iom_add_sys_handler(sp_iom_t *iom, int key, sp_iom_on_sys on_sys, void *user_data);
  18. int sp_iom_remove_sys_handler(sp_iom_t *iom, int key);
  19. SPBASE_API int sp_iom_run(sp_iom_t *iom);
  20. SPBASE_API int sp_iom_stop(sp_iom_t *iom);
  21. SPBASE_API int sp_iom_send(sp_iom_t *iom, int this_svc_id, int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt);
  22. SPBASE_API int sp_iom_post(sp_iom_t *iom, int this_svc_id, int epid, int svc_id, int pkt_type, int pkt_id, iobuffer_t **p_pkt);
  23. int sp_iom_get_state(sp_iom_t *iom, int epid, int *state);
  24. int sp_iom_schedule_timer(sp_iom_t *iom, timer_entry *entry, unsigned int delay);
  25. int sp_iom_cancel_timer(sp_iom_t *iom, timer_entry *entry, int cancel);
  26. int sp_iom_get_epid(sp_iom_t *iom);
  27. const char *sp_iom_get_comm_url(sp_iom_t *iom);
  28. SPBASE_API int sp_iom_post_quit(sp_iom_t *iom);
  29. int sp_iom_get_poll_thread_id(sp_iom_t *iom);
  30. #ifdef __cplusplus
  31. } // extern "C" {
  32. #endif
  33. #endif // SP_IOM_H