您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

67 行
3.6KB

  1. #ifndef _sip_agent_h_
  2. #define _sip_agent_h_
  3. #include "cstring.h"
  4. #if defined(__cplusplus)
  5. extern "C" {
  6. #endif
  7. struct sip_agent_t;
  8. struct sip_dialog_t;
  9. struct sip_message_t;
  10. struct sip_subscribe_t;
  11. struct sip_uas_transaction_t;
  12. /// sip UAC/UAS transaction destroy callback
  13. /// @param[in] param user-defined parameter
  14. typedef void (*sip_transaction_ondestroy)(void* param);
  15. struct sip_uas_handler_t
  16. {
  17. /// @param[in] protocol UDP/TCP/TLS/SCTP
  18. /// @param[in] received replace url host address if has valid value
  19. /// @param[in] rport valid only rport > 0, if rport <= 0, then use url host port; if host port is empty, then use default sip port
  20. /// @return 0-ok, <0-error, other-reserved
  21. int (*send)(void* param, const struct cstring_t* protocol, const struct cstring_t* url, const struct cstring_t *received, int rport, const void* data, int bytes);
  22. /// @param[in] expires in seconds. if not provided, default equal to 60
  23. int (*onregister)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, const char* user, const char* location, int expires);
  24. /// @param[in] dialog nil-new invite, not nil-reinvite
  25. /// @param[out] session user-defined session-id(valid only code=2xx)
  26. /// @return 0-ok, other-error
  27. int (*oninvite)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, struct sip_dialog_t* dialog, const void* data, int bytes, void** session);
  28. /// @param[in] code 0-ok, other-sip status code
  29. int (*onack)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session, struct sip_dialog_t* dialog, int code, const void* data, int bytes);
  30. /// @param[in] session oninvite return value
  31. int (*onprack)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session, struct sip_dialog_t* dialog, const void* data, int bytes);
  32. int (*onupdate)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session, struct sip_dialog_t* dialog, const void* data, int bytes);
  33. int (*oninfo)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session, struct sip_dialog_t* dialog, const struct cstring_t* package, const void* data, int bytes);
  34. /// on terminating a session(dialog)
  35. int (*onbye)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session);
  36. /// cancel a transaction(should be an invite transaction)
  37. int (*oncancel)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session);
  38. int (*onsubscribe)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, struct sip_subscribe_t* subscribe, void** sub);
  39. int (*onnotify)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* sub, const struct cstring_t* event);
  40. int (*onpublish)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, const struct cstring_t* event);
  41. int (*onmessage)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session, const void* data, int bytes);
  42. int (*onrefer)(void* param, const struct sip_message_t* req, struct sip_uas_transaction_t* t, void* session);
  43. };
  44. struct sip_agent_t* sip_agent_create(struct sip_uas_handler_t* handler);
  45. int sip_agent_destroy(struct sip_agent_t* sip);
  46. /// @param[in] msg sip request/response message
  47. /// @param[in] param user-defined parameter, for sip_uas_handler_t only
  48. int sip_agent_input(struct sip_agent_t* sip, struct sip_message_t* msg, void* param);
  49. int sip_agent_set_rport(struct sip_message_t* msg, const char* peer, int port);
  50. #if defined(__cplusplus)
  51. }
  52. #endif
  53. #endif /* !_sip_agent_h_ */