qos_ctx_helpers.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2007 SOMA Networks, INC.
00005  * Written By Ovidiu Sas
00006  *
00007  * This file is part of Kamailio, a free SIP server.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022  * USA
00023  *
00024  * History:
00025  * --------
00026  * 2007-07-16 initial version (osas)
00027  */
00028 
00029 #ifndef _QOS_CTX_HELPERS_H_
00030 #define _QOS_CTX_HELPERS_H_
00031 
00032 #include "../../parser/sdp/sdp.h"
00033 #include "qos_cb.h"
00034 
00035 #define QOS_CALLER  0
00036 #define QOS_CALLEE  1
00037 
00038 typedef struct qos_sdp_st {
00039         struct qos_sdp_st *prev;
00040         struct qos_sdp_st *next;
00041         unsigned int method_dir;     /* the transaction initiator: CALLER/CALLEE */
00042         int          method_id;      /* the method id that is carrying the sdp */
00043         str          method;         /* the method that is carrying the sdp */
00044         str          cseq;           /* the cseq of the method */
00045         unsigned int negotiation;    /* the negotiation type */
00046         sdp_session_cell_t *sdp_session[2]; /* CALLER's and CALLEE's sdp */
00047 } qos_sdp_t;
00048 
00052 typedef struct qos_ctx_st {
00053         qos_sdp_t           *negotiated_sdp;
00054         qos_sdp_t           *pending_sdp;
00055         gen_lock_t lock;
00056         struct qos_head_cbl  cbs;
00057 } qos_ctx_t;
00058 
00059 /*
00060  
00061 ** AFTER INVITE/183 **
00062 
00063 qos_ctx:
00064  +----------------+
00065  | *negotiated_sdp|
00066  +----------------+    qos_sdp (pending)
00067  | *pending_sdp------->+----------------+
00068  +----------------+    | *prev          |
00069                        +----------------+
00070                        | *next          |
00071                        +----------------+  
00072                        | method_dir     |      sdp_session (caller)
00073                        | method_id      |  +-->+----------+
00074                        | method         |  |   |          |
00075                        | cseq           |  |   |          |
00076                        | negotiation    |  |   +----------+
00077                        +----------------+  |
00078                        | sdp_session[0]----+
00079                        +----------------+      sdp_session (callee)
00080                        | sdp_session[1]------->+----------+
00081                        +----------------+      |          |
00082                                                |          |
00083                                                +----------+
00084 
00085 ** AFTER INVITE/200ok **
00086 
00087 qos_ctx:
00088  +----------------+    qos_sdp (negotiated)
00089  | *negotiated_sdp---->+----------------+
00090  +----------------+    | *prev          |
00091  | *pending_sdp   |    +----------------+
00092  +----------------+    | *next          |
00093                        +----------------+  
00094                        | method_dir     |      sdp_session (caller)
00095                        | method_id      |  +-->+----------+
00096                        | method         |  |   |          |
00097                        | cseq           |  |   |          |
00098                        | negotiation    |  |   +----------+
00099                        +----------------+  |
00100                        | sdp_session[0]----+
00101                        +----------------+      sdp_session (callee)
00102                        | sdp_session[1]------->+----------+
00103                        +----------------+      |          |
00104                                                |          |
00105                                                +----------+
00106 
00107 
00108  */
00109 
00110 qos_ctx_t* build_new_qos_ctx();
00111 void destroy_qos_ctx(qos_ctx_t *ctx);
00112 
00113 void add_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
00114 void remove_sdp(qos_ctx_t *qos_ctx, unsigned int dir, struct sip_msg *_m, unsigned int role, unsigned int other_role);
00115 
00116 #endif /* _QOS_CTX_HELPERS_H_ */