Mercurial > hg > waaad
view extensions/radius_gw/radius_gw.h @ 368:ccc9905c4525
Cleaned RADIUS message dump format
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Mon, 25 May 2009 11:13:38 +0900 |
parents | 0146c60af026 |
children | 16747d768091 |
line wrap: on
line source
/********************************************************************************************************* * Software License Agreement (BSD License) * * Author: Sebastien Decugis <sdecugis@nict.go.jp> * * * * Copyright (c) 2008, WIDE Project and NICT * * All rights reserved. * * * * Redistribution and use of this software in source and binary forms, with or without modification, are * * permitted provided that the following conditions are met: * * * * * Redistributions of source code must retain the above * * copyright notice, this list of conditions and the * * following disclaimer. * * * * * Redistributions in binary form must reproduce the above * * copyright notice, this list of conditions and the * * following disclaimer in the documentation and/or other * * materials provided with the distribution. * * * * * Neither the name of the WIDE Project or NICT nor the * * names of its contributors may be used to endorse or * * promote products derived from this software without * * specific prior written permission of WIDE Project and * * NICT. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED * * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR * * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *********************************************************************************************************/ /* This file contains the definitions needed by the radius_gw extension alone, not exported to sub-extensions. */ #ifndef _RADIUS_GW_H #define _RADIUS_GW_H /* This file extends definitions from the standard waaad API */ #define IN_EXTENSION #define DEFINE_DEBUG_MACRO radius_gw #include <waaad/waaad.h> /* include the common definitions */ #include "rg_common.h" /* API definition of waaad */ extern waaad_api_t * waaad_api; struct rgw_client; /* The RADIUS server(s) configuration */ struct rgw_serv { unsigned disabled :1; unsigned ip_disabled :1; unsigned ip6_disabled :1; unsigned :13; /* padding */ uint16_t port; /* stored in network byte order */ struct in_addr ip_endpoint; struct in6_addr ip6_endpoint; }; extern struct rgw_servs { struct rgw_serv auth_serv; struct rgw_serv acct_serv; } rgw_servers; int rgw_servers_init(void); int rgw_servers_start(void); void rgw_servers_dump(void); void rgw_servers_fini(void); /* RADIUS messages + metadata */ struct rgw_radius_msg_meta { /* The RADIUS message */ struct radius_msg radius; /* Metadata */ struct { /* The port it was sent from, in network byte order */ unsigned port :16; /* received on ACCT or AUTH port? */ unsigned serv_type :2; /* The message has a valid Message-Authenticator attribute */ unsigned valid_mac :1; }; }; void rgw_msg_free(struct rgw_radius_msg_meta ** msg); int rgw_msg_parse(unsigned char * buf, size_t len, struct rgw_radius_msg_meta ** msg); void rwg_msg_dump(struct rgw_radius_msg_meta * msg); int rgw_msg_auth_check(struct rgw_radius_msg_meta * msg, struct rgw_client * cli, uint8_t * req_auth); /* The clients allowed to connect to these servers */ int rgw_clients_init(void); int rgw_clients_add( struct sockaddr * ip_port, unsigned char ** key, size_t keylen ); int rgw_clients_getkey(struct rgw_client * cli, unsigned char **key, size_t *key_len); int rgw_clients_search(struct sockaddr * ip_port, struct rgw_client ** ref); int rgw_clients_check_dup(struct rgw_radius_msg_meta **msg, struct rgw_client *cli); void rgw_clients_dispose(struct rgw_client ** ref); void rgw_clients_dump(void); void rgw_clients_fini(void); /* Management of sub-extensions */ int rgw_extensions_init(void); int rgw_extensions_add( char * extfile, char * conffile, int port, unsigned char ** codes_array, size_t codes_sz ); void rgw_extensions_dump(void); void rgw_extensions_start_cache(void); int rgw_extensions_loop_req(struct rgw_radius_msg_meta **rad, sess_id_t **session, msg_t **diam_msg, struct rgw_client * cli); void rgw_extensions_fini(void); /* The function to parse the configuration file */ int rgw_conf_handle(char * conffile); /* Worker module, that processes incoming RADIUS messages (in separated threads) */ int rgw_work_start(void); int rgw_work_add(struct rgw_radius_msg_meta * msg, struct rgw_client * client); void rgw_work_fini(void); /* Verbosity level for debug */ extern int radius_gw_verbosity; #endif /* _RADIUS_GW_H */