PJSIP Developer’s Guide
The on_rx_request() and on_rx_response() function pointers are the primary
means for the module to receive SIP messages from endpoint (pjsip_endpt) or
from other modules. The return value of these callbacks is important. If a callback
has returned non-zero (i.e. true condition), it semantically means that the module
has taken care the message; in this case, the endpoint will stop distributing the
message to other modules. Section 2.1.3 Incoming Message Processing by
Modules will describe this in more detail.
The on_tx_request() and on_tx_response() function pointers are called by
transport manager before a message is transmitted. This gives an opportunity for
some types of modules (e.g. sigcomp, message signing) chance to make last
modification to the message. All modules MUST return PJ_SUCCESS (i.e. zero
status), or otherwise the transmission will be cancelled. Section 2.1.4 Outgoing
Message Processing by Modules will describe this in more detail.
The on_tsx_state() function pointer is used to receive notification every time a
transaction state has changed, which can be caused by receipt of message,
transmission of message, timer events, or transport error event. More
information about this callback will be described in next section 2.1.5
“Transaction User and State Callback”.
2.1.2 Module Priorities
Module priority specifies the order of which modules are called first to process the
callback. Module with higher priority (i.e. lower priority number) will have their
on_rx_request() and on_rx_response() called first, and on_tx_request() and
on_tx_response() called last.
The values below are the standard to set module priority.
enum pjsip_module_priority
{
PJSIP_MOD_PRIORITY_TRANSPORT_LAYER = 8, // Transport
PJSIP_MOD_PRIORITY_TSX_LAYER = 16, // Transaction layer.
PJSIP_MOD_PRIORITY_UA_PROXY_LAYER = 32, // UA or proxy layer
PJSIP_MOD_PRIORITY_DIALOG_USAGE = 48, // Invite usage, event subscr. framework.
PJSIP_MOD_PRIORITY_APPLICATION = 64, // Application has lowest priority.
};
Code 4 Module Priorities
Note : remember that lower priority number means higher priority!
The priority PJSIP_MOD_PRIORITY_TRANSPORT_LAYER is the priority used by
transport manager. This priority currently is only used to control message
transmission, i.e. module with lower priority than this (that means higher priority
number!) will have the on_tx_request()/on_tx_response() called before the
message is processed by transport layer (e.g. destination is calculated, message
is printed to contiguous buffer), while module with higher priority than this will
have the callback called after the message has been processed by transport
layer. Please see 2.1.4Outgoing Message Processing by Modules for more
information.
PJSIP_MOD_PRIORITY_TSX_LAYER is the priority used by transaction layer
module. The transaction layer absorbs all incoming messages that belong to a
transaction.
PJSIP_MOD_PRIORITY_UA_PROXY_LAYER is the priority used by UA layer (i.e.
dialog framework) or proxy layer. The UA layer absorbs all incoming messages
that belong to a dialog set (this means forked responses as well).
Page 16