all: updated FSF address in GPL text
[sip-router] / modules / qos / qos_ctx_helpers.h
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2007 SOMA Networks, INC.
5  * Written By Ovidiu Sas
6  *
7  * This file is part of Kamailio, a free SIP server.
8  *
9  * Kamailio is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version
13  *
14  * Kamailio is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  *
24  * History:
25  * --------
26  * 2007-07-16 initial version (osas)
27  */
28
29 #ifndef _QOS_CTX_HELPERS_H_
30 #define _QOS_CTX_HELPERS_H_
31
32 #include "../../parser/sdp/sdp.h"
33 #include "qos_cb.h"
34
35 #define QOS_CALLER  0
36 #define QOS_CALLEE  1
37
38 typedef struct qos_sdp_st {
39         struct qos_sdp_st *prev;
40         struct qos_sdp_st *next;
41         unsigned int method_dir;     /* the transaction initiator: CALLER/CALLEE */
42         int          method_id;      /* the method id that is carrying the sdp */
43         str          method;         /* the method that is carrying the sdp */
44         str          cseq;           /* the cseq of the method */
45         unsigned int negotiation;    /* the negotiation type */
46         sdp_session_cell_t *sdp_session[2]; /* CALLER's and CALLEE's sdp */
47 } qos_sdp_t;
48
49 /**
50  * The QoS context.
51  */
52 typedef struct qos_ctx_st {
53         qos_sdp_t           *negotiated_sdp;
54         qos_sdp_t           *pending_sdp;
55         gen_lock_t lock;
56         struct qos_head_cbl  cbs;
57 } qos_ctx_t;
58
59 /*
60  
61 ** AFTER INVITE/183 **
62
63 qos_ctx:
64  +----------------+
65  | *negotiated_sdp|
66  +----------------+    qos_sdp (pending)
67  | *pending_sdp------->+----------------+
68  +----------------+    | *prev          |
69                        +----------------+
70                        | *next          |
71                        +----------------+  
72                        | method_dir     |      sdp_session (caller)
73                        | method_id      |  +-->+----------+
74                        | method         |  |   |          |
75                        | cseq           |  |   |          |
76                        | negotiation    |  |   +----------+
77                        +----------------+  |
78                        | sdp_session[0]----+
79                        +----------------+      sdp_session (callee)
80                        | sdp_session[1]------->+----------+
81                        +----------------+      |          |
82                                                |          |
83                                                +----------+
84
85 ** AFTER INVITE/200ok **
86
87 qos_ctx:
88  +----------------+    qos_sdp (negotiated)
89  | *negotiated_sdp---->+----------------+
90  +----------------+    | *prev          |
91  | *pending_sdp   |    +----------------+
92  +----------------+    | *next          |
93                        +----------------+  
94                        | method_dir     |      sdp_session (caller)
95                        | method_id      |  +-->+----------+
96                        | method         |  |   |          |
97                        | cseq           |  |   |          |
98                        | negotiation    |  |   +----------+
99                        +----------------+  |
100                        | sdp_session[0]----+
101                        +----------------+      sdp_session (callee)
102                        | sdp_session[1]------->+----------+
103                        +----------------+      |          |
104                                                |          |
105                                                +----------+
106
107
108  */
109
110 qos_ctx_t* build_new_qos_ctx();
111 void destroy_qos_ctx(qos_ctx_t *ctx);
112
113 void add_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
114 void remove_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
115
116 #endif /* _QOS_CTX_HELPERS_H_ */