You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.9KB

  1. #ifndef _sip_subscribe_h_
  2. #define _sip_subscribe_h_
  3. #if defined(__cplusplus)
  4. extern "C" {
  5. #endif
  6. #include "sip-dialog.h"
  7. #define SIP_SUBSCRIPTION_STATE_ACTIVE "active"
  8. #define SIP_SUBSCRIPTION_STATE_PENDING "pending"
  9. #define SIP_SUBSCRIPTION_STATE_TERMINATED "terminated"
  10. // rfc6665 4.1.3. Receiving and Processing State Information (p15)
  11. #define SIP_SUBSCRIPTION_REASON_DEACTIVATED "deactivated"
  12. #define SIP_SUBSCRIPTION_REASON_PROBATION "probation"
  13. #define SIP_SUBSCRIPTION_REASON_REJECTED "rejected"
  14. #define SIP_SUBSCRIPTION_REASON_TIMEOUT "timeout"
  15. #define SIP_SUBSCRIPTION_REASON_GIVEUP "giveup"
  16. #define SIP_SUBSCRIPTION_REASON_NORESOURCE "noresource"
  17. #define SIP_SUBSCRIPTION_REASON_INVARIANT "invariant"
  18. enum {
  19. SUBSCRIBE_INIT = 0,
  20. SUBSCRIBE_ACTIVE,
  21. SUBSCRIBE_TERMINATED,
  22. };
  23. struct sip_subscribe_t
  24. {
  25. struct sip_dialog_t* dialog;
  26. int state; // SUBSCRIBE_INIT
  27. uint64_t expires;
  28. char event[128];
  29. // internal use only
  30. struct list_head link;
  31. void* evtsession; // user-defined event session
  32. int32_t ref;
  33. int newdiaolog; // flag for remote dialog from sip dialogs link
  34. };
  35. struct sip_subscribe_t* sip_subscribe_create(const struct cstring_t* event);
  36. int sip_subscribe_release(struct sip_subscribe_t* subscribe);
  37. int sip_subscribe_addref(struct sip_subscribe_t* subscribe);
  38. // subscribe management
  39. int sip_subscribe_add(struct sip_agent_t* sip, struct sip_subscribe_t* subscribe);
  40. int sip_subscribe_remove(struct sip_agent_t* sip, struct sip_subscribe_t* subscribe);
  41. /// call sip_subscribe_release
  42. struct sip_subscribe_t* sip_subscribe_fetch(struct sip_agent_t* sip, const struct cstring_t* callid, const struct cstring_t* local, const struct cstring_t* remote, const struct cstring_t* event);
  43. /// call sip_subscribe_release
  44. struct sip_subscribe_t* sip_subscribe_internal_fetch(struct sip_agent_t* sip, const struct sip_message_t* msg, const struct cstring_t* event, int uac, int* added);
  45. #if defined(__cplusplus)
  46. }
  47. #endif
  48. #endif /* !_sip_subscribe_h_ */