-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3332 from carstenbock/presence_add_reginfo_module
Presence: add "reginfo" module
- Loading branch information
Showing
9 changed files
with
771 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# Presence_reginfo Makefile | ||
# | ||
# | ||
# WARNING: do not run this directly, it should be run by the main Makefile | ||
|
||
include ../../Makefile.defs | ||
auto_gen= | ||
NAME=presence_reginfo.so | ||
|
||
ifeq ($(CROSS_COMPILE),) | ||
XML2CFG=$(shell which xml2-config) | ||
ifeq ($(XML2CFG),) | ||
XML2CFG=$(shell \ | ||
if pkg-config --exists libxml-2.0; then \ | ||
echo 'pkg-config libxml-2.0'; \ | ||
fi) | ||
endif | ||
endif | ||
|
||
ifneq ($(XML2CFG),) | ||
DEFS += $(shell $(XML2CFG) --cflags ) | ||
LIBS += $(shell $(XML2CFG) --libs) | ||
else | ||
DEFS+=-I$(LOCALBASE)/include/libxml2 \ | ||
-I$(LOCALBASE)/include | ||
LIBS+=-L$(LOCALBASE)/lib -lxml2 | ||
endif | ||
|
||
include ../../Makefile.modules | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* presence_reginfo module - Presence Handling of reg events | ||
* | ||
* Copyright (C) 2011, 2023 Carsten Bock, [email protected] | ||
* | ||
* This file is part of opensips, a free SIP server. | ||
* | ||
* opensips 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 | ||
* | ||
* opensips 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "../../parser/parse_content.h" | ||
#include "../presence/event_list.h" | ||
#include "presence_reginfo.h" | ||
#include "notify_body.h" | ||
|
||
extern int pres_reginfo_aggregate_presentities; | ||
|
||
int reginfo_add_events(void) | ||
{ | ||
pres_ev_t event; | ||
|
||
/* constructing message-summary event */ | ||
memset(&event, 0, sizeof(pres_ev_t)); | ||
event.name.s = "reg"; | ||
event.name.len = 3; | ||
|
||
event.content_type.s = "application/reginfo+xml"; | ||
event.content_type.len = 23; | ||
event.default_expires = pres_reginfo_default_expires; | ||
event.type = PUBL_TYPE; | ||
event.req_auth = 0; | ||
event.evs_publ_handl = 0; | ||
/* modify XML body for each watcher to set the correct "version" */ | ||
event.aux_body_processing = reginfo_body_setversion; | ||
event.aux_free_body= free_xml_body; | ||
event.etag_not_new = 0; | ||
|
||
if(pres_reginfo_aggregate_presentities) { | ||
/* aggregate XML body and free() function */ | ||
event.agg_nbody = reginfo_agg_nbody; | ||
event.free_body = free_xml_body; | ||
} | ||
|
||
if(pres_add_event(&event) < 0) { | ||
LM_ERR("failed to add event \"reginfo\"\n"); | ||
return -1; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* presence_reginfo module - Presence Handling of reg events | ||
* | ||
* Copyright (C) 2011, 2023 Carsten Bock, [email protected] | ||
* | ||
* This file is part of opensips, a free SIP server. | ||
* | ||
* opensips 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 | ||
* | ||
* opensips 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
|
||
#ifndef _REGINFO_ADD_EV_H_ | ||
#define _REGINFO_ADD_EV_H_ | ||
|
||
int reginfo_add_events(void); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "../../../../doc/docbook/entities.xml"> | ||
%docentities; | ||
|
||
]> | ||
|
||
<book xmlns:xi="http://www.w3.org/2001/XInclude"> | ||
<bookinfo> | ||
<title>presence_reginfo Module</title> | ||
<productname class="trade">&osipsname;</productname> | ||
<authorgroup> | ||
<author> | ||
<firstname>Carsten</firstname> | ||
<surname>Bock</surname> | ||
<email>[email protected]</email> | ||
</author> | ||
<editor> | ||
<firstname>Carsten</firstname> | ||
<surname>Bock</surname> | ||
<email>[email protected]</email> | ||
</editor> | ||
</authorgroup> | ||
<copyright> | ||
<year>2011, 2023</year> | ||
<holder>Carsten Bock, [email protected], http://www.ng-voice.com</holder> | ||
</copyright> | ||
</bookinfo> | ||
<toc></toc> | ||
|
||
<xi:include href="presence_reginfo_admin.xml"/> | ||
|
||
|
||
</book> | ||
|
||
|
120 changes: 120 additions & 0 deletions
120
modules/presence_reginfo/doc/presence_reginfo_admin.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?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 "../../../../doc/docbook/entities.xml"> | ||
%docentities; | ||
|
||
]> | ||
<!-- Module User's Guide --> | ||
|
||
<chapter> | ||
|
||
|
||
<title>&adminguide;</title> | ||
|
||
<section> | ||
<title>Overview</title> | ||
<para> | ||
The module enables the handling of "Event: reg" (as defined | ||
in RFC 3680) inside of the presence module. This can be used | ||
distribute the registration-info status to the subscribed watchers. | ||
</para> | ||
<para> | ||
The module does not currently implement any authorization | ||
rules. It assumes that publish requests are only issued by | ||
an authorized application and subscribe requests only by | ||
authorized users. Authorization can thus be easily done in | ||
&osips; configuration file before calling handle_publish() | ||
and handle_subscribe() functions. | ||
</para> | ||
<para> | ||
Note: This module only activates the processing of the "reg" | ||
in the presence module. To send dialog-info to watchers you also | ||
need a source which PUBLISH the reg info to the presence module. | ||
For example you can use the pua_reginfo module or any external | ||
component. This approach allows to have the presence server and the | ||
reg-info aware publisher (e.g. the main proxy) on different | ||
&osips; instances. | ||
</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>Parameters</title> | ||
<section id="presence_reginfo.p.default_expires"> | ||
<title><varname>default_expires</varname> (int)</title> | ||
<para> | ||
The default expires value used when missing from SUBSCRIBE | ||
message (in seconds). | ||
</para> | ||
<para> | ||
<emphasis>Default value is <quote>3600</quote>. | ||
</emphasis> | ||
</para> | ||
<example> | ||
<title>Set <varname>default_expires</varname> parameter</title> | ||
<programlisting format="linespecific"> | ||
... | ||
modparam("presence_reginfo", "default_expires", 3600) | ||
... | ||
</programlisting> | ||
</example> | ||
</section> | ||
|
||
<section id="presence_reginfo.p.aggregate_presentities"> | ||
<title><varname>aggregate_presentities</varname> (int)</title> | ||
<para> | ||
Whether to aggregate in a single notify body all registration | ||
presentities. Useful to have all registrations on first NOTIFY | ||
following initial SUBSCRIBE. | ||
</para> | ||
<para> | ||
<emphasis>Default value is <quote>0</quote> (disabled). | ||
</emphasis> | ||
</para> | ||
<example> | ||
<title>Set <varname>aggregate_presentities</varname> parameter</title> | ||
<programlisting format="linespecific"> | ||
... | ||
modparam("presence_reginfo", "aggregate_presentities", 1) | ||
... | ||
</programlisting> | ||
</example> | ||
</section> | ||
|
||
</section> | ||
|
||
|
||
<section> | ||
<title>Functions</title> | ||
<para> | ||
None to be used in configuration file. | ||
</para> | ||
</section> | ||
|
||
</chapter> |
Oops, something went wrong.