Browse Source

modules_k/presence_profile: new modul for basic ua-profile event support

 - This is a new modul that is using sip event framework for endpoint config provisioining.
   Currently it has very basic functionality.
Mihály Mészáros 14 years ago
parent
commit
d3a2b22db7

+ 2 - 2
Makefile

@@ -174,7 +174,7 @@ module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
 
 # For presence
 # kamailio modules
-module_group_presence=presence presence_dialoginfo presence_mwi presence_xml \
+module_group_presence=presence presence_dialoginfo presence_mwi presence_xml presence_profile\
 						pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
 						rls xcap_client xcap_server presence_conference \
 						presence_reginfo pua_reginfo
@@ -262,7 +262,7 @@ module_group_kmemcached=memcached
 module_group_ktls=tls
 
 # K presence modules
-module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml \
+module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml presence_profile\
 						pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
 						rls xcap_client xcap_server presence_conference \
 						presence_reginfo pua_reginfo

+ 1 - 1
modules_k/presence/event_list.c

@@ -356,7 +356,7 @@ pres_ev_t* search_event(event_t* event)
 				strncasecmp(pres_ev->evp->name.s,event->name.s,
 					pres_ev->evp->name.len)== 0))
 		{
-			if(event->params.list== NULL && pres_ev->evp->params.list== NULL)
+			if((event->params.list== NULL && pres_ev->evp->params.list== NULL) || event->type==EVENT_UA_PROFILE)
 			{
 				return pres_ev;
 			}

+ 11 - 0
modules_k/presence_profile/Makefile

@@ -0,0 +1,11 @@
+# 
+# WARNING: do not run this directly, it should be run by the master Makefile
+
+include ../../Makefile.defs
+auto_gen=
+NAME=presence_profile.so
+LIBS=
+
+DEFS+=-DOPENSER_MOD_INTERFACE
+
+include ../../Makefile.modules

+ 77 - 0
modules_k/presence_profile/README

@@ -0,0 +1,77 @@
+Presence_Profile Module
+
+Mihály Mészáros
+
+   <[email protected]>
+
+Edited by
+
+Mészáros Mihály
+
+   <[email protected]>
+
+   Copyright © 2011 Mészáros Mihály
+     __________________________________________________________________
+
+   Table of Contents
+
+   1. Admin Guide
+
+        1. Overview
+        2. Dependencies
+
+              2.1. Kamailio Modules
+              2.2. External Libraries or Applications
+
+        3. Exported Parameters
+        4. Exported Functions
+
+Chapter 1. Admin Guide
+
+   Table of Contents
+
+   1. Overview
+   2. Dependencies
+
+        2.1. Kamailio Modules
+        2.2. External Libraries or Applications
+
+   3. Exported Parameters
+   4. Exported Functions
+
+1. Overview
+
+   The module does a very basic handling for ua-profile. You can subscribe
+   to ua-profile provisioning information if you add a provisioning
+   document to presentity table.
+
+   Warning: When you add provisioning config to presentity table, then you
+   must make sure that you set the presentity table expires field to a
+   time value in long future
+
+   If your user agent is subscribing to AoR and if the subscription event
+   is ua-profile, then it will receive provisioning data in the
+   notification body. Read more about sip user agent configuration
+   framework in RFC6080. http://tools.ietf.org/html/rfc6080
+
+2. Dependencies
+
+   2.1. Kamailio Modules
+   2.2. External Libraries or Applications
+
+2.1. Kamailio Modules
+
+   The following modules must be loaded before this module:
+     * presence.
+
+2.2. External Libraries or Applications
+
+   None.
+
+3. Exported Parameters
+
+   None.
+
+4. Exported Functions
+
+   None to be used in configuration file.

+ 66 - 0
modules_k/presence_profile/add_events.c

@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "../../parser/parse_content.h"
+#include "../presence/event_list.h"
+#include "presence_profile.h"
+
+
+int profile_add_events(void)
+{
+    pres_ev_t event;
+	
+    /* constructing profile event */
+    memset(&event, 0, sizeof(pres_ev_t));
+    event.name.s = "ua-profile";
+    event.name.len = 10;
+
+
+    event.content_type.s = "text/xml";
+    event.content_type.len = 8;
+
+    event.default_expires= 3600;
+    event.type = PUBL_TYPE;
+    event.req_auth = 0;
+    event.evs_publ_handl = 0;
+    
+    if (pres_add_event(&event) < 0) {
+	LM_ERR("failed to add event \"ua-profile\"\n");
+	return -1;
+    }		
+	
+    return 0;
+}

+ 40 - 0
modules_k/presence_profile/add_events.h

@@ -0,0 +1,40 @@
+/*
+ * presence_profile module - add_event header file
+ *
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * 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
+ *
+ * History:
+ * --------
+ *  2011-11-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#ifndef _PROFILE_ADD_EV_H_
+#define _PROFILE_ADD_EV_H_
+
+int profile_add_events(void);
+
+#endif

+ 4 - 0
modules_k/presence_profile/doc/Makefile

@@ -0,0 +1,4 @@
+docs = presence_profile.xml
+
+docbook_dir = ../../../docbook
+include $(docbook_dir)/Makefile.module

+ 39 - 0
modules_k/presence_profile/doc/presence_profile.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+
+<book xmlns:xi="http://www.w3.org/2001/XInclude">
+    <bookinfo>
+	<title>Presence_Profile Module</title>
+	<productname class="trade">&kamailioname;</productname>
+	<authorgroup>
+	    <author>
+		<firstname>Mihály</firstname>
+		<surname>Mészáros</surname>
+		<email>[email protected]</email>
+	    </author>
+	    <editor>
+		<firstname>Mészáros</firstname>
+		<surname>Mihály</surname>
+  	        <email>[email protected]</email>
+	    </editor>
+	</authorgroup>
+	<copyright>
+	    <year>2011</year>
+	    <holder>Mészáros Mihály</holder>
+	</copyright>
+  </bookinfo>
+    <toc></toc>
+    
+    <xi:include href="presence_profile_admin.xml"/>
+    
+    
+</book>
+
+

+ 72 - 0
modules_k/presence_profile/doc/presence_profile_admin.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding='ISO-8859-1'?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
+"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
+
+<!-- Include general documentation entities -->
+<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
+%docentities;
+
+]>
+<!-- Module User's Guide -->
+
+<chapter>
+	
+
+	<title>&adminguide;</title>
+	
+	<section>
+	  <title>Overview</title>
+	    <para> 
+	      The module does a very basic handling for ua-profile.
+	      You can subscribe to ua-profile provisioning information if you add a provisioning document to presentity table.
+	    </para>
+	    <para>
+	      Warning: When you add provisioning config to presentity table, then you must make sure 
+	      that you set the presentity table expires field to a time value in long future
+	    </para>
+	    <para>
+	      If your user agent is subscribing to AoR and if the subscription event is ua-profile, then it will receive provisioning data in the notification body.
+	      Read more about sip user agent configuration framework in RFC6080. http://tools.ietf.org/html/rfc6080
+	    </para>
+	</section>
+
+	<section>
+	  <title>Dependencies</title>
+	  <section>
+		<title>&kamailio; Modules</title>
+		<para>
+		The following modules must be loaded before this module:
+			<itemizedlist>
+			<listitem>
+			<para>
+				<emphasis>presence</emphasis>.
+			</para>
+			</listitem>
+			</itemizedlist>
+		</para>
+	  </section>
+
+	  <section>
+		<title>External Libraries or Applications</title>
+		<para>
+		None.
+		</para>
+	  </section>
+	</section>
+	
+	<section>
+	  <title>Exported Parameters</title>
+		<para>
+		  None.
+		</para>
+        </section>
+
+        <section>
+	  <title>Exported Functions</title>
+	      <para>
+	        None to be used in configuration file.
+	      </para>
+	</section>
+
+</chapter>
+

+ 118 - 0
modules_k/presence_profile/presence_profile.c

@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+
+/*!
+ * \defgroup presence_profile Presence_profile :: Presence Handling of ua-profile events
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "../../sr_module.h"
+#include "../../dprint.h"
+#include "../../str.h"
+#include "../../parser/msg_parser.h"
+#include "../../mem/mem.h"
+#include "../presence/bind_presence.h"
+#include "add_events.h"
+#include "presence_profile.h"
+
+MODULE_VERSION
+
+/* module functions */
+static int mod_init(void);
+
+/* module variables */
+add_event_t pres_add_event;
+
+/* module exported commands */
+static cmd_export_t cmds[] =
+{
+    {0,	0, 0, 0, 0, 0}
+};
+
+/* module exported paramaters */
+static param_export_t params[] = {
+    {0, 0, 0}
+};
+
+/* module exports */
+struct module_exports exports= {
+    "presence_profile",				/* module name */
+    DEFAULT_DLFLAGS,            /* dlopen flags */
+    cmds,						/* exported functions */
+    params,						/* exported parameters */
+    0,							/* exported statistics */
+    0,							/* exported MI functions */
+    0,							/* exported pseudo-variables */
+	0,							/* extra processes */
+    mod_init,					/* module initialization function */
+    0,							/* response handling function */
+    0,							/* destroy function */
+    0							/* per-child init function */
+};
+	
+/*
+ * init module function
+ */
+static int mod_init(void)
+{
+	presence_api_t pres;
+    bind_presence_t bind_presence;
+
+    bind_presence= (bind_presence_t)find_export("bind_presence", 1,0);
+    if (!bind_presence) {
+	LM_ERR("can't bind presence\n");
+	return -1;
+    }
+    if (bind_presence(&pres) < 0) {
+	LM_ERR("can't bind pua\n");
+	return -1;
+    }
+
+    pres_add_event = pres.add_event;
+    if (add_event == NULL) {
+	LM_ERR("could not import add_event\n");
+	return -1;
+    }
+    if(profile_add_events() < 0) {
+	LM_ERR("failed to add profile events\n");
+	return -1;		
+    }	
+    
+    return 0;
+}

+ 38 - 0
modules_k/presence_profile/presence_profile.h

@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Mészáros Mihály
+ *
+ * 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
+ *
+ * History:
+ * --------
+ *  2011-09-22  initial version (misi)
+ */
+
+/*!
+ * \file
+ * \brief SIP-router Presence :: ua-profile provisioning support
+ * \ingroup presence
+ * Module: \ref presence
+ */
+
+
+#ifndef _PRES_PROFILE_H_
+#define _PRES_PROFILE_H_
+
+extern add_event_t pres_add_event;
+
+#endif