Mercurial > hg > waaad
annotate include/waaad/waaad.h @ 400:22f29007b931
Detect when extensions are loaded several times (not allowed)
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Tue, 02 Jun 2009 14:49:37 +0900 |
parents | e86dba02630a |
children |
rev | line source |
---|---|
11
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
1 /********************************************************************************************************* |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
2 * Software License Agreement (BSD License) * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
4 * * |
371
e86dba02630a
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
11
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
6 * All rights reserved. * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
7 * * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
10 * * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
13 * following disclaimer. * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
14 * * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
18 * materials provided with the distribution. * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
19 * * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
22 * promote products derived from this software without * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
24 * NICT. * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
25 * * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
34 *********************************************************************************************************/ |
a7183abb0599
Added the license (BSD) information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
10
diff
changeset
|
35 |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 /* |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 * This file contains the full definition of the API to be used between waaad daemon and its extensions. |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 * |
40
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
39 * The extensions are loaded by the function ext_load in the extension.c file in the daemon. |
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
40 * |
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
41 * If you are writing a new extension, you can find some models in the extensions directory. |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 * INSTRUCTIONS FOR EXTENSIONS: |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 * |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 * - Include this file as #include <waaad/waaad.h>, after defining IN_EXTENSION symbol. |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 * |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
47 * - One (and only one) of your extension file must also define the DECLARE_API_POINTERS |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
48 * symbol before including this file. |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
49 * |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 * - The extension must have a function called waaad_ext_init with the following prototype: |
15
89a15d1857f5
Added support for extensions' configuration files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
51 * int waaad_ext_init(waaad_api_t * api, char * conffile); |
40
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
52 * This function will be called by waaad daemon when the extension is loaded. |
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
53 * See the content of the macro EXTENSION_API_INIT for example of such function (see bellow). |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 * |
40
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
55 * - The following macro may be used in your extension to define the waaad_ext_init function to standard behavior: |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 * EXTENSION_API_INIT(flags, function, name) |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 * flags = combination of flags to tell what modules are needed by the extension. |
15
89a15d1857f5
Added support for extensions' configuration files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
58 * function = function to call once API is registered. prototype is: int function(char * conffile); |
89a15d1857f5
Added support for extensions' configuration files
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
11
diff
changeset
|
59 * where conffile is the name of a configuration file for this extension to parse. |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 * name = name of the extension |
40
4958ee89c48e
More details in the initial explanatory comments
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
36
diff
changeset
|
61 * If you use this macro, you need to #include <stdio.h> and <errno.h> |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 * |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 * - The extension may also provide a function called waaad_ext_fini with this prototype: |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 * void waaad_ext_fini (void); |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 * This function, if present, will be called when the daemon terminate cleanly. |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 #ifndef _WAAAD_API_H |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 #define _WAAAD_API_H |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 /* Include all the modules API definitions */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 #include <waaad/log-api.h> |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 #include <waaad/dictionary-api.h> |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
74 #include <waaad/conf-api.h> |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
75 #include <waaad/peer-api.h> |
24
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
76 #include <waaad/message-api.h> |
29
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
77 #include <waaad/routing-api.h> |
35
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
78 #include <waaad/session-api.h> |
36
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
79 #include <waaad/dispatch-api.h> |
43
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
80 #include <waaad/security-api.h> |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
81 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
82 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
83 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
84 /* ********************************** */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
85 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
86 /* The version of this API format. Increment each time you change the structure waaad_api_t */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 #define WAAAD_API_VER 1 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
89 /* Now define the structure type that will be passed to the extension initializer */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
90 typedef struct { |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
91 int version; /* The global version of this API. Must be WAAAD_API_VER */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
92 api_log_t log; |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 api_dict_t dictionary; |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
94 api_conf_t conf; |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
95 api_peer_t peer; |
24
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
96 api_msg_t msg; |
29
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
97 api_rt_t rt; |
35
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
98 api_sess_t session; |
36
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
99 api_disp_t dispatch; |
43
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
100 api_sec_t security; |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
101 } waaad_api_t; |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
102 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 /* ********************************** */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 /* The code bellow this line is only used to load the API in an extension and check the API number version. */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
106 #ifdef IN_EXTENSION |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 |
104
a6fb0680654e
Adding security extensions, work in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
108 #include <stdio.h> |
a6fb0680654e
Adding security extensions, work in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
109 #include <errno.h> |
a6fb0680654e
Adding security extensions, work in progress
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
43
diff
changeset
|
110 |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 typedef struct { |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 size_t length; |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 int version; |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 } sub_api_header_t; |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 #define API_MODULE_ALL 0xffffffff /* Load the complete API in the extension, safest setting */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
118 #define API_MODULE_LOG 0x00000001 /* Load the log API in the extension */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 #define API_MODULE_DICTIONARY 0x00000002 /* Load the dictionary API in the extension */ |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
120 #define API_MODULE_CONF 0x00000004 /* Load the configuration API in the extension */ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
121 #define API_MODULE_PEER 0x00000008 /* Load the peer API in the extension */ |
24
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
122 #define API_MODULE_MSG 0x00000010 /* Load the message API in the extension */ |
29
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
123 #define API_MODULE_RT 0x00000020 /* Load the routing API in the extension */ |
35
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
124 #define API_MODULE_SESSION 0x00000040 /* Load the session API in the extension */ |
36
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
125 #define API_MODULE_DISPATCH 0x00000080 /* Load the dispatch API in the extension */ |
43
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
126 #define API_MODULE_SECURITY 0x00000100 /* Load the security API in the extension */ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
163
diff
changeset
|
129 #define EXTENSION_API_INIT_INTERN( flags, name, api ) { \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
130 sub_api_header_t * hdr; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
131 char * buffer = (char *)api; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 int index = 0; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 if (api->version != WAAAD_API_VER) { \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 /* Unable to parse this API, do not continue */ \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
136 fprintf(stderr, \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
137 "[%s] Incompatible API version, please recompile the extension.\n", (name)); \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
138 return EINVAL; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 } \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
140 \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
141 index += sizeof(int); \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
142 \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
143 hdr = (sub_api_header_t *) &buffer[index]; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
144 index += hdr->length; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
145 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
146 if ( (flags) & API_MODULE_LOG ) { \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
147 g_api_log = (api_log_t *)hdr; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
148 if (g_api_log->version != WAAAD_API_LOG_VER) { \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
149 /* Unable to parse this API, do not continue */ \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
150 fprintf(stderr, \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
151 "[%s] Incompatible log API version, please recompile the extension.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
152 (name)); \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
153 return EINVAL; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
154 } \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 } \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
156 \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 hdr = (sub_api_header_t *) &buffer[index]; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 index += hdr->length; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
160 if ( (flags) & API_MODULE_DICTIONARY ) { \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 g_api_dict = (api_dict_t *)hdr; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 if (g_api_dict->version != WAAAD_API_DICT_VER) { \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
163 /* Unable to parse this API, do not continue */ \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 fprintf(stderr, \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 "[%s] Incompatible dictionary API version, please recompile the extension.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
166 (name)); \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
167 return EINVAL; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
168 } \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 } \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
170 \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
171 hdr = (sub_api_header_t *) &buffer[index]; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 index += hdr->length; \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
174 if ( (flags) & API_MODULE_CONF ) { \ |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
175 g_api_conf = (api_conf_t *)hdr; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
176 if (g_api_conf->version != WAAAD_API_CONF_VER) { \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
177 /* Unable to parse this API, do not continue */ \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
178 fprintf(stderr, \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
179 "[%s] Incompatible conf API version, please recompile the extension.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
180 (name)); \ |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
181 return EINVAL; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
182 } \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
183 } \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
184 \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
185 hdr = (sub_api_header_t *) &buffer[index]; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
186 index += hdr->length; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
187 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
188 if ( (flags) & API_MODULE_PEER ) { \ |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
189 g_api_peer = (api_peer_t *)hdr; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
190 if (g_api_peer->version != WAAAD_API_PEER_VER) { \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
191 /* Unable to parse this API, do not continue */ \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
192 fprintf(stderr, \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
193 "[%s] Incompatible peer API version, please recompile the extension" \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
194 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
195 (name)); \ |
21
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
196 return EINVAL; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
197 } \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
198 } \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
199 \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
200 hdr = (sub_api_header_t *) &buffer[index]; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
201 index += hdr->length; \ |
f28a9cc0e6e1
Fix a bug if extension has several files. Now DECLARE_API_POINTERS must be defined once.
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
15
diff
changeset
|
202 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
203 if ( (flags) & API_MODULE_MSG ) { \ |
24
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
204 g_api_msg = (api_msg_t *)hdr; \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
205 if (g_api_msg->version != WAAAD_API_MSG_VER) { \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
206 /* Unable to parse this API, do not continue */ \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
207 fprintf(stderr, \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
208 "[%s] Incompatible message API version, please recompile the extension" \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
209 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
210 (name)); \ |
24
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
211 return EINVAL; \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
212 } \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
213 } \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
214 \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
215 hdr = (sub_api_header_t *) &buffer[index]; \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
216 index += hdr->length; \ |
41f0f8549ddf
Added skeleton for the messages management
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
21
diff
changeset
|
217 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
218 if ( (flags) & API_MODULE_RT ) { \ |
29
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
219 g_api_rt = (api_rt_t *)hdr; \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
220 if (g_api_rt->version != WAAAD_API_RT_VER) { \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
221 /* Unable to parse this API, do not continue */ \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
222 fprintf(stderr, \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
223 "[%s] Incompatible routing API version, please recompile the extension" \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
224 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
225 (name)); \ |
29
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
226 return EINVAL; \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
227 } \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
228 } \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
229 \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
230 hdr = (sub_api_header_t *) &buffer[index]; \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
231 index += hdr->length; \ |
48cd40f27f3f
Added more information about routing, still incomplete
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
24
diff
changeset
|
232 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
233 if ( (flags) & API_MODULE_SESSION ) { \ |
35
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
234 g_api_session = (api_sess_t *)hdr; \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
235 if (g_api_session->version != WAAAD_API_SESSION_VER) { \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
236 /* Unable to parse this API, do not continue */ \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
237 fprintf(stderr, \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
238 "[%s] Incompatible session API version, please recompile the extension" \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
239 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
240 (name)); \ |
35
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
241 return EINVAL; \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
242 } \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
243 } \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
244 \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
245 hdr = (sub_api_header_t *) &buffer[index]; \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
246 index += hdr->length; \ |
f35a9404cbef
Added prototype and explanations for the basical support of Diameter sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
29
diff
changeset
|
247 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
248 if ( (flags) & API_MODULE_DISPATCH ) { \ |
36
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
249 g_api_disp = (api_disp_t *)hdr; \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
250 if (g_api_disp->version != WAAAD_API_DISP_VER) { \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
251 /* Unable to parse this API, do not continue */ \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
252 fprintf(stderr, \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
253 "[%s] Incompatible dispatch API version, please recompile the extension" \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
254 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
255 (name)); \ |
36
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
256 return EINVAL; \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
257 } \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
258 } \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
259 \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
260 hdr = (sub_api_header_t *) &buffer[index]; \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
261 index += hdr->length; \ |
c90483949e69
Added the dispatch API
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
35
diff
changeset
|
262 \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
263 if ( (flags) & API_MODULE_SECURITY ) { \ |
43
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
264 g_api_sec = (api_sec_t *)hdr; \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
265 if (g_api_sec->version != WAAAD_API_SEC_VER) { \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
266 /* Unable to parse this API, do not continue */ \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
267 fprintf(stderr, \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
268 "[%s] Incompatible security API version, please recompile the extension" \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
269 " or update the initialization in extensions.c.\n", \ |
163
14665eb59b34
Tons of cleanups (unfinished)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
104
diff
changeset
|
270 (name)); \ |
43
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
271 return EINVAL; \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
272 } \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
273 } \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
274 \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
275 hdr = (sub_api_header_t *) &buffer[index]; \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
276 index += hdr->length; \ |
441e1c5624e0
Added the last part of the API, security
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
40
diff
changeset
|
277 \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
278 /* next module... */ \ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
279 \ |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
163
diff
changeset
|
280 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
163
diff
changeset
|
281 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
163
diff
changeset
|
282 |
400
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
283 #define EXTENSION_API_INIT(flags, function, name, no_double) \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
284 static int extension_loaded = 0; \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
285 int waaad_ext_init(waaad_api_t * api, char * conffile) { \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
286 EXTENSION_API_INIT_INTERN( flags, name, api ); \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
287 if (extension_loaded && no_double) { \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
288 log_error("Extension %s cannot be loaded twice!\n", name); \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
289 return ENOTSUP; \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
290 } \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
291 extension_loaded++; \ |
22f29007b931
Detect when extensions are loaded several times (not allowed)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
292 return (function)(conffile); \ |
2
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
293 } |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
294 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
295 |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
296 #endif /* IN_EXTENSION */ |
3d94ea889f98
Initial small set of files to develop the extension mechanism
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
297 #endif /* ! _WAAAD_API_H */ |