1 /**
2  * @file sipevent.h  SIP Event Private Interface
3  *
4  * Copyright (C) 2010 Creytiv.com
5  */
6 
7 /* Listener Socket */
8 
9 struct sipevent_sock {
10 	struct sip_lsnr *lsnr;
11 	struct hash *ht_not;
12 	struct hash *ht_sub;
13 	struct sip *sip;
14 	sip_msg_h *subh;
15 	void *arg;
16 };
17 
18 
19 /* Notifier */
20 
21 struct sipnot {
22 	struct le he;
23 	struct sip_loopstate ls;
24 	struct tmr tmr;
25 	struct sipevent_sock *sock;
26 	struct sip_request *req;
27 	struct sip_dialog *dlg;
28 	struct sip_auth *auth;
29 	struct sip *sip;
30 	struct mbuf *mb;
31 	char *event;
32 	char *id;
33 	char *cuser;
34 	char *hdrs;
35 	char *ctype;
36 	sipnot_close_h *closeh;
37 	void *arg;
38 	uint32_t expires;
39 	uint32_t expires_min;
40 	uint32_t expires_dfl;
41 	uint32_t expires_max;
42 	uint32_t retry_after;
43 	enum sipevent_subst substate;
44 	enum sipevent_reason reason;
45 	bool notify_pending;
46 	bool subscribed;
47 	bool terminated;
48 	bool termsent;
49 };
50 
51 void sipnot_refresh(struct sipnot *not, uint32_t expires);
52 int  sipnot_notify(struct sipnot *not);
53 int  sipnot_reply(struct sipnot *not, const struct sip_msg *msg,
54 		  uint16_t scode, const char *reason);
55 
56 
57 /* Subscriber */
58 
59 struct sipsub {
60 	struct le he;
61 	struct sip_loopstate ls;
62 	struct tmr tmr;
63 	struct sipevent_sock *sock;
64 	struct sip_request *req;
65 	struct sip_dialog *dlg;
66 	struct sip_auth *auth;
67 	struct sip *sip;
68 	char *event;
69 	char *id;
70 	char *cuser;
71 	char *hdrs;
72 	char *refer_hdrs;
73 	sipsub_fork_h *forkh;
74 	sipsub_notify_h *notifyh;
75 	sipsub_close_h *closeh;
76 	void *arg;
77 	int32_t refer_cseq;
78 	uint32_t expires;
79 	uint32_t failc;
80 	bool subscribed;
81 	bool terminated;
82 	bool termconf;
83 	bool termwait;
84 	bool refer;
85 };
86 
87 struct sipsub *sipsub_find(struct sipevent_sock *sock,
88 			   const struct sip_msg *msg,
89 			   const struct sipevent_event *evt, bool full);
90 void sipsub_reschedule(struct sipsub *sub, uint64_t wait);
91 void sipsub_terminate(struct sipsub *sub, int err, const struct sip_msg *msg,
92 		      const struct sipevent_substate *substate);
93