Debian Codegraph @

src/modules/cdp/README

raw
1 The CDP Module
2
3 Dragos Vingarzan
4
5 Fraunhofer
6
7 Edited by
8
9 Jason Penton
10
11 Richard Good
12
13 Carsten Bock
14
15 ng-voice GmbH
16
17 Copyright © 2006 FhG Fokus
18
19 Copyright © 2012 Smile Communications
20
21 Copyright © 2017 ng-voice GmbH
22 __________________________________________________________________
23
24 Table of Contents
25
26 1. Admin Guide
27
28 1. Overview
29 2. How it works
30 3. Dependencies
31
32 3.1. Kamailio Modules
33 3.2. External Libraries or Applications
34
35 4. Parameters
36
37 4.1. config_file (string)
38 4.2. latency_threshold (int)
39 4.3. workerq_latency_threshold (int)
40 4.4. workerq_length_threshold_percentage (int)
41 4.5. debug_heavy (int)
42 4.6. enable_tls (int)
43 4.7. tls_method (string)
44 4.8. private_key (string)
45 4.9. certificate (string)
46 4.10. ca_list (string)
47
48 5. Functions
49
50 5.1. cdp_check_peer(fqdn)
51 5.2. cdp_has_app([vendorid, ]application)
52
53 6. RPC Commands
54
55 6.1. States
56 6.2. cdp.disable_peer
57 6.3. cdp.enable_peer
58 6.4. cdp.list_peers
59
60 7. Configuration Examples
61
62 7.1. DiameterPeer.xml example
63
64 2. Developer Guide
65
66 1. Available Functions
67
68 1.1. load_cdp(struct cdp_binds *cdpb)
69 1.2. AAACreateRequest(AAAApplicationId app_id,
70 AAACommandCode command_code, AAAMsgFlag flags,
71 AAASession *session)
72
73 1.3. AAACreateResponse(AAAMessage *request)
74 1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
75 1.5. AAAReturnCode AAASendMessage(AAAMessage *message,
76 AAATransactionCallback_f *callback_f, void
77 *callback_param)
78
79 1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message,
80 str *peer_id, AAATransactionCallback_f *callback_f,
81 void *callback_param)
82
83 1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
84 1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage
85 *message, str *peer_id)
86
87 1.9. AAASession* AAACreateSession(void *generic_data)
88 1.10. AAASession* AAAMakeSession(int app_id,int type,str
89 session_id)
90
91 1.11. AAASession* AAAGetSession(str id)
92 1.12. AAADropSession(AAASession *s)
93 1.13. AAASessionLock(unsigned int hash)
94 1.14. AAASessionUnLock(unsigned int hash)
95 1.15. AAASession* AAACreateClientAuthSession(int
96 is_statefull,AAASessionCallback_f *cb,void
97 *generic_data)
98
99 1.16. AAASession* AAACreateServerAuthSession(AAMessage
100 *msg,int is_statefull,AAASessionCallback_f *cb,void
101 *generic_data)
102
103 1.17. AAASession* AAAGetAuthSession(str id)
104 1.18. AAADropAuthSession(AAASession *s)
105 1.19. AAATerminateAuthSession(AAASession *s)
106 1.20. AAATransaction* AAACreateTransaction(AAAApplicationId
107 app_id,AAACommandCode cmd_code)
108
109 1.21. int AAADropTransaction(AAATransaction *trans)
110 1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag
111 flags, AAAVendorId vendorId, char *data, size_t
112 length, AVPDataStatus data_status)
113
114 1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg,
115 AAA_AVP *avp, AAA_AVP *position)
116
117 1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP
118 *startAvp, AAA_AVPCode avpCode, AAAVendorId
119 vendorId, AAASearchType searchType)
120
121 1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
122 1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
123 1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
124 1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
125 1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList,
126 AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId
127 vendorId, AAASearchType searchType)
128
129 1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
130 1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void
131 *param)
132
133 1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void
134 *param)
135
136 3. Frequently Asked Questions
137
138 List of Examples
139
140 1.1. Set config_file parameter
141 1.2. Set latency_threshold parameter
142 1.3. Set workerq_latency_threshold parameter
143 1.4. Set workerq_length_threshold_percentage parameter
144 1.5. Set debug_heavy parameter
145 1.6. Set enable_tls parameter
146 1.7. Set tls_method parameter
147 1.8. Set private_key parameter
148 1.9. Set certificate parameter
149 1.10. Set ca_list parameter
150 1.11. cdp_check_peer usage
151 1.12. cdp_has_app usage
152 1.13. cdp_has_app usage
153 1.14. DiameterPeer.xml example
154
155 Chapter 1. Admin Guide
156
157 Table of Contents
158
159 1. Overview
160 2. How it works
161 3. Dependencies
162
163 3.1. Kamailio Modules
164 3.2. External Libraries or Applications
165
166 4. Parameters
167
168 4.1. config_file (string)
169 4.2. latency_threshold (int)
170 4.3. workerq_latency_threshold (int)
171 4.4. workerq_length_threshold_percentage (int)
172 4.5. debug_heavy (int)
173 4.6. enable_tls (int)
174 4.7. tls_method (string)
175 4.8. private_key (string)
176 4.9. certificate (string)
177 4.10. ca_list (string)
178
179 5. Functions
180
181 5.1. cdp_check_peer(fqdn)
182 5.2. cdp_has_app([vendorid, ]application)
183
184 6. RPC Commands
185
186 6.1. States
187 6.2. cdp.disable_peer
188 6.3. cdp.enable_peer
189 6.4. cdp.list_peers
190
191 7. Configuration Examples
192
193 7.1. DiameterPeer.xml example
194
195 1. Overview
196
197 CDP (C Diameter Peer) allows Diameter communication to and from
198 Kamailio. Most of the code is inherited from DISC
199 http://developer.berlios.de/projects/disc/ and OpenIMS and modified for
200 use within Kamailio. A few improvements and new functionality has been
201 added along the way, for example, threshold reporting on Diameter calls
202 that are serviced above a certain threshold.
203
204 2. How it works
205
206 CDP forks the following processes:
207 * 1 x Timer
208 * 1 x Acceptor
209 * k x Workers (k configurable through configuration)
210 * i x Receivers (one for each peer plus one for unknown peers)
211
212 CDP is really only an API and offers all of its methods to other
213 modules. No commands are made available to the main Kamailio
214 configuration file. The exported API can be seen in mod.c. The Full
215 Diameter API is in diameter.h and diameter_api.h. IMS-specific
216 constants can be found in diameter_ims.h. The protocol coding is
217 implemented in diameter_avp.c and diameter_msg.c. The diameter state
218 machine is implemented in peerstatemachine.c - there is one of these
219 for each peer which maintains all protocol/application state for each
220 peer. peermanager.c is responsible for peer administration. Diameter
221 transactions are implemented in transaction.c.
222
223 There are 2 configuration areas for CDP. Firstly it must be loaded and
224 configured in the kamailio.cfg file (this is the normal task associated
225 with Kamailio modules). Then, an XML file is required to configure
226 various Diameter parameters and all related peers and the associated
227 routes.
228
229 3. Dependencies
230
231 3.1. Kamailio Modules
232 3.2. External Libraries or Applications
233
234 3.1. Kamailio Modules
235
236 The following modules must be loaded before this module:
237 * None.
238
239 3.2. External Libraries or Applications
240
241 The following libraries or applications must be installed before
242 running Kamailio with this module loaded:
243 * libxml,
244 * openssl.
245
246 4. Parameters
247
248 4.1. config_file (string)
249 4.2. latency_threshold (int)
250 4.3. workerq_latency_threshold (int)
251 4.4. workerq_length_threshold_percentage (int)
252 4.5. debug_heavy (int)
253 4.6. enable_tls (int)
254 4.7. tls_method (string)
255 4.8. private_key (string)
256 4.9. certificate (string)
257 4.10. ca_list (string)
258
259 4.1. config_file (string)
260
261 This is the location of the XML configuration file.
262
263 Default value is “DiameterPeer.xml”.
264
265 Example 1.1. Set config_file parameter
266 ...
267 modparam("cdp", "config_file", "/etc/kamailio/diametercfg.xml")
268 ...
269
270 4.2. latency_threshold (int)
271
272 The time in ms above which a log error is written to log file for long
273 CDP transactions.
274
275 Default value is “500”.
276
277 Example 1.2. Set latency_threshold parameter
278 ...
279 modparam("cdp", "latency_threshold", 1000)
280 ...
281
282 4.3. workerq_latency_threshold (int)
283
284 The time in ms above which a log error is written to log file for
285 putting tasks into task queue.
286
287 Default value is “100”.
288
289 Example 1.3. Set workerq_latency_threshold parameter
290 ...
291 modparam("cdp", "workerq_latency_threshold", 250)
292 ...
293
294 4.4. workerq_length_threshold_percentage (int)
295
296 The threshold of the length of the worker queue as a percentage of the
297 maximum queue size - when exceeded a warning is written to the log
298 file. 0 means disabled
299
300 Default value is “0”.
301
302 Example 1.4. Set workerq_length_threshold_percentage parameter
303 ...
304 modparam("cdp", "workerq_length_threshold_percentage", 25)
305 ...
306
307 4.5. debug_heavy (int)
308
309 Flag to enable a more verbose log, which tells you more details about
310 peers. This is disabled by default because it brings to a log too much
311 verbose in DBG mode Can be enabled upon needs
312
313 Default value is “0”.
314
315 Example 1.5. Set debug_heavy parameter
316 ...
317 modparam("cdp", "debug_heavy", 1)
318 ...
319
320 4.6. enable_tls (int)
321
322 Flag to enable TLS for communication with all the peers.
323
324 Default value is “0”.
325
326 Example 1.6. Set enable_tls parameter
327 ...
328 modparam("cdp", "enable_tls", 1)
329 ...
330
331 4.7. tls_method (string)
332
333 Sets the TLS protocol method. Possible values are:
334 * TLSv1.3+ - TLSv1.3 or newer connections are accepted (available
335 starting with openssl/libssl v1.1.1)
336 * TLSv1.3 - only TLSv1.3 connections are accepted (available starting
337 with openssl/libssl v1.1.1)
338 * TLSv1.2+ - TLSv1.2 or newer (TLSv1.3, ...) connections are accepted
339 (available starting with openssl/libssl v1.1.1)
340 * TLSv1.2 - only TLSv1.2 connections are accepted (available starting
341 with openssl/libssl v1.0.1e)
342 * TLSv1.1+ - TLSv1.1 or newer (TLSv1.2, ...) connections are accepted
343 (available starting with openssl/libssl v1.0.1)
344 * TLSv1.1 - only TLSv1.1 connections are accepted (available starting
345 with openssl/libssl v1.0.1)
346 * TLSv1+ - TLSv1.0 or newer (TLSv1.1, TLSv1.2, ...) connections are
347 accepted.
348 * TLSv1 - only TLSv1 (TLSv1.0) connections are accepted. This is the
349 default value.
350
351 Default value is “TLSv1.2”.
352
353 Example 1.7. Set tls_method parameter
354 ...
355 modparam("tls", "tls_method", "TLSv1")
356 ...
357
358 4.8. private_key (string)
359
360 Sets the private key file name.
361
362 Example 1.8. Set private_key parameter
363 ...
364 modparam("cdp", "private_key", "/usr/local/etc/kamailio/my_pkey.pem")
365 ...
366
367 4.9. certificate (string)
368
369 Sets the certificate file name. Must be in PEM format.
370
371 Example 1.9. Set certificate parameter
372 ...
373 modparam("cdp", "certificate", "/usr/local/etc/kamailio/my_certificate.pem")
374 ...
375
376 4.10. ca_list (string)
377
378 Sets the CA list file name. This file contains a list of all the
379 trusted CAs certificates used when connecting to other SIP
380 implementations. If a signature in a certificate chain belongs to one
381 of the listed CAs, the verification of that certificate will succeed.
382 If not set, the PCRF sent certificate is not checked.
383
384 The parameter must contain an absolute path. Only PEM files are
385 accepted.
386
387 By default this parameter is not set.
388
389 An easy way to create the CA list is to append each trusted trusted CA
390 certificate in the PEM format to one file.
391
392 Example 1.10. Set ca_list parameter
393 ...
394 modparam("cdp", "ca_list", "/usr/local/etc/kamailio/ca_list.pem")
395 ...
396
397 5. Functions
398
399 5.1. cdp_check_peer(fqdn)
400 5.2. cdp_has_app([vendorid, ]application)
401
402 5.1. cdp_check_peer(fqdn)
403
404 The method checks, if a specific peer is connected and ready.
405
406 Meaning of the parameter is as follows:
407 * fqdn - the Fully qualified domain name of the peer, that should be
408 checked. The parameter may contain pseudovariables.
409
410 Example 1.11. cdp_check_peer usage
411 ...
412 if(!cdp_check_peer("hss.mnc001.mcc001.3gppnetwork.org")) {
413 send_reply("503", "HSS not ready");
414 exit;
415 }
416 ...
417
418 5.2. cdp_has_app([vendorid, ]application)
419
420 The method checks, if any peer with this specific application has
421 connected.
422
423 Meaning of the parameters are as follows:
424 * vendorid - The Vendor ID of the App
425 application - The Application ID
426
427 Example 1.12. cdp_has_app usage
428 ...
429 if(!cdp_has_app("10415", "4")) {
430 send_reply("503", "Charging Server not ready");
431 exit;
432 }
433 ...
434
435 Example 1.13. cdp_has_app usage
436 ...
437 if(!cdp_has_app("16777216")) {
438 send_reply("503", "Cx/Dx Interface not ready");
439 exit;
440 }
441 ...
442
443 6. RPC Commands
444
445 6.1. States
446 6.2. cdp.disable_peer
447 6.3. cdp.enable_peer
448 6.4. cdp.list_peers
449
450 6.1. States
451
452 * Closed (0) - Not connected
453 * Wait_Conn_Ack (1) - Connecting - waiting for Ack
454 * Wait_I_CEA (2) - Connecting - waiting for Capabilities Exchange
455 Answer
456 * Wait_Conn_Ack_Elect (3) - Connecting - Acknowledged and going for
457 Election
458 * Wait_Returns (4) - Connecting - done
459 * R_Open (5) - Connected as receiver
460 * I_Open (6) - Connected as initiator
461 * Closing (7) - Closing the connection
462
463 Exported RPC commands.
464
465 6.2. cdp.disable_peer
466
467 instantly disable a particular diameter peer.
468
469 6.3. cdp.enable_peer
470
471 enable/re-enable a diameter peer
472
473 6.4. cdp.list_peers
474
475 list all configured diameter peers
476
477 State details can be found in the list above (Section 6.1, “States”)
478
479 7. Configuration Examples
480
481 7.1. DiameterPeer.xml example
482
483 7.1. DiameterPeer.xml example
484
485 This is an example CDP configuration file. The location of this file is
486 configured as a CDP parameter (config_file) - See section 4.1 Above
487
488 Example 1.14. DiameterPeer.xml example
489 <?xml version="1.0" encoding="UTF-8"?>
490 <!--
491
492 DiameterPeer Parameters
493 - FQDN - FQDN of this peer, as it should appear in the Origin-Host AVP
494 - Realm - Realm of this peer, as it should appear in the Origin-Realm AVP
495 - Vendor_Id - Default Vendor-Id to appear in the Capabilities Exchange
496 - Product_Name - Product Name to appear in the Capabilities Exchange
497 - AcceptUnknownPeers - Whether to accept (1) or deny (0) connections from peer
498 s with FQDN
499 not configured below
500 - DropUnknownOnDisconnect - Whether to drop (1) or keep (0) and retry connecti
501 ons (until restart)
502 unknown peers in the list of peers after a disconnection.
503 - Tc - Value for the RFC3588 Tc timer - default 30 seconds
504 - Workers - Number of incoming messages processing workers forked processes.
505 - Queue - Length of queue of tasks for the workers:
506 - too small and the incoming messages will be blocked too often;
507 - too large and the senders of incoming messages will have a longer feedbac
508 k loop to notice that
509 this Diameter peer is overloaded in processing incoming requests;
510 - a good choice is to have it about 2 times the number of workers. This wil
511 l mean that each worker
512 will have about 2 tasks in the queue to process before new incoming message
513 s will start to block.
514 - ConnectTimeout - time in seconds to wait for an outbound TCP connection to b
515 e established.
516 - TransactionTimeout - time in seconds after which the transaction timeout cal
517 lback will be fired,
518 when using transactional processing.
519 - SessionsHashSize - size of the hash-table to use for the Diameter sessions.
520 When searching for a
521 session, the time required for this operation will be that of sequential sea
522 rching in a list of
523 NumberOfActiveSessions/SessionsHashSize. So higher the better, yet each hash
524 slot will consume an
525 extra 2xsizeof(void*) bytes (typically 8 or 16 bytes extra).
526 - DefaultAuthSessionTimeout - default value to use when there is no Authorizat
527 ion Session Timeout
528 AVP present.
529 - MaxAuthSessionTimeout - maximum Authorization Session Timeout as a cut-out m
530 easure meant to
531 enforce session refreshes.
532
533 -->
534 <DiameterPeer
535 FQDN="pcscf.ims.smilecoms.com"
536 Realm="ims.smilecoms.com"
537 Vendor_Id="10415"
538 Product_Name="CDiameterPeer"
539 AcceptUnknownPeers="0"
540 DropUnknownOnDisconnect="1"
541 Tc="30"
542 Workers="4"
543 QueueLength="32"
544 ConnectTimeout="5"
545 TransactionTimeout="5"
546 SessionsHashSize="128"
547 DefaultAuthSessionTimeout="60"
548 MaxAuthSessionTimeout="300"
549 >
550
551 <!--
552 Definition of peers to connect to and accept connections from. F
553 or each peer found in here
554 a dedicated receiver process will be forked. All other unknown p
555 eers will share a single
556 receiver. NB: You must have a peer definition for each peer list
557 ed in the realm routing section
558 -->
559 <Peer FQDN="pcrf1.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
560 8"/>
561 <Peer FQDN="pcrf2.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
562 8"/>
563 <Peer FQDN="pcrf3.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
564 8"/>
565 <Peer FQDN="pcrf4.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
566 8"/>
567 <Peer FQDN="pcrf5.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
568 8"/>
569 <Peer FQDN="pcrf6.ims.smilecoms.com" Realm="ims.smilecoms.com" port="386
570 8"/>
571 <Peer FQDN="pcrf7.ims.smilecoms.com" Realm="ims.smilecoms.com" src_addr=
572 "192.168.2.1" port="3868" vrf="blue"/>
573
574 <!--
575 Definition of incoming connection acceptors. If no bind is speci
576 fied, the acceptor will bind
577 on all available interfaces.
578 -->
579 <Acceptor port="3868" />
580 <Acceptor port="3869" bind="127.0.0.1" />
581 <Acceptor port="3870" bind="192.168.1.1" />
582 <Acceptor port="3870" bind="192.168.2.1" vrf="blue" />
583
584 <!--
585 Definition of Auth (authorization) and Acct (accounting) support
586 ed applications. This
587 information is sent as part of the Capabilities Exchange procedu
588 res on connecting to
589 peers. If no common application is found, the peers will disconn
590 ect. Messages will only
591 be sent to a peer if that peer actually has declared support for
592 the application id of
593 the message.
594 -->
595 <Acct id="16777216" vendor="10415" />
596 <Acct id="16777216" vendor="0" />
597 <Auth id="16777216" vendor="10415"/>
598 <Auth id="16777216" vendor="0" />
599
600 <!--
601 Supported Vendor IDs - list of values which will be sent in the
602 CER/CEA in the
603 Supported-Vendor-ID AVPs
604 -->
605 <SupportedVendor vendor="10415" />
606
607 <!--
608 Realm routing definition.
609 Each Realm can have a different table of peers to route towards.
610 In case the Destination
611 Realm AVP contains a Realm not defined here, the DefaultRoute en
612 tries will be used.
613
614 Note: In case a message already contains a Destination-Host AVP,
615 Realm Routing will not be
616 applied.
617 Note: Routing will only happen towards connected and application
618 id supporting peers.
619
620 The metric is used to order the list of preferred peers, while l
621 ooking for a connected and
622 application id supporting peer. In the end, of course, just one
623 peer will be selected.
624 -->
625 <Realm name="ims.smilecoms.com">
626 <Route FQDN="pcrf1.ims.smilecoms.com" metric="3"/>
627 <Route FQDN="pcrf2.ims.smilecoms.com" metric="5"/>
628 </Realm>
629
630 <Realm name="temp.ims.smilecoms.com">
631 <Route FQDN="pcrf3.ims.smilecoms.com" metric="7"/>
632 <Route FQDN="pcrf4.ims.smilecoms.com" metric="11"/>
633 </Realm>
634 <DefaultRoute FQDN="pcrf5.ims.smilecoms.com" metric="15"/>
635 <DefaultRoute FQDN="pcrf6.ims.smilecoms.com" metric="13"/>
636
637
638 </DiameterPeer>
639
640 Chapter 2. Developer Guide
641
642 Table of Contents
643
644 1. Available Functions
645
646 1.1. load_cdp(struct cdp_binds *cdpb)
647 1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode
648 command_code, AAAMsgFlag flags, AAASession *session)
649
650 1.3. AAACreateResponse(AAAMessage *request)
651 1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
652 1.5. AAAReturnCode AAASendMessage(AAAMessage *message,
653 AAATransactionCallback_f *callback_f, void
654 *callback_param)
655
656 1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str
657 *peer_id, AAATransactionCallback_f *callback_f, void
658 *callback_param)
659
660 1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
661 1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str
662 *peer_id)
663
664 1.9. AAASession* AAACreateSession(void *generic_data)
665 1.10. AAASession* AAAMakeSession(int app_id,int type,str
666 session_id)
667
668 1.11. AAASession* AAAGetSession(str id)
669 1.12. AAADropSession(AAASession *s)
670 1.13. AAASessionLock(unsigned int hash)
671 1.14. AAASessionUnLock(unsigned int hash)
672 1.15. AAASession* AAACreateClientAuthSession(int
673 is_statefull,AAASessionCallback_f *cb,void *generic_data)
674
675 1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int
676 is_statefull,AAASessionCallback_f *cb,void *generic_data)
677
678 1.17. AAASession* AAAGetAuthSession(str id)
679 1.18. AAADropAuthSession(AAASession *s)
680 1.19. AAATerminateAuthSession(AAASession *s)
681 1.20. AAATransaction* AAACreateTransaction(AAAApplicationId
682 app_id,AAACommandCode cmd_code)
683
684 1.21. int AAADropTransaction(AAATransaction *trans)
685 1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags,
686 AAAVendorId vendorId, char *data, size_t length,
687 AVPDataStatus data_status)
688
689 1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP
690 *avp, AAA_AVP *position)
691
692 1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP
693 *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId,
694 AAASearchType searchType)
695
696 1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
697 1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
698 1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
699 1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
700 1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList,
701 AAA_AVP *startAvp, AAA_AVPCode avpCode, AAAVendorId
702 vendorId, AAASearchType searchType)
703
704 1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
705 1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
706 1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void
707 *param)
708
709 1. Available Functions
710
711 1.1. load_cdp(struct cdp_binds *cdpb)
712 1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode
713 command_code, AAAMsgFlag flags, AAASession *session)
714
715 1.3. AAACreateResponse(AAAMessage *request)
716 1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
717 1.5. AAAReturnCode AAASendMessage(AAAMessage *message,
718 AAATransactionCallback_f *callback_f, void *callback_param)
719
720 1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str
721 *peer_id, AAATransactionCallback_f *callback_f, void
722 *callback_param)
723
724 1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
725 1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str
726 *peer_id)
727
728 1.9. AAASession* AAACreateSession(void *generic_data)
729 1.10. AAASession* AAAMakeSession(int app_id,int type,str session_id)
730 1.11. AAASession* AAAGetSession(str id)
731 1.12. AAADropSession(AAASession *s)
732 1.13. AAASessionLock(unsigned int hash)
733 1.14. AAASessionUnLock(unsigned int hash)
734 1.15. AAASession* AAACreateClientAuthSession(int
735 is_statefull,AAASessionCallback_f *cb,void *generic_data)
736
737 1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int
738 is_statefull,AAASessionCallback_f *cb,void *generic_data)
739
740 1.17. AAASession* AAAGetAuthSession(str id)
741 1.18. AAADropAuthSession(AAASession *s)
742 1.19. AAATerminateAuthSession(AAASession *s)
743 1.20. AAATransaction* AAACreateTransaction(AAAApplicationId
744 app_id,AAACommandCode cmd_code)
745
746 1.21. int AAADropTransaction(AAATransaction *trans)
747 1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags,
748 AAAVendorId vendorId, char *data, size_t length, AVPDataStatus
749 data_status)
750
751 1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP *avp,
752 AAA_AVP *position)
753
754 1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP *startAvp,
755 AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType
756 searchType)
757
758 1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
759 1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
760 1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
761 1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
762 1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList, AAA_AVP
763 *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId,
764 AAASearchType searchType)
765
766 1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
767 1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
768 1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)
769
770 1.1. load_cdp(struct cdp_binds *cdpb)
771
772 Find and load the CDiameterPeer function bindings
773
774 Meaning of the parameters is as follows:
775 * struct cdp_binds *cdpb - structure holding function pointers
776
777 1.2. AAACreateRequest(AAAApplicationId app_id, AAACommandCode command_code,
778 AAAMsgFlag flags, AAASession *session)
779
780 Create a Diameter request
781
782 Meaning of the parameters is as follows:
783 * AAAApplicationId app_id - structure holding function pointers
784 * AAACommandCode command_code - command code for the message
785 * AAAMsgFlag flags - flags to be set
786 * AAASession *session - session id to be set
787
788 1.3. AAACreateResponse(AAAMessage *request)
789
790 Create a Diameter response to a give request
791
792 Meaning of the parameters is as follows:
793 * AAAMessage *request - request that this response is for
794
795 1.4. AAAReturnCode AAAFreeMessage(AAAMessage **msg)
796
797 Free up memory used by Diameter message
798
799 Meaning of the parameters is as follows:
800 * AAAMessage **msg - pointer to the pointer containing the message
801
802 1.5. AAAReturnCode AAASendMessage(AAAMessage *message,
803 AAATransactionCallback_f *callback_f, void *callback_param)
804
805 Send Diameter message asynchronously
806
807 Meaning of the parameters is as follows:
808 * AAAMessage *message - request message to be sent
809 * AAATransactionCallback_f *callback_f - When the response is
810 received, the callback_f(callback_param,...) is called
811 * void *callback_param - generic param for callback
812
813 1.6. AAAReturnCode AAASendMessageToPeer(AAAMessage *message, str *peer_id,
814 AAATransactionCallback_f *callback_f, void *callback_param)
815
816 Send Diameter message to specific peer asynchronously
817
818 Meaning of the parameters is as follows:
819 * AAAMessage *message - request message to send
820 * str *peer_id - FQDN of peer to send to
821 * AAATransactionCallback_f *callback_f - When the response is
822 received, the callback_f(callback_param,...) is called
823 * void *callback_param - generic param for callback
824
825 1.7. AAAMessage* AAASendRecvMessage(AAAMessage *message)
826
827 Send Diameter message synchronously. This blocks until a response is
828 received or a transactional time-out happens.
829
830 Meaning of the parameters is as follows:
831 * AAAMessage *message - request message to be sent
832
833 1.8. AAAMessage* AAASendRecvMessageToPeer(AAAMessage *message, str *peer_id)
834
835 Send Diameter message to specific peer synchronously. This blocks until
836 a response is received or a transactional time-out happens.
837
838 Meaning of the parameters is as follows:
839 * AAAMessage *message - request message to send
840 * str *peer_id - FQDN of peer to send to.
841
842 1.9. AAASession* AAACreateSession(void *generic_data)
843
844 Create a generic Diameter session
845
846 Meaning of the parameters is as follows:
847 * void *generic_data - data to be save to session, useful for
848 attaching app specific data to the session
849
850 1.10. AAASession* AAAMakeSession(int app_id,int type,str session_id)
851
852 Create a Diameter session using already known params
853
854 Meaning of the parameters is as follows:
855 * int app_id - app id to use
856 * int type - type of session
857 * str session_id - session ID
858
859 1.11. AAASession* AAAGetSession(str id)
860
861 Retrieve a Diameter session. Returns with a lock on AAASession->hash -
862 Unlock when done working with result
863
864 Meaning of the parameters is as follows:
865 * str id - Diameter session ID to search for
866
867 1.12. AAADropSession(AAASession *s)
868
869 Drop a Diameter session - deallocating all memory
870
871 Meaning of the parameters is as follows:
872 * AAASession *s - session to drop
873
874 1.13. AAASessionLock(unsigned int hash)
875
876 Lock a Diameter session (hash table row)
877
878 Meaning of the parameters is as follows:
879 * unsigned int hash - hash to lock
880
881 1.14. AAASessionUnLock(unsigned int hash)
882
883 Unlock a Diameter session (hash table row)
884
885 Meaning of the parameters is as follows:
886 * unsigned int hash - hash to unlock
887
888 1.15. AAASession* AAACreateClientAuthSession(int
889 is_statefull,AAASessionCallback_f *cb,void *generic_data)
890
891 Creates an Authorisation session for the Client. It generate a new ID
892 and adds to the list of CDP sessions. Returns with a lock on
893 AAASession->hash
894
895 Meaning of the parameters is as follows:
896 * int is_statefull - is session stateful or not
897 * AAASessionCallback_f *cb - callback function on session state
898 change
899 * void *generic_data - generic callback data
900
901 1.16. AAASession* AAACreateServerAuthSession(AAMessage *msg,int
902 is_statefull,AAASessionCallback_f *cb,void *generic_data)
903
904 Create authorisation session for the Server. Generates a new ID and add
905 to CDP list of sessions. Returns with a lock on AAASession->hash.
906
907 Meaning of the parameters is as follows:
908 * AAMessage *msg - request message from which to create server
909 session
910 * int is_statefull - is session stateful or not
911 * AAASessionCallback_f *cb - callback function on session state
912 change
913 * void *generic_data - generic callback data
914
915 1.17. AAASession* AAAGetAuthSession(str id)
916
917 Look for an authorisation session. Returns with lock on
918 AAASession->hash
919
920 Meaning of the parameters is as follows:
921 * str id - ID of Auth session to search for
922
923 1.18. AAADropAuthSession(AAASession *s)
924
925 Deallocates the memory taken by an Authorisation session
926
927 Meaning of the parameters is as follows:
928 * AAASession *s - Session to drop and deallocate memory for
929
930 1.19. AAATerminateAuthSession(AAASession *s)
931
932 Sends a service terminated event to the session
933
934 Meaning of the parameters is as follows:
935 * AAASession *s - authhorisation session to terminate
936
937 1.20. AAATransaction* AAACreateTransaction(AAAApplicationId
938 app_id,AAACommandCode cmd_code)
939
940 Create an AAATransaction for the given request
941
942 Meaning of the parameters is as follows:
943 * AAAApplicationId app_id - ID of the request's application
944 * AAACommandCode cmd_code - request's code
945
946 1.21. int AAADropTransaction(AAATransaction *trans)
947
948 Deallocates the memory taken by AAA transaction
949
950 Meaning of the parameters is as follows:
951 * AAATransaction *trans - transaction to free
952
953 1.22. AAA_AVP* AAACreateAVP(AAA_AVPCode code, AAA_AVPFlag flags, AAAVendorId
954 vendorId, char *data, size_t length, AVPDataStatus data_status)
955
956 Create new AVP and return pointer to it
957
958 Meaning of the parameters is as follows:
959 * AAA_AVPCode code - code for new AVP
960 * AAA_AVPFlag flags - flags to set
961 * AAAVendorId vendorId - vendor ID for AVP
962 * char *data - generic payload data
963 * size_t length - length of payload data
964 * AVPDataStatus data_status - what to do with the payload, duplicate,
965 free with message, etc
966
967 1.23. AAAReturnCode AAAAddAVPToMessage(AAAMessage *msg, AAA_AVP *avp, AAA_AVP
968 *position)
969
970 Find and load the CDiameterPeer function bindings
971
972 Meaning of the parameters is as follows:
973 * AAAMessage *msg - the message to add to
974 * AAA_AVP *avp - the AVP to add
975 * AAA_AVP *position - AVP to add after. if NULL, we add at beginning
976
977 1.24. AAA_AVP* AAAFindMatchingAVP(AAAMessage *msg, AAA_AVP *startAvp,
978 AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType searchType)
979
980 Find and load the CDiameterPeer function bindings
981
982 Meaning of the parameters is as follows:
983 * AAAMessage *msg - the message to search in
984 * AAA_AVP *startAvp - at which AVP to start the search. Useful for
985 looking for more of the same name
986 * AAA_AVPCode avpCode - AVP code to match
987 * AAAVendorId vendorId - AVP vendor ID to match
988 * AAASearchType searchType - look forward or backward
989
990 1.25. AAA_AVP * AAAGetNextAVP(AAA_AVP *avp)
991
992 Find and load the CDiameterPeer function bindings
993
994 Meaning of the parameters is as follows:
995 * AAA_AVP *avp - reference AVP
996
997 1.26. AAAReturnCode AAAFreeAVP(AAA_AVP **avp)
998
999 Find and load the CDiameterPeer function bindings
1000
1001 Meaning of the parameters is as follows:
1002 * AAA_AVP **avp - pointer memory to be freed
1003
1004 1.27. str AAAGroupAVPS(AAA_AVP_LIST avps)
1005
1006 Groups a list of AVPS into a data buffer
1007
1008 Meaning of the parameters is as follows:
1009 * AAA_AVP_LIST avps - list of AVPS to group
1010
1011 1.28. AAA_AVP_LIST AAAUnGroupAVPS(str buf)
1012
1013 Ungroup a data buffer into a list of AVPs
1014
1015 Meaning of the parameters is as follows:
1016 * str buf - payload to ungroup list from
1017
1018 1.29. AAA_AVP* AAAFindMatchingAVPList(AAA_AVP_LIST avpList, AAA_AVP
1019 *startAvp, AAA_AVPCode avpCode, AAAVendorId vendorId, AAASearchType
1020 searchType)
1021
1022 Find an AVP in an AVP list
1023
1024 Meaning of the parameters is as follows:
1025 * AAA_AVP_LIST avpList - AVP list to search
1026 * AAA_AVP *startAvp - where to start the search
1027 * AAA_AVPCode avpCode - AVP code to match
1028 * AAAVendorId vendorId - vendor ID to match
1029 * AAASearchType searchType - forwards or backwards
1030
1031 1.30. AAAFreeAVPList(AAA_AVP_LIST *avpList)
1032
1033 Free AVP list and all its members
1034
1035 Meaning of the parameters is as follows:
1036 * AAA_AVP_LIST *avpList - list to be freed
1037
1038 1.31. int AAAAddRequestHandler(AAARequestHandler_f *f,void *param)
1039
1040 add a #AAARequestHandler_f callback to request being received
1041
1042 Meaning of the parameters is as follows:
1043 * AAARequestHandler_f *f - callback function to be called on incoming
1044 requests
1045 * void *param - generic data passed to callback function
1046
1047 1.32. int AAAAddResponseHandler(AAAResponseHandler_f *f,void *param)
1048
1049 add a #AAAResponseHandler_f callback to responses being received
1050
1051 Meaning of the parameters is as follows:
1052 * AAAResponseHandler_f *f - callback function to be called on
1053 incoming responses
1054 * void *param - generic data to be passed to callback function
1055
1056 Chapter 3. Frequently Asked Questions
1057
1058 3.1. Where can I find more about Kamailio?
1059 3.2. Where can I post a question about this module?
1060 3.3. How can I report a bug?
1061
1062 3.1.
1063
1064 Where can I find more about Kamailio?
1065
1066 Take a look at https://www.kamailio.org/.
1067
1068 3.2.
1069
1070 Where can I post a question about this module?
1071
1072 First at all check if your question was already answered on one of our
1073 mailing lists:
1074 * User Mailing List -
1075 https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.
1076 kamailio.org/
1077 * Developer Mailing List -
1078 https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.ka
1079 mailio.org/
1080
1081 E-mails regarding any stable Kamailio release should be sent to
1082 <[email protected]> and e-mails regarding development
1083 versions should be sent to <[email protected]>.
1084
1085 3.3.
1086
1087 How can I report a bug?
1088
1089 Please follow the guidelines provided at:
1090 https://github.com/kamailio/kamailio/issues.