qos_cb.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2007 SOMA Networks, Inc.
00005  * Written by Ovidiu Sas (osas)
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
00010  * it 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,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU 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  USA
00022  *
00023  * History:
00024  * --------
00025  *  2007-07-11  initial version (osas)
00026  */
00027 
00028 #ifndef _QOS_QOS_CB_H_
00029 #define _QOS_QOS_CB_H_
00030 
00031 #include "../../parser/msg_parser.h"
00032 
00033 struct qos_ctx_st;
00034 
00035 struct qos_cb_params {
00036         struct sip_msg *msg;       /* sip msg related to the callback event */
00037         struct qos_sdp_st *sdp;    /* pointer to the sdp that is added/updated/removed */
00038         unsigned int role;
00039         void **param;              /* parameter passed at callback registration*/
00040 };
00041 
00042 /* callback function prototype */
00043 typedef void (qos_cb) (struct qos_ctx_st *qos, int type,
00044                 struct qos_cb_params *params);
00045 /* register callback function prototype */
00046 typedef int (*register_qoscb_f)(struct qos_ctx_st *qos, int cb_types,
00047                 qos_cb f, void *param);
00048 
00049 
00050 #define QOSCB_CREATED      (1<<0)
00051 #define QOSCB_ADD_SDP      (1<<1)
00052 #define QOSCB_UPDATE_SDP   (1<<2)
00053 #define QOSCB_REMOVE_SDP   (1<<3)
00054 #define QOSCB_TERMINATED   (1<<4)
00055 
00056 /*
00057  * Callback logic ....
00058  *
00059 
00060    --INVITE(SDP)-->
00061          +----------------<QOSCB_ADD>
00062 
00063   <---183(SDP)----
00064          +----------------<QOSCB_UPDATE>
00065 
00066   <---200(SDP)----
00067          +----------------<QOSCB_UPDATE>
00068    -----ACK------->
00069 
00070 
00071    -----BYE------->
00072          +----------------<QOSCB_REMOVE>
00073   <-----200-------
00074 
00075  */
00076 
00077 struct qos_callback {
00078         int types;
00079         qos_cb* callback;
00080         void *param;
00081         struct qos_callback* next;
00082 };
00083 
00084 
00085 struct qos_head_cbl {
00086         struct qos_callback *first;
00087         int types;
00088 };
00089 
00090 int init_qos_callbacks();
00091 
00092 void destroy_qos_callbacks();
00093 
00094 void destroy_qos_callbacks_list(struct qos_callback *cb);
00095 
00096 int register_qoscb(struct qos_ctx_st* qos, int types, qos_cb f, void *param);
00097 
00098 void run_create_cbs(struct qos_ctx_st *qos, struct sip_msg *msg);
00099 
00100 void run_qos_callbacks( int type, struct qos_ctx_st *qos,
00101                         struct qos_sdp_st *sdp, unsigned int role,
00102                         struct sip_msg *msg);
00103 
00104 
00105 #endif