6 * Copyright (C) 2008 Alan DeKok <aland@networkradius.com>
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
11 * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
14 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 #include <freeradius-devel/ident.h>
21 #include <freeradius-devel/radiusd.h>
22 #include <freeradius-devel/modules.h>
26 * Find the named user in this modules database. Create the set
27 * of attribute-value pairs to check and reply with for this user
28 * from the database. The authentication code only needs to check
29 * the password, the rest is done here.
31 static int wimax_authorize(void *instance, REQUEST *request)
35 /* quiet the compiler */
40 * Fix Calling-Station-Id. Damn you, WiMAX!
42 vp = pairfind(request->packet->vps, PW_CALLING_STATION_ID);
43 if (vp && (vp->length == 6)) {
47 memcpy(buffer, vp->vp_octets, 6);
50 * RFC 3580 Section 3.20 says this is the preferred
51 * format. Everyone *SANE* is using this format,
54 for (i = 0; i < 6; i++) {
55 fr_bin2hex(&buffer[i], &vp->vp_strvalue[i * 3], 1);
56 vp->vp_strvalue[(i * 3) + 2] = '-';
59 vp->vp_strvalue[(5*3)+2] = '\0';
62 DEBUG2("rlm_wimax: Fixing WiMAX binary Calling-Station-Id to %s",
71 * Massage the request before recording it or proxying it
73 static int wimax_preacct(void *instance, REQUEST *request)
75 return wimax_authorize(instance, request);
79 * Write accounting information to this modules database.
81 static int wimax_accounting(void *instance, REQUEST *request)
83 /* quiet the compiler */
92 * The module name should be the only globally exported symbol.
93 * That is, everything else should be 'static'.
95 * If the module needs to temporarily modify it's instantiation
96 * data, the type should be changed to RLM_TYPE_THREAD_UNSAFE.
97 * The server will then take care of ensuring that the module
100 module_t rlm_wimax = {
103 RLM_TYPE_THREAD_SAFE, /* type */
104 NULL, /* instantiation */
107 NULL, /* authentication */
108 wimax_authorize, /* authorization */
109 wimax_preacct, /* preaccounting */
110 wimax_accounting, /* accounting */
111 NULL, /* checksimul */
112 NULL, /* pre-proxy */
113 NULL, /* post-proxy */