Mercurial > hg > freeDiameter
annotate include/freeDiameter/freeDiameter.h @ 7:e5af94b04946
Added dispatch module and tests
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 04 Sep 2009 18:05:25 +0900 |
parents | bafb831ba688 |
children | 3e143f047f78 |
rev | line source |
---|---|
0 | 1 /********************************************************************************************************* |
2 * Software License Agreement (BSD License) * | |
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * | |
4 * * | |
5 * Copyright (c) 2009, WIDE Project and NICT * | |
6 * All rights reserved. * | |
7 * * | |
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * | |
9 * permitted provided that the following conditions are met: * | |
10 * * | |
11 * * Redistributions of source code must retain the above * | |
12 * copyright notice, this list of conditions and the * | |
13 * following disclaimer. * | |
14 * * | |
15 * * Redistributions in binary form must reproduce the above * | |
16 * copyright notice, this list of conditions and the * | |
17 * following disclaimer in the documentation and/or other * | |
18 * materials provided with the distribution. * | |
19 * * | |
20 * * Neither the name of the WIDE Project or NICT nor the * | |
21 * names of its contributors may be used to endorse or * | |
22 * promote products derived from this software without * | |
23 * specific prior written permission of WIDE Project and * | |
24 * NICT. * | |
25 * * | |
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * | |
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * | |
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * | |
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * | |
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * | |
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * | |
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * | |
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * | |
34 *********************************************************************************************************/ | |
35 | |
36 #ifndef _FREEDIAMETER_H | |
37 #define _FREEDIAMETER_H | |
38 | |
39 | |
1
bafb831ba688
Fix names to proper case for freeDiameter
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
0
diff
changeset
|
40 #include <freeDiameter/libfreeDiameter.h> |
0 | 41 |
42 | |
43 /* The global dictionary */ | |
44 extern struct dictionary * fd_g_dict; | |
45 | |
46 | |
47 /***************************************/ | |
48 /* Sending a message on the network */ | |
49 /***************************************/ | |
50 | |
51 /* | |
52 * FUNCTION: fd_msg_send | |
53 * | |
54 * PARAMETERS: | |
55 * pmsg : Location of the message to be sent on the network (set to NULL on function return to avoid double deletion). | |
56 * anscb : A callback to be called when answer is received, if msg is a request (optional) | |
57 * anscb_data : opaque data to be passed back to the anscb when it is called. | |
58 * | |
59 * DESCRIPTION: | |
60 * Sends a message on the network. (actually simply queues it in a global queue, to be picked by a daemon's thread) | |
61 * For requests, the end-to-end id must be set (see fd_msg_get_eteid / MSGFL_ALLOC_ETEID). | |
62 * For answers, the message must be created with function fd_msg_new_answ. | |
63 * | |
64 * The routing module will handle sending to the correct peer, usually based on the Destination-Realm / Destination-Host AVP. | |
65 * | |
66 * If the msg is a request, there are two ways of receiving the answer: | |
67 * - either having registered a callback in the dispatch module (see disp_register) | |
68 * - or provide a callback as parameter here. If such callback is provided, it is called before the dispatch callbacks. | |
69 * The prototype for this callback function is: | |
70 * void anscb(void * data, struct msg ** answer) | |
71 * where: | |
72 * data : opaque data that was registered along with the callback. | |
73 * answer : location of the pointer to the answer. | |
74 * note1: on function return, if *answer is not NULL, the message is passed to the dispatch module for regular callbacks. | |
75 * otherwise, the callback must take care of freeing the message (msg_free). | |
76 * note2: the opaque data is not freed by the daemon in any case, extensions should ensure clean handling in waaad_ext_fini. | |
77 * | |
78 * If no callback is registered to handle an answer, the message is discarded and an error is logged. | |
79 * | |
80 * RETURN VALUE: | |
81 * 0 : The message has been queued for sending (sending may fail asynchronously). | |
82 * EINVAL : A parameter is invalid (ex: anscb provided but message is not a request). | |
83 * ... | |
84 */ | |
85 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ); | |
86 | |
87 /* | |
88 * FUNCTION: fd_msg_rescode_set | |
89 * | |
90 * PARAMETERS: | |
91 * msg : A msg object -- it must be an answer. | |
92 * dict : dictionary to use for AVP definitions | |
93 * rescode : The name of the returned error code (ex: "DIAMETER_INVALID_AVP") | |
94 * errormsg : (optional) human-readable error message to put in Error-Message AVP | |
95 * optavp : (optional) If provided, the content will be put inside a Failed-AVP | |
96 * type_id : 0 => nothing; 1 => adds Origin-Host and Origin-Realm with local info. 2=> adds Error-Reporting-Host. | |
97 * | |
98 * DESCRIPTION: | |
99 * This function adds a Result-Code AVP to a message, and optionally | |
100 * - sets the 'E' error flag in the header, | |
101 * - adds Error-Message, Error-Reporting-Host and Failed-AVP AVPs. | |
102 * | |
103 * RETURN VALUE: | |
104 * 0 : Operation complete. | |
105 * !0 : an error occurred. | |
106 */ | |
107 int fd_msg_rescode_set( struct msg * msg, struct dictionary * dict, char * rescode, char * errormsg, struct avp * optavp, int type_id ); | |
108 | |
109 /* The following functions are used to achieve frequent operations on the messages */ | |
110 int fd_msg_add_origin ( struct msg * msg, struct dictionary * dict, int osi ); /* Add Origin-Host, Origin-Realm, (if osi) Origin-State-Id AVPS at the end of the message */ | |
111 | |
112 | |
7
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
113 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
114 /***************************************/ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
115 /* Dispatch module, daemon's part */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
116 /***************************************/ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
117 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
118 enum { |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
119 DISP_APP_AUTH = 1, |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
120 DISP_APP_ACCT = 2 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
121 }; |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
122 /* |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
123 * FUNCTION: fd_disp_app_support |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
124 * |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
125 * PARAMETERS: |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
126 * app : The dictionary object corresponding to the Application. |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
127 * vendor : (Optional) the dictionary object of a Vendor to claim support in Vendor-Specific-Application-Id |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
128 * flags : Combination of DISP_APP_* flags. |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
129 * |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
130 * DESCRIPTION: |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
131 * Registers an application to be advertized in CER/CEA exchanges. |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
132 * Messages with an application-id matching a registered value are passed to the dispatch module, |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
133 * while other messages are simply relayed or an error is returned (if local node does not relay) |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
134 * |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
135 * RETURN VALUE: |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
136 * 0 : The application support is registered. |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
137 * EINVAL : A parameter is invalid. |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
138 */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
139 int fd_disp_app_support ( struct dict_object * app, struct dict_object * vendor, int flags ); |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
140 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
141 /* Note: if we want to support capabilities updates, we'll have to add possibility to remove an app as well... */ |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
142 |
e5af94b04946
Added dispatch module and tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
1
diff
changeset
|
143 |
0 | 144 #endif /* _FREEDIAMETER_H */ |