No subject

=3D?UTF-8?q?M=3DC3=3DA9sz=3DC3=3DA1ros=3D20Mih=3DC3=3DA1ly?=3D mis=
Tue Aug 30 21:52:48 CEST 2011


i at niif.hu>
Date: Thu, 29 Sep 2011 10:14:12 +0200
Subject: [PATCH] add basic ua-profile event support

---
 Makefile                                           |    4 +-
 modules/tls/Makefile                               |    1 +
 modules_k/presence/event_list.c                    |    2 +-
 modules_k/presence_profile/Makefile                |   11 ++
 modules_k/presence_profile/README                  |   77 +++++++++++++
 modules_k/presence_profile/add_events.c            |   66 +++++++++++
 modules_k/presence_profile/add_events.h            |   40 +++++++
 modules_k/presence_profile/doc/Makefile            |    4 +
 .../presence_profile/doc/presence_profile.xml      |   39 +++++++
 .../doc/presence_profile_admin.xml                 |   72 ++++++++++++
 modules_k/presence_profile/presence_profile.c      |  118 ++++++++++++++=
++++++
 modules_k/presence_profile/presence_profile.h      |   38 +++++++
 parser/parse_event.c                               |    1 +
 parser/parse_event.h                               |    1 +
 14 files changed, 471 insertions(+), 3 deletions(-)
 create mode 100644 modules_k/presence_profile/Makefile
 create mode 100644 modules_k/presence_profile/README
 create mode 100644 modules_k/presence_profile/add_events.c
 create mode 100644 modules_k/presence_profile/add_events.h
 create mode 100644 modules_k/presence_profile/doc/Makefile
 create mode 100644 modules_k/presence_profile/doc/presence_profile.xml
 create mode 100644 modules_k/presence_profile/doc/presence_profile_admin=
.xml
 create mode 100644 modules_k/presence_profile/presence_profile.c
 create mode 100644 modules_k/presence_profile/presence_profile.h

diff --git a/Makefile b/Makefile
index 0eb44e8..dc81f2c 100644
--- a/Makefile
+++ b/Makefile
@@ -174,7 +174,7 @@ module_group_radius=3Dacc_radius auth_radius misc_rad=
ius avp_radius uri_radius \
=20
 # For presence
 # kamailio modules
-module_group_presence=3Dpresence presence_dialoginfo presence_mwi presen=
ce_xml \
+module_group_presence=3Dpresence presence_dialoginfo presence_mwi presen=
ce_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
@@ -259,7 +259,7 @@ module_group_kmemcached=3Dmemcached
 module_group_ktls=3Dtls
=20
 # K presence modules
-module_group_kpresence=3Dpresence presence_dialoginfo presence_mwi prese=
nce_xml \
+module_group_kpresence=3Dpresence presence_dialoginfo presence_mwi prese=
nce_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
diff --git a/modules/tls/Makefile b/modules/tls/Makefile
index 6e00b70..dd446c7 100644
--- a/modules/tls/Makefile
+++ b/modules/tls/Makefile
@@ -10,6 +10,7 @@ auto_gen=3D
 NAME=3Dtls.so
=20
 DEFS+=3D -I$(LOCALBASE)/ssl/include
+EXTRA_DEFS=3D"-DTLS_WR_DEBUG -DTLS_RD_DEBUG"
 LIBS+=3D	-L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib \
 		-L$(LOCALBASE)/lib64 -L$(LOCALBASE)/ssl/lib64 \
 		-lssl  -lcrypto \
diff --git a/modules_k/presence/event_list.c b/modules_k/presence/event_l=
ist.c
index 0d628b6..eb83d6b 100644
--- a/modules_k/presence/event_list.c
+++ b/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)=3D=3D 0))
 		{
-			if(event->params.list=3D=3D NULL && pres_ev->evp->params.list=3D=3D N=
ULL)
+			if((event->params.list=3D=3D NULL && pres_ev->evp->params.list=3D=3D =
NULL) || event->type=3D=3DEVENT_UA_PROFILE)
 			{
 				return pres_ev;
 			}
diff --git a/modules_k/presence_profile/Makefile b/modules_k/presence_pro=
file/Makefile
new file mode 100644
index 0000000..addf9e2
--- /dev/null
+++ b/modules_k/presence_profile/Makefile
@@ -0,0 +1,11 @@
+#=20
+# WARNING: do not run this directly, it should be run by the master Make=
file
+
+include ../../Makefile.defs
+auto_gen=3D
+NAME=3Dpresence_profile.so
+LIBS=3D
+
+DEFS+=3D-DOPENSER_MOD_INTERFACE
+
+include ../../Makefile.modules
diff --git a/modules_k/presence_profile/README b/modules_k/presence_profi=
le/README
new file mode 100644
index 0000000..1d59539
--- /dev/null
+++ b/modules_k/presence_profile/README
@@ -0,0 +1,77 @@
+Presence_Profile Module
+
+Mih=C3=83=C2=A1ly M=C3=83=C2=A9sz=C3=83=C2=A1ros
+
+   <misi at niif.hu>
+
+Edited by
+
+M=C3=83=C2=A9sz=C3=83=C2=A1ros Mih=C3=83=C2=A1ly
+
+   <misi at niif.hu>
+
+   Copyright =C2=A9 2011 M=C3=83=C2=A9sz=C3=83=C2=A1ros Mih=C3=83=C2=A1l=
y
+     __________________________________________________________________
+
+   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 subscri=
be
+   to ua-profile provisioning information if you add a provisioning
+   document to presentity table.
+
+   Warning: When you add provisioning config to presentity table, then y=
ou
+   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 even=
t
+   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.
diff --git a/modules_k/presence_profile/add_events.c b/modules_k/presence=
_profile/add_events.c
new file mode 100644
index 0000000..d4ee90c
--- /dev/null
+++ b/modules_k/presence_profile/add_events.c
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright (C) 2011 M=C3=A9sz=C3=A1ros Mih=C3=A1ly
+ *
+ * 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=20
+ * along with this program; if not, write to the Free Software=20
+ * 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;
+=09
+    /* constructing profile event */
+    memset(&event, 0, sizeof(pres_ev_t));
+    event.name.s =3D "ua-profile";
+    event.name.len =3D 10;
+
+
+    event.content_type.s =3D "text/xml";
+    event.content_type.len =3D 8;
+
+    event.default_expires=3D 3600;
+    event.type =3D PUBL_TYPE;
+    event.req_auth =3D 0;
+    event.evs_publ_handl =3D 0;
+   =20
+    if (pres_add_event(&event) < 0) {
+	LM_ERR("failed to add event \"ua-profile\"\n");
+	return -1;
+    }	=09
+=09
+    return 0;
+}
diff --git a/modules_k/presence_profile/add_events.h b/modules_k/presence=
_profile/add_events.h
new file mode 100644
index 0000000..6d9498f
--- /dev/null
+++ b/modules_k/presence_profile/add_events.h
@@ -0,0 +1,40 @@
+/*
+ * presence_profile module - add_event header file
+ *
+ * Copyright (C) 2011 M=C3=A9sz=C3=A1ros Mih=C3=A1ly
+ *
+ * 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=20
+ * along with this program; if not, write to the Free Software=20
+ * 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
diff --git a/modules_k/presence_profile/doc/Makefile b/modules_k/presence=
_profile/doc/Makefile
new file mode 100644
index 0000000..3c6a162
--- /dev/null
+++ b/modules_k/presence_profile/doc/Makefile
@@ -0,0 +1,4 @@
+docs =3D presence_profile.xml
+
+docbook_dir =3D ../../../docbook
+include $(docbook_dir)/Makefile.module
diff --git a/modules_k/presence_profile/doc/presence_profile.xml b/module=
s_k/presence_profile/doc/presence_profile.xml
new file mode 100644
index 0000000..9478a57
--- /dev/null
+++ b/modules_k/presence_profile/doc/presence_profile.xml
@@ -0,0 +1,39 @@
+<?xml version=3D"1.0" encoding=3D'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=3D"http://www.w3.org/2001/XInclude">
+    <bookinfo>
+	<title>Presence_Profile Module</title>
+	<productname class=3D"trade">&kamailioname;</productname>
+	<authorgroup>
+	    <author>
+		<firstname>Mih=C3=A1ly</firstname>
+		<surname>M=C3=A9sz=C3=A1ros</surname>
+		<email>misi at niif.hu</email>
+	    </author>
+	    <editor>
+		<firstname>M=C3=A9sz=C3=A1ros</firstname>
+		<surname>Mih=C3=A1ly</surname>
+  	        <email>misi at niif.hu</email>
+	    </editor>
+	</authorgroup>
+	<copyright>
+	    <year>2011</year>
+	    <holder>M=C3=A9sz=C3=A1ros Mih=C3=A1ly</holder>
+	</copyright>
+  </bookinfo>
+    <toc></toc>
+   =20
+    <xi:include href=3D"presence_profile_admin.xml"/>
+   =20
+   =20
+</book>
+
+
diff --git a/modules_k/presence_profile/doc/presence_profile_admin.xml b/=
modules_k/presence_profile/doc/presence_profile_admin.xml
new file mode 100644
index 0000000..e1c026f
--- /dev/null
+++ b/modules_k/presence_profile/doc/presence_profile_admin.xml
@@ -0,0 +1,72 @@
+<?xml version=3D"1.0" encoding=3D'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>
+=09
+
+	<title>&adminguide;</title>
+=09
+	<section>
+	  <title>Overview</title>
+	    <para>=20
+	      The module does a very basic handling for ua-profile.
+	      You can subscribe to ua-profile provisioning information if you a=
dd a provisioning document to presentity table.
+	    </para>
+	    <para>
+	      Warning: When you add provisioning config to presentity table, th=
en you must make sure=20
+	      that you set the presentity table expires field to a time value i=
n 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 notifi=
cation 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>
+=09
+	<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>
+
diff --git a/modules_k/presence_profile/presence_profile.c b/modules_k/pr=
esence_profile/presence_profile.c
new file mode 100644
index 0000000..686dbd5
--- /dev/null
+++ b/modules_k/presence_profile/presence_profile.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2011 M=C3=A9sz=C3=A1ros Mih=C3=A1ly
+ *
+ * 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=20
+ * along with this program; if not, write to the Free Software=20
+ * 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 u=
a-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[] =3D
+{
+    {0,	0, 0, 0, 0, 0}
+};
+
+/* module exported paramaters */
+static param_export_t params[] =3D {
+    {0, 0, 0}
+};
+
+/* module exports */
+struct module_exports exports=3D {
+    "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 */
+};
+=09
+/*
+ * init module function
+ */
+static int mod_init(void)
+{
+	presence_api_t pres;
+    bind_presence_t bind_presence;
+
+    bind_presence=3D (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 =3D pres.add_event;
+    if (add_event =3D=3D 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;	=09
+    }=09
+   =20
+    return 0;
+}
diff --git a/modules_k/presence_profile/presence_profile.h b/modules_k/pr=
esence_profile/presence_profile.h
new file mode 100644
index 0000000..2b17fea
--- /dev/null
+++ b/modules_k/presence_profile/presence_profile.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 M=C3=A9sz=C3=A1ros Mih=C3=A1ly
+ *
+ * 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=20
+ * along with this program; if not, write to the Free Software=20
+ * 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
diff --git a/parser/parse_event.c b/parser/parse_event.c
index 4211da2..87d1c51 100644
--- a/parser/parse_event.c
+++ b/parser/parse_event.c
@@ -54,6 +54,7 @@ static struct {
 	{STR_STATIC_INIT("presence.winfo"),  EVENT_PRESENCE_WINFO},
 	{STR_STATIC_INIT("xcap-change"),     EVENT_XCAP_CHANGE},
 	{STR_STATIC_INIT("sip-profile"),     EVENT_SIP_PROFILE},
+	{STR_STATIC_INIT("ua-profile"),      EVENT_UA_PROFILE},
 	{STR_STATIC_INIT("message-summary"), EVENT_MESSAGE_SUMMARY},
 	{STR_STATIC_INIT("dialog"),          EVENT_DIALOG},
 	/* The following must be the last element in the array */
diff --git a/parser/parse_event.h b/parser/parse_event.h
index ab51b79..62175f3 100644
--- a/parser/parse_event.h
+++ b/parser/parse_event.h
@@ -40,6 +40,7 @@ enum event_type {
 	EVENT_OTHER =3D 0,
 	EVENT_PRESENCE,
 	EVENT_PRESENCE_WINFO,
+	EVENT_UA_PROFILE,
 	EVENT_SIP_PROFILE,
 	EVENT_XCAP_CHANGE,
 	EVENT_DIALOG,
--=20
1.7.6.3



--------------050707060309060700010606--



More information about the sr-dev mailing list