Mercurial > hg > waaad
annotate extensions/radius_gw/rg_common.h @ 410:9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 11 Jun 2009 16:59:45 +0900 |
parents | 3a8e91184d4d |
children | fc0d723c1f8b |
rev | line source |
---|---|
348
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
371
e86dba02630a
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
365
diff
changeset
|
5 * Copyright (c) 2009, WIDE Project and NICT * |
348
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
8 * Redistribution and use of this software in source and binary forms, with or without modification, are * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
35 |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
36 /* This file contains definitions for both radius_gw extension and subextensions. */ |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
37 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
38 #ifndef _RG_COMMON_H |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
39 #define _RG_COMMON_H |
360
2206c7f2945a
Added md5 code to check authenticator
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
358
diff
changeset
|
40 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
41 /* Some headers that are useful in many files */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
42 #include <pthread.h> |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
43 #include <string.h> |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
44 #include <stdlib.h> |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
45 #include <errno.h> |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
46 #include <stdint.h> |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
47 #include <dlfcn.h> |
388
1a4902b216f8
Improved initial handling of RADIUS messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
385
diff
changeset
|
48 #include <sys/socket.h> |
1a4902b216f8
Improved initial handling of RADIUS messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
385
diff
changeset
|
49 #include <netdb.h> |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
50 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
51 /* This should be overwritten before including this file */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
52 #ifndef DEFINE_DEBUG_MACRO |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
53 # define DEFINE_DEBUG_MACRO rg_common |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
54 # ifndef RG_COMMON_VERBO |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
55 # define RG_COMMON_VERBO 0 |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
56 # endif /* RG_COMMON_VERBO */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
57 static int rg_common_verbosity = RG_COMMON_VERBO; |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
58 #endif /* DEFINE_DEBUG_MACRO */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
59 |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
60 /* Include the waaad API definition */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
61 #define IN_EXTENSION |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
62 #include <waaad/waaad.h> |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
63 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
64 /* Include host-specific defines */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
65 #include "rg_host.h" |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
66 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
67 /* Include hostap files for RADIUS processings */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
68 #include "hostap_compat.h" |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
69 #include "md5.h" |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
70 #include "radius.h" |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
71 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
72 /* Include the radius_gw API definition */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
73 #include "rg_api.h" |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
74 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
75 /* Type of message / server */ |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
76 #define RGW_EXT_TYPE_AUTH 1 |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
77 #define RGW_EXT_TYPE_ACCT 2 |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
78 |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
79 |
410
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
80 /**************************************************************/ |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
81 /* Additional RADIUS definitions */ |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
82 /**************************************************************/ |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
83 /* Attributes missing from radius.h (not used in EAP) */ |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
84 enum { RADIUS_ATTR_CHAP_PASSWORD = 3, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
85 RADIUS_ATTR_SERVICE_TYPE = 6, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
86 RADIUS_ATTR_FRAMED_PROTOCOL = 7, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
87 RADIUS_ATTR_FRAMED_IP_ADDRESS = 8, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
88 RADIUS_ATTR_FRAMED_IP_NETMASK = 9, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
89 RADIUS_ATTR_FRAMED_ROUTING = 10, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
90 RADIUS_ATTR_FILTER_ID = 11, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
91 RADIUS_ATTR_FRAMED_COMPRESSION = 13, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
92 RADIUS_ATTR_LOGIN_IP_HOST = 14, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
93 RADIUS_ATTR_LOGIN_SERVICE = 15, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
94 RADIUS_ATTR_LOGIN_TCP_PORT = 16, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
95 RADIUS_ATTR_CALLBACK_NUMBER = 19, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
96 RADIUS_ATTR_CALLBACK_ID = 20, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
97 RADIUS_ATTR_FRAMED_ROUTE = 22, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
98 RADIUS_ATTR_FRAMED_IPX_NETWORK = 23, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
99 RADIUS_ATTR_LOGIN_LAT_SERVICE = 34, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
100 RADIUS_ATTR_LOGIN_LAT_NODE = 35, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
101 RADIUS_ATTR_LOGIN_LAT_GROUP = 36, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
102 RADIUS_ATTR_FRAMED_APPLETALK_LINK = 37, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
103 RADIUS_ATTR_FRAMED_APPLETALK_NETWORK = 38, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
104 RADIUS_ATTR_FRAMED_APPLETALK_ZONE = 39, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
105 RADIUS_ATTR_CHAP_CHALLENGE = 60, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
106 RADIUS_ATTR_PORT_LIMIT = 62, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
107 RADIUS_ATTR_LOGIN_LAT_PORT = 63, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
108 RADIUS_ATTR_TUNNEL_CLIENT_ENDPOINT = 66, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
109 RADIUS_ATTR_TUNNEL_SERVER_ENDPOINT = 67, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
110 RADIUS_ATTR_TUNNEL_PASSWORD = 69, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
111 RADIUS_ATTR_ARAP_PASSWORD = 70, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
112 RADIUS_ATTR_ARAP_FEATURES = 71, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
113 RADIUS_ATTR_ARAP_ZONE_ACCESS = 72, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
114 RADIUS_ATTR_ARAP_SECURITY = 73, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
115 RADIUS_ATTR_ARAP_SECURITY_DATA = 74, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
116 RADIUS_ATTR_PASSWORD_RETRY = 75, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
117 RADIUS_ATTR_PROMPT = 76, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
118 RADIUS_ATTR_CONFIGURATION_TOKEN = 78, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
119 RADIUS_ATTR_TUNNEL_ASSIGNEMENT_ID = 82, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
120 RADIUS_ATTR_TUNNEL_PREFERENCE = 83, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
121 RADIUS_ATTR_ARAP_CHALLENGE_RESPONSE = 84, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
122 RADIUS_ATTR_NAS_PORT_ID = 87, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
123 RADIUS_ATTR_FRAMED_POOL = 88, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
124 RADIUS_ATTR_TUNNEL_CLIENT_AUTH_ID = 90, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
125 RADIUS_ATTR_TUNNEL_SERVER_AUTH_ID = 91, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
126 RADIUS_ATTR_ORIGINATING_LINE_INFO = 94, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
127 RADIUS_ATTR_FRAMED_INTERFACE_ID = 96, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
128 RADIUS_ATTR_FRAMED_IPV6_PREFIX = 97, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
129 RADIUS_ATTR_LOGIN_IPV6_HOST = 98, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
130 RADIUS_ATTR_FRAMED_IPV6_ROUTE = 99, |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
131 RADIUS_ATTR_FRAMED_IPV6_POOL = 100 |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
132 }; |
9cb1799c40d1
Added code to convert Access-Request attributes to Diameter AVPs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
406
diff
changeset
|
133 |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
134 |
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
135 /**************************************************************/ |
356
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
136 /* Functions exported by the common library extension */ |
350
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
137 /**************************************************************/ |
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
138 |
c47a045fd4d6
Commit before the golden week
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
348
diff
changeset
|
139 /* List management */ |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
140 struct rg_list { |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
141 struct rg_list *next; |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
142 struct rg_list *prev; |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
143 struct rg_list *head; |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
144 }; |
356
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
145 void rg_list_init(struct rg_list * plist); |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
146 int rg_list_is_empty(struct rg_list * plist); |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
147 void rg_list_insert_after(struct rg_list * ref, struct rg_list * item); |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
148 void rg_list_insert_before(struct rg_list * ref, struct rg_list * item); |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
149 void rg_list_unlink(struct rg_list * plist); |
353
6ca21598562a
Unified TRACE_DEBUG handling between daemon and extensions + some progress on radius gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
352
diff
changeset
|
150 |
363
9d330bd07134
Progress on the radius_gw gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
361
diff
changeset
|
151 /* Others */ |
9d330bd07134
Progress on the radius_gw gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
361
diff
changeset
|
152 int rg_thread_term(pthread_t * th); |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
153 void rg_cleanup_mutex(void * mtx); |
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
154 |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
155 int rg_pointers_init(void ** hdl); |
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
156 void rg_pointers_fini(void **hdl); |
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
157 #define rg_pointers_resolve( ptr, hdl, fct, ret ) { \ |
406
3a8e91184d4d
Added code to handle RADIUS client deconnection
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
158 ptr = dlsym(hdl, fct); \ |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
159 if (!ptr) { \ |
406
3a8e91184d4d
Added code to handle RADIUS client deconnection
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
388
diff
changeset
|
160 TRACE_DEBUG(INFO, "Error in dlsym(" fct "): %s", dlerror()); \ |
385
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
161 return ret; \ |
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
162 } \ |
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
163 } |
03b512313cc1
Added code to handle sessions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
371
diff
changeset
|
164 |
363
9d330bd07134
Progress on the radius_gw gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
361
diff
changeset
|
165 |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
166 /****************************************/ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
167 /* Debug and related stuff */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
168 /****************************************/ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
169 |
356
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
170 #include <assert.h> |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
171 #ifndef ASSERT |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
172 #define ASSERT(x) assert(x) |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
173 #endif /* ASSERT */ |
555dc5a58aef
Added server code for radius extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
355
diff
changeset
|
174 |
348
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
176 /* CHECK_* macro from the daemon */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
177 /* Helper for tracing the CHECK_* macros bellow */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
178 #define TRACE_DEBUG_ALL( str ) \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
179 TRACE_DEBUG(CALL, str ); |
348
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 |
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 |
355
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
182 /* Macros to check a return value and branch out in case of error. |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
183 * These macro are to be used only when errors are highly improbable, not for expected errors. |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
184 */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
185 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
186 /* Check the return value of a system function and execute fallback in case of error */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
187 #define CHECK_SYS_DO( __call__, __fallback__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
188 int __ret__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
189 TRACE_DEBUG_ALL( "Check SYS: " #__call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
190 __ret__ = (__call__); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
191 if (__ret__ < 0) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
192 int __err__ = errno; /* We may handle EINTR here */ \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
193 log_error("An unexpected error occured (%s), turn on debug for detail\n",\ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
194 strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
195 TRACE_DEBUG(INFO, "Error in '" #__call__ "': %s", strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
196 __fallback__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
197 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
198 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
199 /* Check the return value of a system function, return error code on error */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
200 #define CHECK_SYS( __call__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
201 int __ret__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
202 TRACE_DEBUG_ALL( "Check SYS: " #__call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
203 __ret__ = (__call__); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
204 if (__ret__ < 0) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
205 int __err__ = errno; /* We may handle EINTR here */ \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
206 log_error("An unexpected error occured (%s), turn on debug for detail\n",\ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
207 strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
208 TRACE_DEBUG(INFO, "Error in '" #__call__ "': %s", strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
209 return __err__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
210 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
211 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
212 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
213 /* Check the return value of a POSIX function and execute fallback in case of error or special value */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
214 #define CHECK_POSIX_DO2( __call__, __val__, __fallback1__, __fallback2__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
215 int __ret__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
216 TRACE_DEBUG_ALL( "Check POSIX: " #__call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
217 __ret__ = (__call__); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
218 if (__ret__ != 0) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
219 if (__ret__ == (__val__)) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
220 __fallback1__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
221 } else { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
222 log_error("An unexpected error, see log for detail\n"); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
223 TRACE_DEBUG(INFO, "Error in '" #__call__ "': %s", strerror(__ret__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
224 __fallback2__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
225 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
226 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
227 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
228 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
229 /* Check the return value of a POSIX function and execute fallback in case of error */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
230 #define CHECK_POSIX_DO( __call__, __fallback__ ) \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
231 CHECK_POSIX_DO2( (__call__), 0, , __fallback__ ); |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
232 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
233 /* Check the return value of a POSIX function and return it if error */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
234 #define CHECK_POSIX( __call__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
235 int __v__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
236 CHECK_POSIX_DO( __v__ = (__call__), return __v__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
237 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
238 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
239 /* Check that a memory allocator did not return NULL, otherwise log an error and execute fallback */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
240 #define CHECK_MALLOC_DO( __call__, __fallback__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
241 void * __ret__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
242 TRACE_DEBUG_ALL( "Check MALLOC: " #__call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
243 __ret__ = (void *)( __call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
244 if (__ret__ == NULL) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
245 int __err__ = errno; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
246 log_error("Memory allocation failed: %s\n", strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
247 TRACE_DEBUG(INFO, "Error in '" #__call__ "': %s", strerror(__err__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
248 __fallback__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
249 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
250 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
251 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
252 /* Check that a memory allocator did not return NULL, otherwise return ENOMEM */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
253 #define CHECK_MALLOC( __call__ ) \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
254 CHECK_MALLOC_DO( __call__, return ENOMEM ); |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
255 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
256 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
257 /* The next functions can be used also for expected errors */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
258 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
259 /* Check parameters at function entry, execute fallback on error */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
260 #define CHECK_PARAMS_DO( __bool__, __fallback__ ) \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
261 TRACE_DEBUG_ALL( "Check PARAMS: " #__bool__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
262 if ( ! (__bool__) ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
263 TRACE_DEBUG(INFO, "Invalid parameter received in " #__bool__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
264 __fallback__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
265 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
266 /* Check parameters at function entry, return EINVAL if the boolean is false (similar to assert) */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
267 #define CHECK_PARAMS( __bool__ ) \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
268 CHECK_PARAMS_DO( __bool__, return EINVAL ); |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
269 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
270 /* Check the return value of an internal function, log and propagate */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
271 #define CHECK_FCT_DO( __call__, __fallback__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
272 int __ret__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
273 TRACE_DEBUG_ALL( "Check FCT: " #__call__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
274 __ret__ = (__call__); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
275 if (__ret__ != 0) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
276 TRACE_DEBUG(INFO, "Error in '" #__call__ "': %s", strerror(__ret__)); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
277 __fallback__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
278 } \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
279 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
280 /* Check the return value of a function call, return any error code */ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
281 #define CHECK_FCT( __call__ ) { \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
282 int __v__; \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
283 CHECK_FCT_DO( __v__ = (__call__), return __v__ ); \ |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
284 } |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
285 |
b811859f9963
Added extensions management in radius_gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
354
diff
changeset
|
286 |
365
0146c60af026
Moved to the hostap implementation of RADIUS processing (copied radius.* and md5.* files)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
363
diff
changeset
|
287 #endif /* _RG_COMMON_H */ |
348
7907e7cc0aef
Some stub files for the gateway extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
288 |