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.

68 lines
1.9KB

  1. #ifndef _sip_dialog_h_
  2. #define _sip_dialog_h_
  3. #include "sip-header.h"
  4. #include "sys/atomic.h"
  5. #include "cstring.h"
  6. #include "list.h"
  7. #include <stdint.h>
  8. #if defined(__cplusplus)
  9. extern "C" {
  10. #endif
  11. enum {
  12. DIALOG_ERALY = 0,
  13. DIALOG_CONFIRMED,
  14. DIALOG_TERMINATED,
  15. };
  16. struct sip_agent_t;
  17. struct sip_message_t;
  18. struct sip_dialog_t
  19. {
  20. int state; // DIALOG_ERALY/DIALOG_CONFIRMED
  21. struct cstring_t callid;
  22. struct
  23. {
  24. uint32_t id; // local/remote sequence number
  25. uint32_t rseq; // rfc3262 PRACK, [1, 2**31 - 1]
  26. struct sip_contact_t uri; // local/remote URI(From/To Field)
  27. struct sip_uri_t target; // local/remote target(Contact Field)
  28. } local, remote;
  29. int secure; // bool
  30. // route set(the list of URIs in the Record-Route header field from the request)
  31. struct sip_uris_t routers;
  32. // internal use only
  33. void* session; // user-defined session
  34. struct list_head link;
  35. char* ptr;
  36. int32_t ref;
  37. };
  38. struct sip_dialog_t* sip_dialog_create(void);
  39. int sip_dialog_release(struct sip_dialog_t* dialog);
  40. int sip_dialog_addref(struct sip_dialog_t* dialog);
  41. int sip_dialog_init_uac(struct sip_dialog_t* dialog, const struct sip_message_t* msg);
  42. int sip_dialog_init_uas(struct sip_dialog_t* dialog, const struct sip_message_t* msg);
  43. int sip_dialog_setlocaltag(struct sip_dialog_t* dialog, const struct cstring_t* tag);
  44. int sip_dialog_target_refresh(struct sip_dialog_t* dialog, const struct sip_message_t* msg);
  45. int sip_dialog_set_local_target(struct sip_dialog_t* dialog, const struct sip_message_t* msg);
  46. // dialog management
  47. int sip_dialog_add(struct sip_agent_t* sip, struct sip_dialog_t* dialog);
  48. int sip_dialog_remove(struct sip_agent_t* sip, struct sip_dialog_t* dialog);
  49. /// call sip_dialog_release
  50. struct sip_dialog_t* sip_dialog_fetch(struct sip_agent_t* sip, const struct cstring_t* callid, const struct cstring_t* local, const struct cstring_t* remote);
  51. #if defined(__cplusplus)
  52. }
  53. #endif
  54. #endif /* !_sip_dialog_h_ */