Browse files

Drop bogus comments and whitespace

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
  • Loading branch information...
1 parent fb00dad commit dbf0b6bb78e1489c7b1750445e6586b0a6b6875c @lemenkov committed Oct 18, 2011
Showing with 9 additions and 199 deletions.
  1. +0 −1 include/eradius_dict.hrl
  2. +0 −1 include/eradius_lib.hrl
  3. +0 −45 src/eradius.erl
  4. +3 −4 src/eradius.hrl
  5. +6 −61 src/eradius_acc.erl
  6. +0 −43 src/eradius_dict.erl
  7. +0 −1 src/eradius_lib.erl
  8. +0 −43 src/eradius_server.erl
View
1 include/eradius_dict.hrl
@@ -7,7 +7,6 @@
%%% Created : 25 Sep 2003 by tobbe@bluetail.com
%%%-------------------------------------------------------------------
-
-record(attribute, {
id, % integer
type, % atom
View
1 include/eradius_lib.hrl
@@ -27,7 +27,6 @@
sockopts = [],% list of extra socket options
timeout}). % timeout in seconds
-
-record(rad_pdu, {
reqid,
authenticator,
View
45 src/eradius.erl
@@ -32,7 +32,6 @@
%% Internal exports
-export([worker/5]).
-
-record(state, {}).
-define(SERVER , ?MODULE).
@@ -44,7 +43,6 @@
default_port() -> ?PORT.
-
start() ->
application:start(eradius).
@@ -55,10 +53,6 @@ stop() ->
%%====================================================================
%% External functions
%%====================================================================
-%%--------------------------------------------------------------------
-%% Function: start_link/0
-%% Description: Starts the server
-%%--------------------------------------------------------------------
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
@@ -87,7 +81,6 @@ auth(E, User, Passwd, CallState) when is_record(E, eradius) ->
load_tables(Tables) ->
eradius_dict:load_tables(Tables).
-
%%====================================================================
%% Server functions
%%====================================================================
@@ -113,57 +106,21 @@ create_ets_table() ->
bump_id() ->
ets:update_counter(?TABLENAME, id_counter, 1).
-
-%%--------------------------------------------------------------------
-%% Function: handle_call/3
-%% Description: Handling call messages
-%% Returns: {reply, Reply, State} |
-%% {reply, Reply, State, Timeout} |
-%% {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, Reply, State} | (terminate/2 is called)
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_call({auth, E, User, Passwd, CState}, From, State) ->
start_worker(From, E, User, Passwd, CState),
{noreply, State}.
-%%--------------------------------------------------------------------
-%% Function: handle_cast/2
-%% Description: Handling cast messages
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_cast(_Req, State) ->
{noreply, State}.
-
-%%--------------------------------------------------------------------
-%% Function: handle_info/2
-%% Description: Handling all non call/cast messages
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_info({'EXIT', _Pid, _Reason}, State) ->
{noreply, State };
handle_info(_, State) ->
{noreply, State}.
-%%--------------------------------------------------------------------
-%% Function: terminate/2
-%% Description: Shutdown the server
-%% Returns: any (ignored by gen_server)
-%%--------------------------------------------------------------------
terminate(_Reason, _State) ->
ok.
-%%--------------------------------------------------------------------
-%% Func: code_change/3
-%% Purpose: Convert process state when code is changed
-%% Returns: {ok, NewState}
-%%--------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
@@ -244,15 +201,13 @@ wloop(E, User, _Passwd, [], _State) ->
?TRACEFUN(E,"no more RADIUS servers to try for ~s",[binary_to_list(User)]),
{reject, ?AL_Backend_Unreachable}.
-
send_recv_msg(Ip, Port, Req, E) ->
{ok, S} = gen_udp:open(0, [binary]),
gen_udp:send(S, Ip, Port, Req),
Resp = recv_wait(S, E#eradius.timeout),
gen_udp:close(S),
decode_response(Resp, E).
-
recv_wait(S, Timeout) ->
receive
{udp, S, _IP, _Port, Packet} ->
View
7 src/eradius.hrl
@@ -13,18 +13,17 @@
-define(AL_Backend_Error, 3). % other backend related, e.g. bad pdu
-define(AL_Internal_Error, 4).
-
%%% Result codes passed on to the (user provided) statistic fun.
-define(STAT_ACCEPTED, 1).
-define(STAT_REJECTED, 2).
-define(STAT_TIMEDOUT, 3).
%%% Calling the statistics fun
--define(STATFUN_ACCEPTED(E, Ip, Port),
+-define(STATFUN_ACCEPTED(E, Ip, Port),
(E#eradius.statfun)(?STAT_ACCEPTED, E, Ip, Port)).
--define(STATFUN_REJECTED(E, Ip, Port),
+-define(STATFUN_REJECTED(E, Ip, Port),
(E#eradius.statfun)(?STAT_REJECTED, E, Ip, Port)).
--define(STATFUN_TIMEDOUT(E, Ip, Port),
+-define(STATFUN_TIMEDOUT(E, Ip, Port),
(E#eradius.statfun)(?STAT_TIMEDOUT, E, Ip, Port)).
%%% Calling the trace fun
View
67 src/eradius_acc.erl
@@ -21,7 +21,7 @@
acc_start/1, acc_stop/1,
validate_servers/1, start/0,
set_user/2, set_nas_ip_address/1, set_nas_ip_address/2,
- set_sockopts/2,
+ set_sockopts/2,
set_login_time/1, set_logout_time/1, set_session_id/2, new/0,
set_radacct/1, set_attr/3, set_vend_attr/2, set_vend_attr/3, acc_update/1,
set_servers/2, set_timeout/2, set_login_time/2, set_vendor_id/2,
@@ -48,7 +48,6 @@
-define(PORT, 1813). % standard port for Radius Accounting
-define(TIMEOUT, 10).
-
%%% ====================================================================
%%% External interface
%%% ====================================================================
@@ -155,18 +154,12 @@ set_radacct(Radacct) when is_record(Radacct,radacct) ->
%%====================================================================
%% External functions
%%====================================================================
-%%--------------------------------------------------------------------
-%% Function: start_link/0
-%% Description: Starts the server
-%%--------------------------------------------------------------------
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
start() ->
gen_server:start({local, ?SERVER}, ?MODULE, [], []).
-
-
%%-----------------------------------------------------------------
%% Func: auth(User, Passwd, AuthSpec)
%% Types:
@@ -193,14 +186,6 @@ acc_update(Req) when is_record(Req,rad_accreq) ->
%% Server functions
%%====================================================================
-%%--------------------------------------------------------------------
-%% Function: init/1
-%% Description: Initiates the server
-%% Returns: {ok, State} |
-%% {ok, State, Timeout} |
-%% ignore |
-%% {stop, Reason}
-%%--------------------------------------------------------------------
init([]) ->
create_ets_table(),
{ok, #s{}}.
@@ -215,43 +200,25 @@ get_id() ->
bump_id() ->
ets:update_counter(?TABLENAME, id_counter, 1).
-
-%%--------------------------------------------------------------------
-%% Function: handle_call/3
-%% Description: Handling call messages
-%% Returns: {reply, Reply, State} |
-%% {reply, Reply, State, Timeout} |
-%% {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, Reply, State} | (terminate/2 is called)
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_call({set_radacct, R}, _From, State) when is_record(R, radacct) ->
{reply, ok, State#s{r = R}}.
-%%--------------------------------------------------------------------
-%% Function: handle_cast/2
-%% Description: Handling cast messages
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_cast({acc_on, Req}, State) ->
punch_acc(Req, State, ?Val_Acct_Status_Type_Accounting_On),
{noreply, State};
-%%
+
handle_cast({acc_off, Req}, State) ->
punch_acc(Req, State, ?Val_Acct_Status_Type_Accounting_Off),
{noreply, State};
-%%
+
handle_cast({acc_start, Req}, State) ->
punch_acc(Req, State, ?Val_Acct_Status_Type_Start),
{noreply, State};
-%%
+
handle_cast({acc_stop, Req}, State) ->
punch_acc(Req, State, ?Val_Acct_Status_Type_Stop),
{noreply, State};
-%%
+
handle_cast({acc_update, Req}, State) ->
punch_acc(Req, State, ?Val_Acct_Status_Type_Interim_Update),
{noreply, State}.
@@ -283,31 +250,12 @@ get_servers(Req,State) ->
{Srvs, Req#rad_accreq.timeout}
end.
-
-
-%%--------------------------------------------------------------------
-%% Function: handle_info/2
-%% Description: Handling all non call/cast messages
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%--------------------------------------------------------------------
handle_info(_Info, State) ->
{noreply, State}.
-%%--------------------------------------------------------------------
-%% Function: terminate/2
-%% Description: Shutdown the server
-%% Returns: any (ignored by gen_server)
-%%--------------------------------------------------------------------
terminate(_Reason, _State) ->
ok.
-%%--------------------------------------------------------------------
-%% Func: code_change/3
-%% Purpose: Convert process state when code is changed
-%% Returns: {ok, NewState}
-%%--------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
@@ -351,7 +299,6 @@ recv_wait(S, Timeout) ->
timeout
end.
-
%% Login = Logout = {MSec, Sec, uSec} | is_integer()
%% (In the second form it is erlang:now() in seconds)
compute_session_time(Login0, Logout0) ->
@@ -366,20 +313,18 @@ to_now(Now = {MSec, Sec, USec}) when is_integer(MSec),
to_now(Now) when is_integer(Now) ->
{Now div 1000000, Now rem 1000000, 0}.
-
any2bin(I) when is_integer(I) -> list_to_binary(integer_to_list(I));
any2bin(L) when is_list(L) -> list_to_binary(L);
any2bin(B) when is_binary(B) -> B.
-
%%%
%%% Registry validation and typecheck stuff
%%%
validate_servers(_X) ->
+ %% FIXME
true.
-
nas_ip_address() ->
node2ip(node()).
View
43 src/eradius_dict.erl
@@ -44,23 +44,13 @@ start_link() ->
start() ->
gen_server:start({local, ?SERVER}, ?MODULE, [], []).
-
load_tables(Tables) ->
gen_server:call(?SERVER, {load_tables, Tables}, infinity).
-
-
%%%----------------------------------------------------------------------
%%% Callback functions from gen_server
%%%----------------------------------------------------------------------
-%%----------------------------------------------------------------------
-%% Func: init/1
-%% Returns: {ok, State} |
-%% {ok, State, Timeout} |
-%% ignore |
-%% {stop, Reason}
-%%----------------------------------------------------------------------
init([]) ->
process_flag(trap_exit, true),
create_table(),
@@ -69,59 +59,26 @@ init([]) ->
create_table() ->
ets:new(?TABLENAME, [named_table, {keypos, 2}, public]).
-
-%%----------------------------------------------------------------------
-%% Func: handle_call/3
-%% Returns: {reply, Reply, State} |
-%% {reply, Reply, State, Timeout} |
-%% {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, Reply, State} | (terminate/2 is called)
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_call({load_tables, Tables}, _From, State) ->
Res = (catch lists:foreach(fun(Tab) -> load_table(Tab) end, Tables)),
{reply, Res, State}.
-%%----------------------------------------------------------------------
-%% Func: handle_cast/2
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_cast(_Msg, State) ->
{noreply, State}.
-%%----------------------------------------------------------------------
-%% Func: handle_info/2
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_info(_Info, State) ->
{noreply, State}.
-%%----------------------------------------------------------------------
-%% Func: terminate/2
-%% Purpose: Shutdown the server
-%% Returns: any (ignored by gen_server)
-%%----------------------------------------------------------------------
terminate(_Reason, _State) ->
ok.
-%%--------------------------------------------------------------------
-%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
-%% Description: Convert process state when code is changed
-%%--------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
-
%%%----------------------------------------------------------------------
%%% Internal functions
%%%----------------------------------------------------------------------
-
%%% --------------------------------------------------------------------
%%% Load dictionary table
%%% --------------------------------------------------------------------
View
1 src/eradius_lib.erl
@@ -295,7 +295,6 @@ dec_vend_attr_val(VendId, <<Vtype:8, Vlen:8, Vbin/binary>>) ->
[{Vkey,Vval} | dec_vend_attr_val(VendId, Vrest)]
end.
-
%%% ====================================================================
%%% Radius Accounting specifics
%%% ====================================================================
View
43 src/eradius_server.erl
@@ -40,7 +40,6 @@ start_link({A,B,C,D}=If, Port) ->
Name = list_to_atom(lists:flatten(io_lib:format("rad_~p_~p_~p_~p_~p", [A,B,C,D,Port]))),
gen_server:start_link({local, Name}, ?MODULE, {If, Port}, []).
-
create_tables(Nodes) ->
mnesia:create_table(nas_prop, [{attributes, record_info(fields, nas_prop)},
{disc_copies, Nodes}]).
@@ -69,18 +68,10 @@ set_trace(IP, Port, Bool) ->
end,
mnesia:transaction(F).
-
%%%----------------------------------------------------------------------
%%% Callback functions from gen_server
%%%----------------------------------------------------------------------
-%%----------------------------------------------------------------------
-%% Func: init/1
-%% Returns: {ok, State} |
-%% {ok, State, Timeout} |
-%% ignore |
-%% {stop, Reason}
-%%----------------------------------------------------------------------
init({Interface, Port}) ->
process_flag(trap_exit, true),
case gen_udp:open(Port, [{active, once}, {ip, Interface}, binary]) of
@@ -93,34 +84,13 @@ init({Interface, Port}) ->
{stop, Reason}
end.
-%%----------------------------------------------------------------------
-%% Func: handle_call/3
-%% Returns: {reply, Reply, State} |
-%% {reply, Reply, State, Timeout} |
-%% {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, Reply, State} | (terminate/2 is called)
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_call(_Request, _From, State) ->
Reply = ok,
{reply, Reply, State}.
-%%----------------------------------------------------------------------
-%% Func: handle_cast/2
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_cast(_Msg, State) ->
{noreply, State}.
-%%----------------------------------------------------------------------
-%% Func: handle_info/2
-%% Returns: {noreply, State} |
-%% {noreply, State, Timeout} |
-%% {stop, Reason, State} (terminate/2 is called)
-%%----------------------------------------------------------------------
handle_info({udp, Socket, IP, InPortNo, Packet} = Req, State) ->
case dec_radius(IP, Packet, State#state.port) of
{ok, Req_id, Nas_prop} ->
@@ -173,20 +143,10 @@ handle_info({'EXIT', Pid, _Reason}, State) ->
handle_info(_Info, State) ->
{noreply, State}.
-%%----------------------------------------------------------------------
-%% Func: terminate/2
-%% Purpose: Shutdown the server
-%% Returns: any (ignored by gen_server)
-%%----------------------------------------------------------------------
terminate(_Reason, State) ->
gen_udp:close(State#state.socket),
ok.
-%%----------------------------------------------------------------------
-%% Func: code_change/3
-%% Purpose: Convert process state when code is changed
-%% Returns: {ok, NewState}
-%%----------------------------------------------------------------------
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
@@ -223,19 +183,16 @@ allowed_ip(IP, Port) ->
{ok, Nas_prop}
end.
-
error_msg(Fmt, Vals) ->
error_logger:error_report([{application, radius},
lists:flatten(io_lib:format(Fmt, Vals))]).
-
dbg(on, Text, Vals) ->
io:format("~s -- "++Text, [printable_date() | Vals]);
dbg(#nas_prop{trace = true}, Text, Vals) ->
io:format("~s -- "++Text, [printable_date() | Vals]);
dbg(_, _, _) -> ok.
-
%%-----------------------------------------------------------------------
%% One of these is spawned for every radius request. This provides us
%% with nice fault isolation and allows remote LDAP servers to be as

0 comments on commit dbf0b6b

Please sign in to comment.