Apply 9441_add_pcem_module.patch

remotes/origin/3.3+ngcp2.6
Jon Bonilla 14 years ago
parent e4a03b5806
commit 0ba3c1c7be

@ -170,7 +170,7 @@ module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
# For radius
module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
peering
peering pcem
# For presence
# kamailio modules
@ -226,7 +226,7 @@ module_group_kpostgres=db_postgres
module_group_kcpl=cpl-c
# K radius modules
module_group_kradius=acc_radius auth_radius misc_radius peering
module_group_kradius=acc_radius auth_radius misc_radius peering pcem
# K unixodbc module
module_group_kunixodbc=db_unixodbc
@ -309,7 +309,7 @@ else
db_sqlite db_unixodbc db_cassandra memcached mi_xmlrpc \
perl perlvdb purple \
snmpstats xmpp \
carrierroute peering \
carrierroute peering pcem \
dialplan lcr utils presence presence_mwi \
presence_dialoginfo presence_xml pua pua_bla \
pua_dialoginfo pua_usrloc pua_xmpp \

@ -16,3 +16,21 @@ SERLIBPATH=../../lib
SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kcore/kcore
include ../../Makefile.modules
# $Id$
#
# pcem module makefile
#
#
# WARNING: do not run this directly, it should be run by the master Makefile
include ../../Makefile.defs
auto_gen=
NAME=pcem.so
LIBS=
DEFS+=-DOPENSER_MOD_INTERFACE
SERLIBPATH=../../lib
SER_LIBS+=$(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kcore/kcore
include ../../Makefile.modules

@ -128,3 +128,133 @@ static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps )
}
}
/*
* $Id$
*
* PacketCable Event Messages module
*
* Copyright (C) 2012 Sipwise GmbH
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <string.h>
#include "../../dprint.h"
#include "../../parser/parse_from.h"
#include "../../parser/parse_content.h"
#include "../../modules/tm/tm_load.h"
#include "../rr/api.h"
#include "../../flags.h"
#include "pcem_mod.h"
#include "pcem_logic.h"
extern struct tm_binds tmb;
extern struct rr_binds rrb;
#define is_pcem_flag_set(_rq,_flag) (((_flag) != -1) && (isflagset((_rq), (_flag)) == 1))
#define reset_pcem_flag(_rq,_flag) (resetflag((_rq), (_flag)))
#define is_all_on(_rq) is_pcem_flag_set(_rq,pcem_all_flag)
#define is_qos_on(_rq) is_pcem_flag_set(_rq,pcem_qos_flag)
static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
static inline int pcem_preparse_req(struct sip_msg *req)
{
/*
if((parse_headers(req,HDR_CALLID_F|HDR_CSEQ_F|HDR_FROM_F|HDR_TO_F,0)<0)
|| (parse_from_header(req)<0 ) ) {
LM_ERR("failed to preparse request\n");
return -1;
}
*/
return 0;
}
void pcem_onreq( struct cell* t, int type, struct tmcb_params *ps )
{
int tmcb_types;
int is_invite;
LM_ERR("pcem_onreq called for t(%p) event type %d\n", t, type);
if(ps->req && (is_all_on(ps->req) || is_qos_on(ps->req))) {
LM_ERR("it's a request, is_all_on=%d, is_qos_on=%d, processing request\n",
is_all_on(ps->req), is_qos_on(ps->req));
if (pcem_preparse_req(ps->req)<0)
return;
is_invite = (ps->req->REQ_METHOD==METHOD_INVITE)?1:0;
tmcb_types =
/* get completed transactions */
TMCB_RESPONSE_OUT |
/* get incoming replies ready for processing */
TMCB_RESPONSE_IN |
/* get failed transactions */
(is_invite?TMCB_ON_FAILURE:0);
if (tmb.register_tmcb( 0, t, tmcb_types, tmcb_func, 0, 0 ) <= 0) {
LM_ERR("cannot register additional callbacks\n");
return;
}
/*
if(!rrb.is_direction(ps->req,RR_FLOW_UPSTREAM) ) {
LM_DBG("detected an UPSTREAM req -> flaging it\n");
ps->req->msg_flags |= FL_REQ_UPSTREAM;
}
*/
}
}
static inline void pcem_onreply_in(struct cell *t, struct sip_msg *req,
struct sip_msg *reply, int code)
{
LM_ERR("got a reply_in, code=%d\n", code);
}
static inline void pcem_onreply(struct cell *t, struct sip_msg *req,
struct sip_msg *reply, int code)
{
LM_ERR("got a reply, code=%d\n", code);
}
static inline void pcem_onfailure(struct cell *t, struct sip_msg *req,
struct sip_msg *reply, int code)
{
LM_ERR("got a failure\n");
}
static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps )
{
LM_ERR("pcem callback called for t(%p) event type %d, reply code %d\n",
t, type, ps->code);
if (type&TMCB_RESPONSE_OUT) {
pcem_onreply( t, ps->req, ps->rpl, ps->code);
} else if (type&TMCB_ON_FAILURE) {
pcem_onfailure( t, ps->req, ps->rpl, ps->code);
} else if (type&TMCB_RESPONSE_IN) {
pcem_onreply_in( t, ps->req, ps->rpl, ps->code);
}
}

@ -32,3 +32,37 @@
void pcem_onreq( struct cell* t, int type, struct tmcb_params *ps );
#endif
/*
* $Id$
*
* PacketCable Event Messages module
*
* Copyright (C) 2012 Sipwise GmbH
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _PCEM_LOGIC_H
#define _PCEM_LOGIC_H
#include "../../str.h"
#include "../../modules/tm/t_hooks.h"
void pcem_onreq( struct cell* t, int type, struct tmcb_params *ps );
#endif

@ -72,6 +72,159 @@ static cmd_export_t cmds[] = {
static param_export_t params[] = {
/*{"test_str", INT_PARAM, &test_str.s },*/
{"qos_flag", INT_PARAM, &pcem_qos_flag },
{"all_flag", INT_PARAM, &pcem_all_flag },
{0,0,0}
};
struct module_exports exports= {
"pcem",
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* exported functions */
params, /* exported params */
0, /* exported statistics */
0, /* exported MI functions */
0, /* exported pseudo-variables */
0, /* extra processes */
mod_init, /* initialization module */
0, /* response function */
destroy, /* destroy function */
child_init /* per-child init function */
};
static int mod_init( void )
{
if ((pcem_qos_flag != -1) &&
!flag_in_range(pcem_qos_flag)) {
LM_ERR("pcem_qos_flag set to invalid value\n");
return -1;
}
if ((pcem_all_flag != -1) &&
!flag_in_range(pcem_all_flag)) {
LM_ERR("pcem_all_flag set to invalid value\n");
return -1;
}
/* load the TM API */
if (load_tm_api(&tmb)!=0) {
LM_ERR("can't load TM API\n");
return -1;
}
/* load the RR API */
if (load_rr_api(&rrb)!=0) {
LM_ERR("can't load RR API\n");
return -1;
}
/* we need the append_fromtag on in RR */
if (!rrb.append_fromtag) {
LM_ERR("'append_fromtag' RR param is not enabled\n");
return -1;
}
/* listen for all incoming requests */
if ( tmb.register_tmcb( 0, 0, TMCB_REQUEST_IN, pcem_onreq, 0, 0 ) <=0 ) {
LM_ERR("cannot register TMCB_REQUEST_IN callback\n");
return -1;
}
_pcem_module_initialized = 1;
return 0;
}
static int child_init(int rank)
{
if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
return 0; /* do nothing for the main process */
return 0;
}
static void destroy(void)
{
}
/*
* $Id$
*
* PacketCable Event Messages module
*
* Copyright (C) 2012 Sipwise GmbH
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <string.h>
#include "../../sr_module.h"
#include "../../dprint.h"
#include "../../mem/mem.h"
#include "../../modules/tm/tm_load.h"
#include "../../str.h"
#include "../rr/api.h"
#include "pcem_mod.h"
#include "pcem_logic.h"
MODULE_VERSION
struct tm_binds tmb;
struct rr_binds rrb;
static int mod_init(void);
static void destroy(void);
static int child_init(int rank);
int pcem_qos_flag = -1; /* don't send qos messages by default */
int pcem_all_flag = -1; /* don't send any messages by default */
/*
static int bind_acc(acc_api_t* api);
static int acc_register_engine(acc_engine_t *eng);
static int acc_init_engines(void);
static acc_engine_t *_acc_engines=NULL;
*/
static int _pcem_module_initialized = 0;
/*
static int acc_fixup(void** param, int param_no);
static int free_acc_fixup(void** param, int param_no);
*/
static cmd_export_t cmds[] = {
/*
{"pcem_test", (cmd_function)w_pkg_em_test, 1,
acc_fixup, free_acc_fixup,
ANY_ROUTE},
*/
{0, 0, 0, 0, 0, 0}
};
static param_export_t params[] = {
/*{"test_str", INT_PARAM, &test_str.s },*/
{"qos_flag", INT_PARAM, &pcem_qos_flag },

@ -31,3 +31,36 @@ extern int pcem_qos_flag;
extern int pcem_all_flag;
#endif
/*
* $Id$
*
* PacketCable Event Messages module
*
* Copyright (C) 2012 Sipwise GmbH
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _PCEM_MOD_H
#define _PCEM_MOD_H
/* module parameter declaration */
extern int pcem_qos_flag;
extern int pcem_all_flag;
#endif

Loading…
Cancel
Save