cdp Module

Jason Penton

Smile Communications

Edited by

Richard Good

Smile Communications

Table of Contents

1. Admin Guide
1. Overview
2. Dependencies
2.1. Kamailio Modules
2.2. External Libraries or Applications
3. Parameters
3.1. hash_size (int)
3.2. timer_interval (int)
4. Functions
4.1.
5. RPC Commands
5.1. ulpcscf.status
6. Statistics
6.1. registered contacts
6.2. impus
6.3. expired contacts
2. Developer Guide
1. Available Functions
1.1. load_cdp(struct cdp_binds *cdpb)
1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode command_code, AAAMsgFlag flags, AAASession *session)
1.3. AAACreateResponse(AAAMessage *request)
1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
1.5. AAAReturnCode AAASendMessage(AAAMessage *message, AAATransactionCallback_f *callback_f, void *callback_param)
1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str *peer_id, AAATransactionCallback_f *callback_f, void *callback_param)
1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
1.9. AAASession* AAACreateSession(void *generic_data)
1.10. AAASession* AAAMakeSession(int app_id,int type,str session_id)
1.11. AAASession* AAAGetSession(str id)
1.12. AAADropSession(AAASession *s)
1.13. AAASessionLock(unsigned int hash)
1.14. AAASessionUnLock(unsigned int hash)
1.15. AAASession* AAACreateClientAuthSession(int is_statefull,AAASessionCallback_f *cb,void *generic_data)
1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int is_statefull,AAASessionCallback_f *cb,void *generic_data)
1.17. AAASession* AAAGetAuthSession(str id)
1.18. AAADropAuthSession(AAASession *s)
1.19. AAATerminateAuthSession(AAASession *s)
1.20. AAATransaction* AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code)
1.21. int AAADropTransaction(AAATransaction *trans)
1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags, AAAVendorId vendorId, char *data, size_t length, AVPDataStatus data_status)
1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP *avp, AAA_AVP *position)
1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)
1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)
1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)
3. Frequently Asked Questions

List of Examples

1.1. Set hash_size parameter
1.2. Set timer_interval parameter

Chapter 1. Admin Guide

1. Overview

This module serves as a storage engine for PCSCF contacts, much like the standard Kamailio module, usrloc, is a storage engine for standard SIP contacts. The concept of a contact in IMS, PCSCF specifically, is very different to that of std. SIP and as a result we have built this new module. Alot of the design has been borrowed from the std. usrloc module. For example. An IMS contact, in PCSCF, needs things like:

  • Diameter Rx session for signalling bearer status. i.e. this is effectively QoS from the network to make sure the signalling link can be 'trusted'

  • IPSEC Security Assocation for secure signalling between UE and PCSCF (first point of contact)

  • IMPU, each contact can have a number of associated public identities (IMPU).

2. Dependencies

2.1. Kamailio Modules

The following modules must be loaded before this module:

  • None.

2.2. External Libraries or Applications

The following libraries or applications must be installed before running Kamailio with this module loaded:

  • None.

3. Parameters

3.1. hash_size (int)

The number of entries of the hash table used by to store the contact records is 2^hash_size. For hash_size=4, the number of entries of the hash table is 16.

Default value is 9.

Example 1.1. Set hash_size parameter

...
modparam("usrloc_pcscf", "hash_size", 10)
...

3.2. timer_interval (int)

Number of seconds between two timer runs. The module uses timer to delete expired contacts.

Default value is 60.

Example 1.2. Set timer_interval parameter

...
modparam("usrloc_pcscf", "timer_interval", 30)
...

4. Functions

There are no exported functions that could be used in scripts.

5. RPC Commands

exported RPC commands.

5.1. ulpcscf.status

Status of pcscf_usrloc, AORs, max slots, etc.

6. Statistics

Exported statistics are listed in the next sections.

6.1. registered contacts

Number of AOR contacts in registered state - cannot be reset.

6.2. impus

Number of IMPUs - cannot be reset.

6.3. expired contacts

Number of expired contacts - can be reset.

Chapter 2. Developer Guide

Table of Contents

1. Available Functions
1.1. load_cdp(struct cdp_binds *cdpb)
1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode command_code, AAAMsgFlag flags, AAASession *session)
1.3. AAACreateResponse(AAAMessage *request)
1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
1.5. AAAReturnCode AAASendMessage(AAAMessage *message, AAATransactionCallback_f *callback_f, void *callback_param)
1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str *peer_id, AAATransactionCallback_f *callback_f, void *callback_param)
1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
1.9. AAASession* AAACreateSession(void *generic_data)
1.10. AAASession* AAAMakeSession(int app_id,int type,str session_id)
1.11. AAASession* AAAGetSession(str id)
1.12. AAADropSession(AAASession *s)
1.13. AAASessionLock(unsigned int hash)
1.14. AAASessionUnLock(unsigned int hash)
1.15. AAASession* AAACreateClientAuthSession(int is_statefull,AAASessionCallback_f *cb,void *generic_data)
1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int is_statefull,AAASessionCallback_f *cb,void *generic_data)
1.17. AAASession* AAAGetAuthSession(str id)
1.18. AAADropAuthSession(AAASession *s)
1.19. AAATerminateAuthSession(AAASession *s)
1.20. AAATransaction* AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code)
1.21. int AAADropTransaction(AAATransaction *trans)
1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags, AAAVendorId vendorId, char *data, size_t length, AVPDataStatus data_status)
1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP *avp, AAA_AVP *position)
1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)
1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)
1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)

1. Available Functions

1.1. load_cdp(struct cdp_binds *cdpb)

Find and load the CDiameterPeer function bindings

Meaning of the parameters is as follows:

  • struct cdp_binds *cdpb - structure holding function pointers

1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode command_code, AAAMsgFlag flags, AAASession *session)

Create a Diameter request

Meaning of the parameters is as follows:

  • AAAApplicationId app_id - structure holding function pointers

  • AAACommandCode command_code - command code for the message

  • AAAMsgFlag flags - flags to be set

  • AAASession *session - session id to be set

1.3. AAACreateResponse(AAAMessage *request)

Create a Diameter response to a give request

Meaning of the parameters is as follows:

  • AAAMessage *request - request that this response is for

1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)

Free up memory used by Diameter message

Meaning of the parameters is as follows:

  • AAAMessage **msg - pointer to the pointer containing the message

1.5. AAAReturnCode AAASendMessage(AAAMessage *message, AAATransactionCallback_f *callback_f, void *callback_param)

Send Diameter message asynchronously

Meaning of the parameters is as follows:

  • AAAMessage *message - request message to be sent

  • AAATransactionCallback_f *callback_f - When the response is received, the callback_f(callback_param,...) is called

  • void *callback_param - generic param for callback

1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str *peer_id, AAATransactionCallback_f *callback_f, void *callback_param)

Send Diameter message to specific peer asynchronously

Meaning of the parameters is as follows:

  • AAAMessage *message - request message to send

  • str *peer_id - FQDN of peer to send to

  • AAATransactionCallback_f *callback_f - When the response is received, the callback_f(callback_param,...) is called

  • void *callback_param - generic param for callback

1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)

Send Diameter message synchronously. This blocks until a response is received or a transactional time-out happens.

Meaning of the parameters is as follows:

  • AAAMessage *message - request message to be sent

1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)

Send Diameter message to specific peer synchronously. This blocks until a response is received or a transactional time-out happens.

Meaning of the parameters is as follows:

  • AAAMessage *message - request message to send

  • str *peer_id - FQDN of peer to send to.

1.9. AAASession* AAACreateSession(void *generic_data)

Create a generic Diameter session

Meaning of the parameters is as follows:

  • void *generic_data - data to be save to session, useful for attaching app specific data to the session

1.10. AAASession* AAAMakeSession(int app_id,int type,str session_id)

Create a Diameter session using already known params

Meaning of the parameters is as follows:

  • int app_id - app id to use

  • int type - type of session

  • str session_id - session ID

1.11. AAASession* AAAGetSession(str id)

Retrieve a Diameter session. Returns with a lock on AAASession->hash - Unlock when done working with result

Meaning of the parameters is as follows:

  • str id - Diameter session ID to search for

1.12. AAADropSession(AAASession *s)

Drop a Diameter session - deallocating all memory

Meaning of the parameters is as follows:

  • AAASession *s - session to drop

1.13. AAASessionLock(unsigned int hash)

Lock a Diameter session (hash table row)

Meaning of the parameters is as follows:

  • unsigned int hash - hash to lock

1.14. AAASessionUnLock(unsigned int hash)

Unlock a Diameter session (hash table row)

Meaning of the parameters is as follows:

  • unsigned int hash - hash to unlock

1.15. AAASession* AAACreateClientAuthSession(int is_statefull,AAASessionCallback_f *cb,void *generic_data)

Creates an Authorisation session for the Client. It generate a new ID and adds to the list of CDP sessions. Returns with a lock on AAASession->hash

Meaning of the parameters is as follows:

  • int is_statefull - is session stateful or not

  • AAASessionCallback_f *cb - callback function on session state change

  • void *generic_data - generic callback data

1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int is_statefull,AAASessionCallback_f *cb,void *generic_data)

Create authorisation session for the Server. Generates a new ID and add to CDP list of sessions. Returns with a lock on AAASession->hash.

Meaning of the parameters is as follows:

  • AAMessage *msg - request message from which to create server session

  • int is_statefull - is session stateful or not

  • AAASessionCallback_f *cb - callback function on session state change

  • void *generic_data - generic callback data

1.17. AAASession* AAAGetAuthSession(str id)

Look for an authorisation session. Returns with lock on AAASession->hash

Meaning of the parameters is as follows:

  • str id - ID of Auth session to search for

1.18. AAADropAuthSession(AAASession *s)

Deallocates the memory taken by a Authorisation session

Meaning of the parameters is as follows:

  • AAASession *s - Session to drop and deallocate memory for

1.19. AAATerminateAuthSession(AAASession *s)

Sends a service terminated event to the session

Meaning of the parameters is as follows:

  • AAASession *s - authhorisation session to terminate

1.20. AAATransaction* AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code)

Create a AAATransaction for the given request

Meaning of the parameters is as follows:

  • AAAApplicationId app_id - ID of the request's application

  • AAACommandCode cmd_code - request's code

1.21. int AAADropTransaction(AAATransaction *trans)

Deallocates the memory taken by AAA transaction

Meaning of the parameters is as follows:

  • AAATransaction *trans - transaction to free

1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags, AAAVendorId vendorId, char *data, size_t length, AVPDataStatus data_status)

Create new AVP and return pointer to it

Meaning of the parameters is as follows:

  • AAA_AVPCode code - code for new AVP

  • AAA_AVPFlag flags - flags to set

  • AAAVendorId vendorId - vendor ID for AVP

  • char *data - generic payload data

  • size_t length - length of payload data

  • AVPDataStatus data_status - what to do with the payload, duplicate, free with message, etc

1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP *avp, AAA_AVP *position)

Find and load the CDiameterPeer function bindings

Meaning of the parameters is as follows:

  • AAAMessage *msg - the message to add to

  • AAA_AVP *avp - the AVP to add

  • AAA_AVP *position - AVP to add after. if NULL, we add at beginning

1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)

Find and load the CDiameterPeer function bindings

Meaning of the parameters is as follows:

  • AAAMessage *msg - the message to search in

  • AAA_AVP *startAvp - at which AVP to start the search. usefull for looking for more of the same name

  • AAA_AVPCode avpCode - AVP code to match

  • AAAVendorId vendorId - AVP vendor ID to match

  • AAASearchType searchType - look forward or backward

1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)

Find and load the CDiameterPeer function bindings

Meaning of the parameters is as follows:

  • AAA_AVP *avp - reference AVP

1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)

Find and load the CDiameterPeer function bindings

Meaning of the parameters is as follows:

  • AAA_AVP **avp - pointer memory to be freed

1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)

Groups a list of AVPS into a data buffer

Meaning of the parameters is as follows:

  • AAA_AVP_LIST avps - list of AVPS to group

1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)

Ungroup a data buffer into a list of AVPs

Meaning of the parameters is as follows:

  • str buf - payload to ungroup list from

1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList, AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)

Find an AVP in an AVP list

Meaning of the parameters is as follows:

  • AAA_AVP_LIST avpList - AVP list to search

  • AAA_AVP *startAvp - where to start the search

  • AAA_AVPCode avpCode - AVP code to match

  • AAAVendorId vendorId - vendor ID to match

  • AAASearchType searchType - forwards or backwards

1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)

Free AVP list and all its members

Meaning of the parameters is as follows:

  • AAA_AVP_LIST *avpList - list to be freed

1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)

add a #AAARequestHandler_f callback to request being received

Meaning of the parameters is as follows:

  • AAARequestHandler_f *f - callback function to be called on incoming requests

  • void *param - generic data passed to callback function

1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)

add a #AAAResponseHandler_f callback to responses being received

Meaning of the parameters is as follows:

  • AAAResponseHandler_f *f - callback function to be called on incoming responses

  • void *param - generic data to be bassed to callback function

Chapter 3. Frequently Asked Questions

3.1. Where can I find more about Kamailio?
3.2. Where can I post a question about this module?
3.3. How can I report a bug?

3.1.

Where can I find more about Kamailio?

Take a look at http://www.kamailio.org/.

3.2.

Where can I post a question about this module?

First at all check if your question was already answered on one of our mailing lists:

E-mails regarding any stable Kamailio release should be sent to and e-mails regarding development versions should be sent to .

If you want to keep the mail private, send it to .

3.3.

How can I report a bug?

Please follow the guidelines provided at: http://sip-router.org/tracker.