Commit Graph

42 Commits

Author SHA1 Message Date
George Joseph e52175341e res_pjsip_exten_state,res_pjsip_mwi: Allow unload on shutdown
Commit f66f77f last year prevents the res_pjsip_exten_state and
res_pjsip_mwi modules from unloading due to possible pjproject
asserts if the modules are reloaded. A side effect of the
implementation is that the taskprocessors these modules use aren't
being released. When asterisk is doing a graceful shutdown, it
waits AST_TASKPROCESSOR_SHUTDOWN_MAX_WAIT seconds for all
taskprocessors to stop but since those 2 modules don't release
theirs, the shutdown hangs for that amount of time.

This change allows the modules to be unloaded and their resources to
be released when ast_shutdown_final is true.

Resolves: #379
(cherry picked from commit 9efc4bdfbc)
2024-01-12 18:29:19 +00:00
Naveen Albert 9258d8212a res_pjsip_pubsub: Prevent removing subscriptions.
pjproject does not provide any mechanism of removing
event packages, which means that once a subscription
handler is registered, it is effectively permanent.

pjproject will assert if the same event package is
ever registered again, so currently unloading and
loading any Asterisk modules that use subscriptions
will cause a crash that is beyond our control.

For that reason, we now prevent users from being
able to unload these modules, to prevent them
from ever being loaded twice.

ASTERISK-30264 #close

Change-Id: I7fdcb1a5e44d38b7ba10c44259fe98f0ae9bc12c
2022-10-26 09:08:17 -05:00
Alexei Gradinari 12c4c1bf5f res_pjsip_pubsub: Postpone destruction of old subscriptions on RLS update
Set termination state to old subscriptions to prevent queueing and sending
NOTIFY messages on exten/device state changes.

Postpone destruction of old subscriptions until all already queued tasks
that may be using old subscriptions have completed.

ASTERISK-29906

Change-Id: I96582aad3a26515ca73a8460ee6756f56f6ba23b
2022-09-09 08:35:53 -05:00
Alexei Gradinari c12cb899de res_pjsip_pubsub: provide a display name for RLS subscriptions
Whereas BLFs allow to show a display name for each RLS entry,
the asterisk provides only the extension now.
This is not end user friendly.

This commit adds a new resource_list option, resource_display_name,
to indicate whether display name of resource or the resource name being
provided for RLS entries.
If this option is enabled, the Display Name will be provided.
This option is disabled by default to remain the previous behavior.
If the 'event' set to 'presence' or 'dialog' the non-empty HINT name
will be set as the Display Name.
The 'message-summary' is not supported yet.

ASTERISK-29891 #close

Change-Id: Ic5306bd5a7c73d03f5477fe235e9b0f41c69c681
2022-02-23 15:20:49 -06:00
Corey Farrell 021ce938ca
astobj2: Remove legacy ao2_container_alloc routine.
Replace usage of ao2_container_alloc with ao2_container_alloc_hash or
ao2_container_alloc_list.  Remove ao2_container_alloc macro.

Change-Id: I0907d78bc66efc775672df37c8faad00f2f6c088
2018-11-21 09:56:16 -05:00
Corey Farrell 527cf5a570 Remove redundant module checks and references.
This removes references that are no longer needed due to automatic
references created by module dependencies.

In addition this removes most calls to ast_module_check as they were
checking modules which are listed as dependencies.

Change-Id: I332a6e8383d4c72c8e89d988a184ab8320c4872e
2018-01-24 13:37:29 -05:00
Corey Farrell 9cfdb81e91 loader: Add dependency fields to module structures.
* Declare 'requires' and 'enhances' text fields on module info structure.
* Rename 'nonoptreq' to 'optional_modules'.
* Update doxygen comments.

Still need to investigate dependencies among modules I cannot compile.

Change-Id: I3ad9547a0a6442409ff4e352a6d897bef2cc04bf
2018-01-15 13:25:51 -05:00
Corey Farrell 8684219f79 res_pjsip_exten_state: Check for vector append failure.
Release reference to publisher if we fail to add it to the vector.

Change-Id: I64dff3f481b67b9884f37cadba7a5ccf23d084f3
2017-11-06 18:48:06 -05:00
George Joseph 4bdf5d329f res_pjsip_pubsub: Correctly implement persisted subscriptions
This patch fixes 2 original issues and more that those 2 exposed.

* When we send a NOTIFY, and the client either doesn't respond or
  responds with a non OK, pjproject only calls our
  pubsub_on_evsub_state callback, no others.  Since
  pubsub_on_evsub_state (which does the sub_tree cleanup) does not
  expect to be called back without the other callbacks being called
  first, it just returns leaving the sub_tree orphaned.  Now
  pubsub_on_evsub_state checks the event for PJSIP_EVENT_TSX_STATE
  which is what pjproject will set to tell us that it was the
  transaction that timed out or failed and not the subscription
  itself timing our or being terminated by the client. If is
  TSX_STATE, pubsub_on_evsub_state now does the proper cleanup
  regardless of the state of the subscription.

* When a client renews a subscription, we don't update the
  persisted subscription with the new expires timestamp.  This causes
  subscription_persistence_recreate to prune the subscription if/when
  asterisk restarts.  Now, pubsub_on_rx_refresh calls
  subscription_persistence_update to apply the new expires timestamp.
  This exposed other issues however...

* When creating a dialog from rdata (which sub_persistence_recreate
  does from the packet buffer) there must NOT be a tag on the To
  header (which there will be when a client refreshes a
  subscription).  If there is one, pjsip_dlg_create_uas will fail.
  To address this, subscription_persistence_update now accepts a flag
  that indicates that the original packet buffer must not be updated.
  New subscribes don't set the flag and renews do.  This makes sure
  that when the rdata is recreated on asterisk startup, it's done
  from the original subscribe packet which won't have the tag on To.

* When creating a dialog from rdata, we were setting the dialog's
  remote (SUBSCRIBE) cseq to be the same as the local (NOTIFY) cseq.
  When the client tried to resubscribe after a restart with the
  correct cseq, we'd reject the request with an Invalid CSeq error.

* The acts of creating a dialog and evsub by themselves when
  recreating a subscription does NOT restart pjproject's subscription
  timer.  The result was that even if we did correctly recreate the
  subscription, we never removed it if the client happened to go away
  or send a non-OK response to a NOTIFY.  However, there is no
  pjproject function exposed to just set the timer on an evsub that
  wasn't created by an incoming subscribe request.  To address this,
  we create our own timer using ast_sip_schedule_task.  This timer is
  used only for re-establishing subscriptions after a restart.

  An earlier approach was to add support for setting pjproject's
  timer (via a pjproject patch) and while that patch is still included
  here, we don't use that call at the moment.

While addressing these issues, additional debugging was added and
some existing messages made more useful.  A few formatting changes
were also made to 'pjsip show scheduled tasks' to make displaying
the subscription timers a little more friendly.

ASTERISK-26696
ASTERISK-26756

Change-Id: I8c605fc1e3923f466a74db087d5ab6f90abce68e
2017-02-15 13:11:46 -06:00
Alexei Gradinari 1c949eea6c res_pjsip: Added "subscribe_context" to endpoint
If specified, incoming SUBSCRIBE requests will be searched for the matching
extension in the indicated context. If no "subscribe_context" is specified,
then the "context" setting is used.

ASTERISK-25471 #close

Change-Id: I3fb7a15f5bc154079bd348c08b7ad1cdd2d5e514
2016-07-06 10:30:27 -04:00
Joshua Colp d4b77dad1b res_pjsip_exten_state: Use the extension for publishing to.
This change uses the newly added multi-user support for
outbound publish to publish to the specific user that an
extension state change is for.

This also extends the res_pjsip_outbound_publish support
to include the user specific From and To URI information in
the outbound publishing of extension state. Since the URI
is used when constructing the body it is important to ensure
that the correct local and remote URIs are used.

Finally the max string growths for the dialog-info+xml
body generator has been increased as through testing it has
proven to be too conservative.

ASTERISK-25965

Change-Id: I668fdf697b1e171d4c7e6f282b2e1590f8356ca1
2016-05-18 18:37:27 -05:00
Joshua Colp d03e170ae7 res_pjsip_pubsub: Use common datastores container API.
This migrates res_pjsip_pubsub over to using the newly
introduce common datastores management API instead of using
its own implementations for both subscriptions and
publications.

As well the extension state data now provides a generic
datastores container instead of a subscription. This allows
the dialog-info+xml body generator to work for both
subscriptions and publications.

ASTERISK-25999 #close

Change-Id: I773f9e4f35092da0f653566736a8647e8cfebef1
2016-05-09 10:40:36 -03:00
Richard Mudgett 2c46063d54 res_pjsip_exten_state: Create PUBLISH messages.
Create PUBLISH messages to update a third party when an extension state
changes because of either a device or presence state change.

A configuration example:

[exten-state-publisher]
type=outbound-publish
server_uri=sip:instance1@172.16.10.2
event=presence
; Optional regex for context filtering, if specified only extension state
; for contexts matching the regex will cause a PUBLISH to be sent.
@context=^users
; Optional regex for extension filtering, if specified only extension
; state for extensions matching the regex will cause a PUBLISH to be sent.
@exten=^[0-9]*
; Required body type for the PUBLISH message.
;
; Supported values are:
; application/pidf+xml
; application/xpidf+xml
; application/cpim-pidf+xml
; application/dialog-info+xml (Planned support but not yet)
@body=application/pidf+xml

The '@' extended variables are used because the implementation can't
extend the outbound publish type as it is provided by the outbound publish
module.  That means you either have to use extended variables, or
implement some sort of custom extended variable thing in the outbound
publish module.  Another option would be to refactor that stuff to have an
option which specifies the use of an alternate implementation's
configuration and then have that passed to the implementation.  JColp
opted for the extended variables method originally.

ASTERISK-25972 #close

Change-Id: Ic0dab4022f5cf59302129483ed38398764ee3cca
2016-04-29 14:53:40 -05:00
Joshua Colp bc19d9a2b0 Merge "res_pjsip_exten_state: Check if body generator is available." 2016-04-29 14:33:01 -05:00
Richard Mudgett 0b5292525c res_pjsip_exten_state: Check if body generator is available.
When starting the extension state publishers, check if the requested
message body generator is available.  If not available give error message
and skip starting that publisher.

* res_pjsip_pubsub.c: Create new API if type/subtype generator
registered.

* res_pjsip_exten_state.c: Use new body generator API for validation.

ASTERISK-25922

Change-Id: I4ad69200666e3cc909d4619e3c81042d7f9db25c
2016-04-28 17:14:44 -05:00
Richard Mudgett 369182d084 res_pjsip: Start body generator users after suppliers.
Change-Id: I8f0b57841feaab56c8a4e821b5ccb4e05e5fbadb
2016-04-28 17:07:22 -05:00
Joshua Colp 81ea80b74c res_pjsip_exten_state: Add config support for exten state publishers.
This change adds the ability to configure outbound publishing of
extension state. Right now stuff is merely set up to store the
configuration and to register a global extension state callback. The
act of constructing the body and sending is not yet complete.

Configurable elements right now are a regex for filtering the context,
a regex for filtering the extension, and the body type to publish.

ASTERISK-25922 #close

Change-Id: Ia7e630136dfc355073c1cadff8ad394a08523d78
2016-04-26 18:47:51 -05:00
Richard Mudgett 6138a75e8e pbx.h: Make ast_state_cb_type take more const.
This eliminates some casts that I made a note saying v10 and above
would no longer need them.

Better late than never :)

Change-Id: I346cdb3032b6478ceb40eb6fe732978b54035572
2016-04-07 17:20:17 -05:00
Mark Michelson ac0194dad6 res_pjsip_pubsub: Solidify lifetime and ownership of objects.
There have been crashes and general instability seen in the pubsub code,
so this patch introduces three changes to increase the stability.

First, the ownership model for subscriptions has been modified. Due to
RLS, subscriptions are stored in memory as a tree structure. Prior to my
patch, the PJSIP subscription was the owner of the subscription tree.
When the PJSIP subscription told us that it was terminating, we started
destroying the subscription tree along with all of the individual leaf
subscriptions that belong to the tree. The problem with this model is
that the two actors in play here, the PJSIP subscription and the
individual leaf subscriptions, need to have joint ownership of the
subscription tree. So now, the PJSIP subscription and the individual
leaf subscriptions each have a reference to the subscription tree. This
way, we will not actually free memory until no players are left that
care. The PJSIP subscription is a bigger stakeholder, in that if the
PJSIP subscription's reference to the subscription tree is removed, the
subscription tree instructs the leaf subscriptions to shut down and drop
their references to the subscription tree when possible. The individual
leaf subscriptions, upon being told to shut down, can drop their stasis
subscriptions or whatever they use to learn of new state, and then drop
their reference to the subscription tree once they are ready to die.

Second, the lifetime of a PJSIP subscription's reference to our
subscription tree has been altered. As I learned from doing a deep dive,
the PJSIP evsub code can tell Asterisk multiple times that the
subscription has been terminated, and not all of these times
are especially helpful. I have altered the message flow that we use for
SIP subscriptions such that we will always drop the PJSIP subscription's
reference to the subscription tree when we send the NOTIFY that
terminates a SIP subscription. This also means that we will now queue
NOTIFY requests to be sent after responding to incoming SUBSCRIBEs so
that we can have predictable state changes from the PJSIP evsub code.

Third, the synchronization of operations has been improved. PJSIP can
call into our code from a serializer thread (e.g. upon receiving an
incoming request) or from the monitor thread (e.g. when a subscription
times out). Because of this, there is the possibility of competing
threads stepping on each other. PJSIP attempts to do some
synchronization on its own by always keeping the dialog lock held when
it calls into us. However, since we end up pushing tasks into the
serializer, the result was that serialized operations were not grabbing
the dialog lock and could, as a result, step on something that was being
attempted by a different thread. Now we ensure that serialized
operations grab the dialog lock, then check for extenuating
circumstances, then proceed with their operation if they can.

Change-Id: Iff2990c40178dad9cc5f6a5c7f76932ec644b2e5
2015-10-22 15:39:58 -05:00
Matt Jordan ad7192a8fd res/res_pjsip_exten_state: Fix confusing NOTICE message
When a SUBSCRIBE request is made to a dialplan hint that doesn't exist,
the current NOTICE message informing users of this swaps the context and
extension parameters. This can cause a bit of confusion.

Thanks to CptBurger in #asterisk for helping to point this out.

Change-Id: Ie584d1a58ae217385c87a450ca25b55ca0e36e43
2015-05-22 12:23:52 -05:00
Rodrigo Ramírez Norambuena eec010829a AST_MODULE_INFO: Format corrections to the usages of AST_MODULE_INFO macro.
Change-Id: Icf88f9f861c6b2a16e5f626ff25795218a6f2723
2015-05-13 16:34:23 -05:00
Joshua Colp e33682cae2 res_pjsip_exten_state: Fix race condition between sending NOTIFY and termination
The res_pjsip_exten_state module currently has a race condition between
processing the extension state callback from the PBX core and processing
the subscription shutdown callback from res_pjsip_pubsub. There is currently
no synchronization between the two. This can present a problem as while
the SIP subscription will remain valid the tree it points to may not.
This is in particular a problem as a task to send a NOTIFY may get queued
which will try to use the tree that may no longer be valid.

This change does the following to fix this problem:

1. All access to the subscription tree is done within the task that
sends the NOTIFY to ensure that no other thread is modifying or
destroying the tree. This task executes on the serializer for the
subscriptions.

2. A reference to the subscription serializer is kept to ensure it
remains valid for the lifetime of the extension state subscription.

3. The NOTIFY task has been changed so it will no longer attempt
to send a NOTIFY if the subscription has already been terminated.

ASTERISK-25057 #close
Reported by: Matt Jordan

Change-Id: I0b3cd2fac5be8d9b3dc5e693aaa79846eeaf5643
2015-05-07 07:42:10 -05:00
Matthew Jordan ea0098724e clang compiler warnings: Fix autological comparisons
This fixes autological comparison warnings in the following:
 * chan_skinny: letohl may return a signed or unsigned value, depending on the
   macro chosen
 * func_curl: Provide a specific cast to CURLoption to prevent mismatch
 * cel: Fix enum comparisons where the enum can never be negative
 * enum: Fix comparison of return result of dn_expand, which returns a signed
   int value
 * event: Fix enum comparisons where the enum can never be negative
 * indications: tone_data.freq1 and freq2 are unsigned, and hence can never be
   negative
 * presencestate: Use the actual enum value for INVALID state
 * security_events: Fix enum comparisons where the enum can never be negative
 * udptl: Don't bother to check if the return value from encode_length is less
   than 0, as it returns an unsigned int
 * translate: Since the parameters are unsigned int, don't bother checking
   to see if they are negative. The cast to unsigned int would already blow
   past the matrix bounds.
 * res_pjsip_exten_state: Use a temporary value to cache the return of
   ast_hint_presence_state
 * res_stasis_playback: Fix enum comparisons where the enum can never be
   negative
 * res_stasis_recording: Add an enum value for the case where the recording
   operation is in error; fix enum comparisons
 * resource_bridges: Use enum value as opposed to -1
 * resource_channels: Use enum value as opposed to -1

Review: https://reviewboard.asterisk.org/r/4533
ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4533.patch submitted by dkdegroot (License 6600)
........

Merged revisions 434469 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 434470 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434471 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-04-09 12:57:21 +00:00
Joshua Colp fae6bf8ace res_pjsip_exten_state: Improve log message when a subscription is attempted to a non-existent extension.
ASTERISK-24716 #close
Reported by: Rusty Newton
........

Merged revisions 431754 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431755 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-02-14 18:31:15 +00:00
George Joseph 8357ffab9c res_pjsip_exten_state: Reduce log clutter... change a WARNING to a VERBOSE/2
Reduce log clutter by changing the "Watcher for hint %s (removed|deactivated)"
message from WARNING to VERBOSE/2.

Tested-by: George Joseph

Review: https://reviewboard.asterisk.org/r/4387/
........

Merged revisions 431403 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431404 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-29 16:47:28 +00:00
George Joseph e83853eebc res_pjsip_exten_state: Change 'does not exist' warning to notice
The 'new_subscribe: Extension <> does not exist or has no associated hint'
is a config issue and doesn't need to clutter up logs with warnings.
Changed to notice.

Tested-by: George Joseph

Review: https://reviewboard.asterisk.org/r/4307/
........

Merged revisions 430319 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430321 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2015-01-07 18:17:42 +00:00
Kevin Harwell a537e314d1 res_pjsip_exten_state: PJSIPShowSubscriptionsInbound causes crash
Currently, it is possible for some subscriptions to get into a NULL state. When
this occurs and the PJSIPShowSubscriptionsInbound ami action is issued and a
device is subscribed for extension state then the associated subscription state
object can't be located.  The code then attempts to dereference a NULL object.
Added a NULL check to avoid the problem.

Reported by: John Bigelow
........

Merged revisions 426779 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 426780 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@426781 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-30 21:14:01 +00:00
Kinsey Moore 86a4ce4957 PJSIP: Enforce module load dependencies
This enforces that res_pjsip, res_pjsip_session, and res_pjsip_pubsub
have loaded properly before attempting to load any modules that depend
on them since the module loader system is not currently capable of
resolving module dependencies on its own.

ASTERISK-24312 #close
Reported by: Dafi Ni
Review: https://reviewboard.asterisk.org/r/4062/
........

Merged revisions 425690 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 425691 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425700 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-10-16 16:32:25 +00:00
Mark Michelson 79eac1ffca res_pjsip_pubsub: Add some type safety when generating NOTIFY bodies.
res_pjsip_pubsub has two separate checks that it makes when a SUBSCRIBE
arrives.
* It checks that there is a subscription handler for the Event
* It checks that there are body generators for the types in the Accept header

The problem is, there's nothing that ensures that these two things will
actually mesh with each other. For instance, Asterisk will accept a subscription
to MWI that accepts pidf+xml bodies. That doesn't make sense.

With this commit, we add some type information to the mix. Subscription
handlers state they generate data of type X, and body generators state
that they consume data of type X. This way, Asterisk doesn't end up in
some hilariously mismatched situation like the one in the previous paragraph.

ASTERISK-24136 #close
Reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/3877
Review: https://reviewboard.asterisk.org/r/3878
........

Merged revisions 423344 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 423348 from http://svn.asterisk.org/svn/asterisk/branches/13


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-09-18 16:09:25 +00:00
Mark Michelson 99d0bccd35 Add support for RFC 4662 resource list subscriptions.
This commit adds the ability for a user to configure
a resource list in pjsip.conf. Subscribing to this
list simultaneously subscribes the subscriber to all
resources listed. This has the potential to reduce
the amount of SIP traffic when loads of subscribers
on a system attempt to subscribe to each others' states.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-08-07 19:26:32 +00:00
Mark Michelson dcf1ad14da Add module support level to ast_module_info structure. Print it in CLI "module show" .
ASTERISK-23919 #close
Reported by Malcolm Davenport

Review: https://reviewboard.asterisk.org/r/3802



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419592 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-25 16:47:17 +00:00
Joshua Colp 534ffd8481 res_pjsip_dialog_info_body_generator: Add dialog-info+xml support for presence.
This module implements dialog-info+xml for the purposes of presence. This means
that phones such as Grandstreams can now subscribe to receive presence information
for an extension.

ASTERISK-21443 #close
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/3705/
........

Merged revisions 418116 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418117 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-07 16:08:47 +00:00
Mark Michelson bc8c08c609 Abstract PJSIP-specific elements from the pubsub API.
This helps to pave the way for RLS work that is to come.
Since this is a self-contained change and subscription
tests still pass, this work is being committed directly
to trunk instead of a working branch.

ASTERISK-23865 #close
Review: https://reviewboard.asterisk.org/r/3628



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417233 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-25 20:57:28 +00:00
Joshua Colp 58f4c18ab6 res_pjsip_pubsub: Persist subscriptions in sorcery so they are recreated on startup.
This change makes res_pjsip_pubsub persist inbound subscriptions in sorcery. By default
this uses the local astdb but it can also be configured to store within an outside
database. When Asterisk is started these subscriptions are recreated if they have not
expired. Notifications are sent to the devices which have subscribed and they are none
the wiser that the system has restarted.

Review: https://reviewboard.asterisk.org/r/3598/
........

Merged revisions 415766 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-06-12 11:34:36 +00:00
Mark Michelson fc4c5ca3de Remove unnecessary repetition checks from res_pjsip_exten_state
The PBX core already takes care of ensuring that repeated state changes
are not communicated to exten state consumers. Because the check in res_pjsip_exten_state
was incomplete, it was causing valid presence state changes not to be sent out. For instance,
if the presence state did not change but the message or subtype did, then no presence-related
NOTIFY request would be sent out.

closes issue ASTERISK-23672
Reported by Mark Michelson
........

Merged revisions 413173 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413174 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-05-01 15:47:49 +00:00
Kevin Harwell 73ad9430e8 res_pjsip_exten_state: Presence for digium phones
Added presence support for digium phones.

Review: https://reviewboard.asterisk.org/r/3239/
........

Merged revisions 408882 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@408883 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-02-25 17:51:51 +00:00
Kevin Harwell f5bb5b3e8c res_pjsip_exten_state: Exporting global symbols caused load order issues
Removed the exportation of global symbols from the module as it is no longer
needed and it could potentially cause load problems as on some systems it
would try to load before res_pjsip_pubsub
........

Merged revisions 407034 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407035 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 23:13:39 +00:00
Mark Michelson f55abe9cf1 Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.

This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.

Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).

Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.

Review: https://reviewboard.asterisk.org/r/3150
........

Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
Kevin Harwell 05cbf8df9b res_pjsip: AMI commands and events.
Created the following AMI commands and corresponding events for res_pjsip:

PJSIPShowEndpoints - Provides a listing of all pjsip endpoints and a few
                     select attributes on each.
  Events:
    EndpointList - for each endpoint a few attributes.
    EndpointlistComplete - after all endpoints have been listed.

PJSIPShowEndpoint - Provides a detail list of attributes for a specified
                    endpoint.
  Events:
    EndpointDetail - attributes on an endpoint.
    AorDetail - raised for each AOR on an endpoint.
    AuthDetail - raised for each associated inbound and outbound auth
    TransportDetail - transport attributes.
    IdentifyDetail - attributes for the identify object associated with
                     the endpoint.
    EndpointDetailComplete - last event raised after all detail events.

PJSIPShowRegistrationsInbound - Provides a detail listing of all inbound
                                registrations.
  Events:
    InboundRegistrationDetail - inbound registration attributes for each
                                registration.
    InboundRegistrationDetailComplete - raised after all detail records have
                                been listed.

PJSIPShowRegistrationsOutbound  - Provides a detail listing of all outbound
                                  registrations.
  Events:
    OutboundRegistrationDetail - outbound registration attributes for each
                                 registration.
    OutboundRegistrationDetailComplete - raised after all detail records
                                 have been listed.

PJSIPShowSubscriptionsInbound - A detail listing of all inbound subscriptions
                                and their attributes.
  Events:
    SubscriptionDetail - on each subscription detailed attributes
    SubscriptionDetailComplete - raised after all detail records have
                                 been listed.

PJSIPShowSubscriptionsOutbound - A detail listing of all outboundbound
                                subscriptions and their attributes.
  Events:
    SubscriptionDetail - on each subscription detailed attributes
    SubscriptionDetailComplete - raised after all detail records have
                                 been listed.

(issue ASTERISK-22609)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2959/
........

Merged revisions 403131 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403133 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-11-23 17:26:57 +00:00
Mark Michelson 8049bf94f7 Handle default body types for SIP event packages in res_pjsip_pubsub
Prior to this change, we would reject SUBSCRIBE requests that had no Accept
headers. Now event package handlers that handle the default type for the
event package indicate that they do so. Therefore, if we have a handler that
can handle the default type, we can allow SUBSCRIBEs for the handler's event
package that have no Accept headers.

(closes issue ASTERISK-22067)
reported by Mark Michelson

Review: https://reviewboard.asterisk.org/r/2774


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397441 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-22 17:42:37 +00:00
Joshua Colp 5b3441ae55 Fix crash in res_pjsip_outbound_registration when the remote server can not be resolved.
This crash was caused by decrementing the reference count of a newly created message when
it should not be. This change fixes that but also fixes all other cases where this was
incorrectly done.

(closes issue ASTERISK-22188)
Reported by: Kinsey Moore


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396319 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-06 12:39:27 +00:00
Mark Michelson 735b30ad71 The large GULP->PJSIP renaming effort.
The general gist is to have a clear boundary between old SIP stuff
and new SIP stuff by having the word "SIP" for old stuff and "PJSIP"
for new stuff. Here's a brief rundown of the changes:

* The word "Gulp" in dialstrings, functions, and CLI commands is now
  "PJSIP"
* chan_gulp.c is now chan_pjsip.c
* Function names in chan_gulp.c that were "gulp_*" are now "chan_pjsip_*"
* All files that were "res_sip*" are now "res_pjsip*"
* The "res_sip" directory is now "res_pjsip"
* Files in the "res_pjsip" directory that began with "sip_*" are now "pjsip_*"
* The configuration file is now "pjsip.conf" instead of "res_sip.conf"
* The module info for all PJSIP-related files now uses "PJSIP" instead of "SIP"
* CLI and AMI commands created by Asterisk's PJSIP modules now have "pjsip" as
the starting word instead of "sip"



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@395764 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-07-30 18:14:50 +00:00