James Kuszmaul | 82f6c04 | 2021-01-17 11:30:16 -0800 | [diff] [blame^] | 1 | /** |
| 2 | * @file sip.h SIP Private Interface |
| 3 | * |
| 4 | * Copyright (C) 2010 Creytiv.com |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | struct sip { |
| 9 | struct list transpl; |
| 10 | struct list lsnrl; |
| 11 | struct list reql; |
| 12 | struct hash *ht_ctrans; |
| 13 | struct hash *ht_strans; |
| 14 | struct hash *ht_strans_mrg; |
| 15 | struct hash *ht_conn; |
| 16 | struct hash *ht_udpconn; |
| 17 | struct dnsc *dnsc; |
| 18 | struct stun *stun; |
| 19 | char *software; |
| 20 | sip_exit_h *exith; |
| 21 | void *arg; |
| 22 | bool closing; |
| 23 | }; |
| 24 | |
| 25 | |
| 26 | struct sip_lsnr { |
| 27 | struct le le; |
| 28 | struct sip_lsnr **lsnrp; |
| 29 | sip_msg_h *msgh; |
| 30 | void *arg; |
| 31 | bool req; |
| 32 | }; |
| 33 | |
| 34 | |
| 35 | struct sip_keepalive { |
| 36 | struct le le; |
| 37 | struct sip_keepalive **kap; |
| 38 | sip_keepalive_h *kah; |
| 39 | void *arg; |
| 40 | }; |
| 41 | |
| 42 | |
| 43 | /* request */ |
| 44 | void sip_request_close(struct sip *sip); |
| 45 | |
| 46 | |
| 47 | /* ctrans */ |
| 48 | struct sip_ctrans; |
| 49 | |
| 50 | int sip_ctrans_request(struct sip_ctrans **ctp, struct sip *sip, |
| 51 | enum sip_transp tp, const struct sa *dst, char *met, |
| 52 | char *branch, struct mbuf *mb, sip_resp_h *resph, |
| 53 | void *arg); |
| 54 | int sip_ctrans_cancel(struct sip_ctrans *ct); |
| 55 | int sip_ctrans_init(struct sip *sip, uint32_t sz); |
| 56 | int sip_ctrans_debug(struct re_printf *pf, const struct sip *sip); |
| 57 | |
| 58 | |
| 59 | /* strans */ |
| 60 | int sip_strans_init(struct sip *sip, uint32_t sz); |
| 61 | int sip_strans_debug(struct re_printf *pf, const struct sip *sip); |
| 62 | |
| 63 | |
| 64 | /* transp */ |
| 65 | struct sip_connqent; |
| 66 | |
| 67 | typedef void(sip_transp_h)(int err, void *arg); |
| 68 | |
| 69 | int sip_transp_init(struct sip *sip, uint32_t sz); |
| 70 | int sip_transp_send(struct sip_connqent **qentp, struct sip *sip, void *sock, |
| 71 | enum sip_transp tp, const struct sa *dst, struct mbuf *mb, |
| 72 | sip_transp_h *transph, void *arg); |
| 73 | bool sip_transp_supported(struct sip *sip, enum sip_transp tp, int af); |
| 74 | const char *sip_transp_srvid(enum sip_transp tp); |
| 75 | bool sip_transp_reliable(enum sip_transp tp); |
| 76 | int sip_transp_debug(struct re_printf *pf, const struct sip *sip); |
| 77 | |
| 78 | |
| 79 | /* auth */ |
| 80 | int sip_auth_encode(struct mbuf *mb, struct sip_auth *auth, const char *met, |
| 81 | const char *uri); |
| 82 | |
| 83 | |
| 84 | /* dialog */ |
| 85 | int sip_dialog_encode(struct mbuf *mb, struct sip_dialog *dlg, uint32_t cseq, |
| 86 | const char *met); |
| 87 | const char *sip_dialog_uri(const struct sip_dialog *dlg); |
| 88 | const struct uri *sip_dialog_route(const struct sip_dialog *dlg); |
| 89 | uint32_t sip_dialog_hash(const struct sip_dialog *dlg); |
| 90 | |
| 91 | |
| 92 | /* keepalive */ |
| 93 | struct sip_conn; |
| 94 | |
| 95 | void sip_keepalive_signal(struct list *kal, int err); |
| 96 | uint64_t sip_keepalive_wait(uint32_t interval); |
| 97 | int sip_keepalive_tcp(struct sip_keepalive *ka, struct sip_conn *conn, |
| 98 | uint32_t interval); |
| 99 | int sip_keepalive_udp(struct sip_keepalive *ka, struct sip *sip, |
| 100 | struct udp_sock *us, const struct sa *paddr, |
| 101 | uint32_t interval); |