1609 lines
57 KiB
C
1609 lines
57 KiB
C
/******************************************************************************
|
|
******************************************************************************
|
|
**** This file was automatically generated by Wind River's
|
|
**** MIB Compiler, version 10.2.
|
|
**** This file was generated using the -stub switch.
|
|
****
|
|
**** This file contains stub function declarations to aid in building
|
|
**** the agent MIB interface. It creates all the MIB get, set, test, and
|
|
**** next method routines that you will need to supply. However,
|
|
**** since it doesn't know your system, several things are left to you.
|
|
**** Look for comments with `!!!' in them for places you're likely to want
|
|
**** to change for your system. Also, while the layout of the method
|
|
**** routines is a commonly useful one, it will not fit all data structures
|
|
**** and systems. Look at this output as a guide to how to write your
|
|
**** method routines; a guide that will, in most cases, significantly reduce
|
|
**** the amount of typing you need to do.
|
|
****
|
|
**** The code here assumes you've created a file called `mibleaf.h' with
|
|
**** the -leaf option to the mibcompiler.
|
|
****
|
|
**** YOU WILL PROBABLY MODIFY THIS FILE BUT BEWARE ACCIDENTALLY
|
|
**** OVERWRITING IT BY REGENERATING IT WITH THE MIB COMPILER.
|
|
****
|
|
**** Last build date: Thu Mar 15 16:41:18 2012
|
|
**** from files:
|
|
**** rfc2571.mib, rfc3291.mib, rfc4668.mib
|
|
******************************************************************************
|
|
******************************************************************************
|
|
*/
|
|
|
|
#include <wrn/wm/snmp/engine/asn1conf.h>
|
|
#include <wrn/wm/snmp/engine/asn1.h>
|
|
#include <wrn/wm/snmp/engine/buffer.h>
|
|
#include <wrn/wm/snmp/engine/mib.h>
|
|
#include <wrn/wm/snmp/engine/localio.h>
|
|
#include <wrn/wm/snmp/engine/snmpdefs.h>
|
|
#include <wrn/wm/snmp/engine/snmp.h>
|
|
#include <wrn/wm/snmp/engine/auxfuncs.h>
|
|
#include <ipcom_mib2_api.h>
|
|
#include "radius_mth.h"
|
|
#include "radius_mibhand.h"
|
|
|
|
|
|
#ifdef WRSNMP
|
|
#ifdef IPRADIUS
|
|
|
|
#include "ipradius.h"
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_lookup(int tcount, OIDC_T *tlist);
|
|
|
|
static int
|
|
radiusAuthServerEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) ; /* !!! */
|
|
|
|
static int
|
|
radiusAuthServerExtEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) ; /* !!! */
|
|
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_first();
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_int_next(Ipradius_server_entry * data);
|
|
|
|
int radiusAuthServerEntry_build_instance( Ipradius_server_entry * data,OIDC_T * tmp_inst);
|
|
|
|
Ipradius_data * radiusAuthClient_lookup();
|
|
|
|
static int
|
|
radiusAuthClient_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_data *data) ; /* !!! */
|
|
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_lookup(int tcount, OIDC_T *tlist);
|
|
|
|
static int
|
|
radiusAccServerEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) ; /* !!! */
|
|
|
|
static int
|
|
radiusAccServerExtEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) ; /* !!! */
|
|
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_first();
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_int_next(Ipradius_server_entry * data);
|
|
|
|
int radiusAccServerEntry_build_instance( Ipradius_server_entry * data,OIDC_T * tmp_inst);
|
|
|
|
Ipradius_data * radiusAccClient_lookup();
|
|
|
|
static int
|
|
radiusAccClient_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_data *data) ; /* !!! */
|
|
|
|
|
|
IP_EXTERN Ipradius_data ipradius;
|
|
/*
|
|
* Method routines for the radiusAuthServerTable:
|
|
*
|
|
* radiusAuthServerIndex -- not-accessible
|
|
* A number uniquely identifying each RADIUS
|
|
* Authentication server with which this client
|
|
* communicates.
|
|
*
|
|
* radiusAuthServerAddress -- read-only
|
|
* The IP address of the RADIUS authentication server
|
|
* referred to in this table entry.
|
|
*
|
|
* radiusAuthClientServerPortNumber -- read-only
|
|
* The UDP port the client is using to send requests to
|
|
* this server.
|
|
*
|
|
* radiusAuthClientRoundTripTime -- read-only
|
|
* The time interval (in hundredths of a second) between
|
|
* the most recent Access-Reply/Access-Challenge and the
|
|
* Access-Request that matched it from this RADIUS
|
|
* authentication server.
|
|
*
|
|
* radiusAuthClientAccessRequests -- read-only
|
|
* The number of RADIUS Access-Request packets sent
|
|
* to this server. This does not include retransmissions.
|
|
*
|
|
* radiusAuthClientAccessRetransmissions -- read-only
|
|
* The number of RADIUS Access-Request packets
|
|
* retransmitted to this RADIUS authentication server.
|
|
*
|
|
* radiusAuthClientAccessAccepts -- read-only
|
|
* The number of RADIUS Access-Accept packets
|
|
* (valid or invalid) received from this server.
|
|
*
|
|
* radiusAuthClientAccessRejects -- read-only
|
|
* The number of RADIUS Access-Reject packets
|
|
* (valid or invalid) received from this server.
|
|
*
|
|
* radiusAuthClientAccessChallenges -- read-only
|
|
* The number of RADIUS Access-Challenge packets
|
|
* (valid or invalid) received from this server.
|
|
*
|
|
* radiusAuthClientMalformedAccessResponses -- read-only
|
|
* The number of malformed RADIUS Access-Response
|
|
* packets received from this server.
|
|
* Malformed packets include packets with
|
|
* an invalid length. Bad authenticators or
|
|
* Message Authenticator attributes or unknown types
|
|
* are not included as malformed access responses.
|
|
*
|
|
* radiusAuthClientBadAuthenticators -- read-only
|
|
* The number of RADIUS Access-Response packets
|
|
* containing invalid authenticators or Message
|
|
* Authenticator attributes received from this server.
|
|
*
|
|
* radiusAuthClientPendingRequests -- read-only
|
|
* The number of RADIUS Access-Request packets
|
|
* destined for this server that have not yet timed out
|
|
* or received a response. This variable is incremented
|
|
* when an Access-Request is sent and decremented due to
|
|
* receipt of an Access-Accept, Access-Reject,
|
|
* Access-Challenge, timeout, or retransmission.
|
|
*
|
|
* radiusAuthClientTimeouts -- read-only
|
|
* The number of authentication timeouts to this server.
|
|
* After a timeout, the client may retry to the same
|
|
* server, send to a different server, or
|
|
* give up. A retry to the same server is counted as a
|
|
* retransmit as well as a timeout. A send to a different
|
|
* server is counted as a Request as well as a timeout.
|
|
*
|
|
* radiusAuthClientUnknownTypes -- read-only
|
|
* The number of RADIUS packets of unknown type that
|
|
* were received from this server on the authentication
|
|
* port.
|
|
*
|
|
* radiusAuthClientPacketsDropped -- read-only
|
|
* The number of RADIUS packets that were
|
|
* received from this server on the authentication port
|
|
* and dropped for some other reason.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAuthServerEntry_get and radiusAuthServerEntry_next.
|
|
* You need to replace the type STRUCT_radiusAuthServerEntry with something
|
|
* appropriate to your system. */
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
radiusAuthServerEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) /* !!! */
|
|
{
|
|
|
|
char addr[64]= {0};
|
|
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAuthServerAddress:
|
|
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
{
|
|
ipcom_inet_ntop(IP_AF_INET, &(servent->server.server_addr.sin.sin_addr.s_addr), addr, sizeof(addr)) ;
|
|
}
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
{
|
|
ipcom_inet_ntop(IP_AF_INET6, &(servent->server.server_addr.sin6.sin6_addr), addr, sizeof(addr)) ;
|
|
}
|
|
#endif
|
|
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen(addr), (OCTET_T *)addr, VT_STRING );
|
|
|
|
break;
|
|
case LEAF_radiusAuthClientServerPortNumber:
|
|
getproc_got_int32(pktp, vbp, ip_htons(servent->server.server_addr.sin.sin_port)); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientRoundTripTime:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthRoundTripTime, VT_TIMETICKS); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientAccessRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRequests, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientAccessRetransmissions:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRetransmissions, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientAccessAccepts:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessAccepts, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientAccessRejects:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRejects, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientAccessChallenges:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessChallenges, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientMalformedAccessResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthMalformedAccessResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientBadAuthenticators:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthBadAuthenticators, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientPendingRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->pkt_ids->access_ids.num, VT_GAUGE); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientTimeouts:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthTimeouts ,VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientUnknownTypes:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthUnknownTypes , VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientPacketsDropped:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthPacketsDropped, VT_COUNTER); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
void
|
|
radiusAuthServerEntry_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
int error;
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* use the instance (tcount and tlist) to look up the entry in the
|
|
* table. This lookup routine will probably have to be changed to
|
|
* suit your system. */
|
|
|
|
if ((data = radiusAuthServerEntry_lookup(tcount, tlist)) == 0) /* !!! */
|
|
{
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
}
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAuthServerEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_lookup(int tcount, OIDC_T *tlist)
|
|
{
|
|
int svr_index =0;
|
|
Ipradius_server_entry * servent = IP_NULL;
|
|
if(tlist && tcount ==1)
|
|
{
|
|
svr_index = tlist[0];
|
|
}
|
|
else
|
|
{
|
|
svr_index =1;
|
|
}
|
|
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if( (svr_index == servent->server.index) &&
|
|
((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCESS_SERVER)))
|
|
{
|
|
return servent;
|
|
}
|
|
}
|
|
return IP_NULL;
|
|
|
|
}
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_first()
|
|
{
|
|
|
|
Ipradius_server_entry *servent = IP_NULL;
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if(((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCESS_SERVER)))
|
|
{
|
|
|
|
return servent;
|
|
}
|
|
}
|
|
return IP_NULL;
|
|
}
|
|
|
|
Ipradius_server_entry * radiusAuthServerEntry_int_next(Ipradius_server_entry * data)
|
|
{
|
|
|
|
Ipradius_server_entry *servent = IP_NULL;
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if( (data->server.index < servent->server.index) &&
|
|
((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCESS_SERVER)))
|
|
{
|
|
return servent;
|
|
}
|
|
}
|
|
|
|
return IP_NULL;
|
|
}
|
|
|
|
int radiusAuthServerEntry_build_instance( Ipradius_server_entry * data,OIDC_T * tmp_inst)
|
|
{
|
|
|
|
tmp_inst [0] = data->server.index;
|
|
|
|
return (1);
|
|
}
|
|
|
|
void
|
|
radiusAuthServerEntry_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
Ipradius_server_entry * best; /* !!! */
|
|
int i;
|
|
int error;
|
|
unsigned inst_len;
|
|
unsigned best_inst_len;
|
|
|
|
OIDC_T tmp_inst[1];
|
|
OIDC_T best_inst[1];
|
|
|
|
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
|
|
best = 0;
|
|
/* This loop needs to iterate over each entry in your table */
|
|
for (data = radiusAuthServerEntry_first(); data; /* !!! */
|
|
data = radiusAuthServerEntry_int_next(data)) { /* !!! */
|
|
inst_len = radiusAuthServerEntry_build_instance(data, tmp_inst);
|
|
|
|
if ((oidcmp2(inst_len, tmp_inst, tcount, tlist) > 0) &&
|
|
((!best || (oidcmp2(inst_len, tmp_inst,
|
|
inst_len, best_inst) < 0)))) {
|
|
best = data;
|
|
for (i = 0; i < inst_len; i++)
|
|
best_inst[i] = tmp_inst[i];
|
|
best_inst_len = inst_len;
|
|
}
|
|
}
|
|
if (best) {
|
|
/* we found a next so get the values and set the instance for all
|
|
* the varbinds for this row of this table.
|
|
* NOTE: if you allow holes in the table then this code will have to
|
|
* change significantly to accomodate that. */
|
|
for ( ; vbp ; vbp = vbp->vb_link) {
|
|
if ((error = radiusAuthServerEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, best)) == NO_ERROR)
|
|
nextproc_next_instance(pktp, vbp, best_inst_len, best_inst);
|
|
else
|
|
nextproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
else /* there's no more in this table */
|
|
for ( ; vbp ; vbp = vbp->vb_link )
|
|
nextproc_no_next(pktp, vbp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
* Method routines for the radiusAuthServerExtTable:
|
|
*
|
|
* radiusAuthServerExtIndex -- not-accessible
|
|
* A number uniquely identifying each RADIUS
|
|
* Authentication server with which this client
|
|
* communicates.
|
|
*
|
|
* radiusAuthServerInetAddressType -- read-only
|
|
* The type of address format used for the
|
|
* radiusAuthServerInetAddress object.
|
|
*
|
|
* radiusAuthServerInetAddress -- read-only
|
|
* The IP address of the RADIUS authentication
|
|
* server referred to in this table entry, using
|
|
* the version-neutral IP address format.
|
|
*
|
|
* radiusAuthClientServerInetPortNumber -- read-only
|
|
* The UDP port the client is using to send requests
|
|
* to this server. The value of zero (0) is invalid.
|
|
*
|
|
* radiusAuthClientExtRoundTripTime -- read-only
|
|
* The time interval (in hundredths of a second) between
|
|
* the most recent Access-Reply/Access-Challenge and the
|
|
* Access-Request that matched it from this RADIUS
|
|
* authentication server.
|
|
*
|
|
* radiusAuthClientExtAccessRequests -- read-only
|
|
* The number of RADIUS Access-Request packets sent
|
|
* to this server. This does not include retransmissions.
|
|
* This counter may experience a discontinuity when the
|
|
* RADIUS Client module within the managed entity is
|
|
* reinitialized, as indicated by the current value of
|
|
* radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtAccessRetransmissions -- read-only
|
|
* The number of RADIUS Access-Request packets
|
|
* retransmitted to this RADIUS authentication server.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed entity
|
|
* is reinitialized, as indicated by the current value
|
|
* of radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtAccessAccepts -- read-only
|
|
* The number of RADIUS Access-Accept packets
|
|
* (valid or invalid) received from this server.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed entity
|
|
* is reinitialized, as indicated by the current value
|
|
* of radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtAccessRejects -- read-only
|
|
* The number of RADIUS Access-Reject packets
|
|
* (valid or invalid) received from this server.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed
|
|
* entity is reinitialized, as indicated by the
|
|
* current value of
|
|
* radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtAccessChallenges -- read-only
|
|
* The number of RADIUS Access-Challenge packets
|
|
* (valid or invalid) received from this server.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed
|
|
* entity is reinitialized, as indicated by the
|
|
* current value of
|
|
* radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtMalformedAccessResponses -- read-only
|
|
* The number of malformed RADIUS Access-Response
|
|
* packets received from this server.
|
|
* Malformed packets include packets with
|
|
* an invalid length. Bad authenticators or
|
|
* Message Authenticator attributes or unknown types
|
|
* are not included as malformed access responses.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed entity
|
|
* is reinitialized, as indicated by the current value
|
|
* of radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtBadAuthenticators -- read-only
|
|
* The number of RADIUS Access-Response packets
|
|
* containing invalid authenticators or Message
|
|
* Authenticator attributes received from this server.
|
|
* This counter may experience a discontinuity when
|
|
* the RADIUS Client module within the managed entity
|
|
* is reinitialized, as indicated by the current value
|
|
* of radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtPendingRequests -- read-only
|
|
* The number of RADIUS Access-Request packets
|
|
* destined for this server that have not yet timed out
|
|
* or received a response. This variable is incremented
|
|
* when an Access-Request is sent and decremented due to
|
|
* receipt of an Access-Accept, Access-Reject,
|
|
* Access-Challenge, timeout, or retransmission.
|
|
*
|
|
* radiusAuthClientExtTimeouts -- read-only
|
|
* The number of authentication timeouts to this server.
|
|
* After a timeout, the client may retry to the same
|
|
* server, send to a different server, or
|
|
* give up. A retry to the same server is counted as a
|
|
* retransmit as well as a timeout. A send to a different
|
|
* server is counted as a Request as well as a timeout.
|
|
* This counter may experience a discontinuity when the
|
|
* RADIUS Client module within the managed entity is
|
|
* reinitialized, as indicated by the current value of
|
|
* radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtUnknownTypes -- read-only
|
|
* The number of RADIUS packets of unknown type that
|
|
* were received from this server on the authentication
|
|
* port. This counter may experience a discontinuity
|
|
* when the RADIUS Client module within the managed
|
|
* entity is reinitialized, as indicated by the current
|
|
* value of radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientExtPacketsDropped -- read-only
|
|
* The number of RADIUS packets that were
|
|
* received from this server on the authentication port
|
|
* and dropped for some other reason. This counter may
|
|
* experience a discontinuity when the RADIUS Client
|
|
* module within the managed entity is reinitialized,
|
|
* as indicated by the current value of
|
|
* radiusAuthClientCounterDiscontinuity.
|
|
*
|
|
* radiusAuthClientCounterDiscontinuity -- read-only
|
|
* The number of centiseconds since the last discontinuity
|
|
* in the RADIUS Client counters. A discontinuity may
|
|
* be the result of a reinitialization of the RADIUS
|
|
* Client module within the managed entity.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAuthServerExtEntry_get and radiusAuthServerExtEntry_next.
|
|
* You need to replace the type STRUCT_radiusAuthServerExtEntry with something
|
|
* appropriate to your system. */
|
|
|
|
|
|
|
|
static int
|
|
radiusAuthServerExtEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) /* !!! */
|
|
{
|
|
char addr[64] ={0};
|
|
Ip_u32 addrtype = 0;
|
|
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAuthServerInetAddressType:
|
|
/* Values:
|
|
* unknown(0) = VAL_radiusAuthServerInetAddressType_unknown
|
|
* ipv4(1) = VAL_radiusAuthServerInetAddressType_ipv4
|
|
* ipv6(2) = VAL_radiusAuthServerInetAddressType_ipv6
|
|
* ipv4z(3) = VAL_radiusAuthServerInetAddressType_ipv4z
|
|
* ipv6z(4) = VAL_radiusAuthServerInetAddressType_ipv6z
|
|
* dns(16) = VAL_radiusAuthServerInetAddressType_dns
|
|
*/
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
{
|
|
addrtype =1;
|
|
}
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
{
|
|
addrtype = IP_IN6_IS_ADDR_LINK_LOCAL(&(servent->server.server_addr.sin6.sin6_addr)) ? 4 : 2;
|
|
}
|
|
#endif
|
|
|
|
getproc_got_int32(pktp, vbp, addrtype); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthServerInetAddress:
|
|
/* !!! This code uses the getproc_got_octet_string() API,
|
|
* which always allocates a new buffer to store the data
|
|
* provided. For more control over memory allocations,
|
|
* use getproc_got_string() instead.
|
|
*/
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
{
|
|
ipcom_inet_ntop(IP_AF_INET, &(servent->server.server_addr.sin.sin_addr.s_addr), addr, sizeof(addr)) ;
|
|
}
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
{
|
|
ipcom_inet_ntop(IP_AF_INET6, &(servent->server.server_addr.sin6.sin6_addr), addr, sizeof(addr)) ;
|
|
}
|
|
#endif
|
|
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen(addr), (OCTET_T *)addr, VT_STRING );
|
|
break;
|
|
case LEAF_radiusAuthClientServerInetPortNumber:
|
|
getproc_got_int32(pktp, vbp, ip_htons(servent->server.server_addr.sin.sin_port)); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtRoundTripTime:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthRoundTripTime, VT_TIMETICKS); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtAccessRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRequests, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtAccessRetransmissions:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRetransmissions, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtAccessAccepts:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessAccepts, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtAccessRejects:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessRejects, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtAccessChallenges:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthAccessChallenges, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtMalformedAccessResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthMalformedAccessResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtBadAuthenticators:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthBadAuthenticators, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtPendingRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->pkt_ids->access_ids.num, VT_GAUGE); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtTimeouts:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthTimeouts ,VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtUnknownTypes:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthUnknownTypes , VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientExtPacketsDropped:
|
|
getproc_got_uint32(pktp, vbp, servent->AuthPacketsDropped, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientCounterDiscontinuity:
|
|
getproc_got_uint32(pktp, vbp, 0, VT_TIMETICKS); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
void
|
|
radiusAuthServerExtEntry_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
int error;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* use the instance (tcount and tlist) to look up the entry in the
|
|
* table. This lookup routine will probably have to be changed to
|
|
* suit your system. */
|
|
if ((data = radiusAuthServerEntry_lookup(tcount, tlist)) == 0) /* !!! */
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAuthServerExtEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
radiusAuthServerExtEntry_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
Ipradius_server_entry *best; /* !!! */
|
|
OIDC_T tmp_inst[1];
|
|
OIDC_T best_inst[1];
|
|
int i;
|
|
int error;
|
|
unsigned inst_len;
|
|
unsigned best_inst_len;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* generate the instance of each table entry and find the
|
|
* smallest instance that's larger than tcount/tlist */
|
|
best = 0;
|
|
|
|
/* This loop needs to iterate over each entry in your table */
|
|
for (data = radiusAuthServerEntry_first(); data; /* !!! */
|
|
data = radiusAuthServerEntry_int_next(data)) { /* !!! */
|
|
inst_len = radiusAuthServerEntry_build_instance(data, tmp_inst);
|
|
|
|
if ((oidcmp2(inst_len, tmp_inst, tcount, tlist) > 0) &&
|
|
((!best || (oidcmp2(inst_len, tmp_inst,
|
|
inst_len, best_inst) < 0)))) {
|
|
best = data;
|
|
for (i = 0; i < inst_len; i++)
|
|
best_inst[i] = tmp_inst[i];
|
|
best_inst_len = inst_len;
|
|
}
|
|
}
|
|
if (best) {
|
|
/* we found a next so get the values and set the instance for all
|
|
* the varbinds for this row of this table.
|
|
* NOTE: if you allow holes in the table then this code will have to
|
|
* change significantly to accomodate that. */
|
|
for ( ; vbp ; vbp = vbp->vb_link) {
|
|
if ((error = radiusAuthServerExtEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, best)) == NO_ERROR)
|
|
nextproc_next_instance(pktp, vbp, best_inst_len, best_inst);
|
|
else
|
|
nextproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
else /* there's no more in this table */
|
|
for ( ; vbp ; vbp = vbp->vb_link )
|
|
nextproc_no_next(pktp, vbp);
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
* Method routines for the radiusAuthClient variables:
|
|
*
|
|
* radiusAuthClientInvalidServerAddresses -- read-only
|
|
* The number of RADIUS Access-Response packets
|
|
* received from unknown addresses.
|
|
*
|
|
* radiusAuthClientIdentifier -- read-only
|
|
* The NAS-Identifier of the RADIUS authentication client.
|
|
* This is not necessarily the same as sysName in MIB II.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAuthClient_get and radiusAuthClient_next.
|
|
* You need to replace the type STRUCT_radiusAuthClient with something
|
|
* appropriate to your system. */
|
|
|
|
Ipradius_data * radiusAuthClient_lookup()
|
|
{
|
|
return &ipradius;
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
radiusAuthClient_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_data *data) /* !!! */
|
|
{
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAuthClientInvalidServerAddresses:
|
|
getproc_got_uint32(pktp, vbp, data->mib_AuthInvalidServerAddresses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAuthClientIdentifier:
|
|
/* !!! This code uses the getproc_got_octet_string() API,
|
|
* which always allocates a new buffer to store the data
|
|
* provided. For more control over memory allocations,
|
|
* use getproc_got_string() instead.
|
|
*/
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen((const char*)data->ipradius_NAS_Identifier), data->ipradius_NAS_Identifier, VT_STRING); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
void
|
|
radiusAuthClient_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_data *data; /* !!! */
|
|
int error;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* check that the instance is exactly .0 */
|
|
if (!((tcount == 1) && (*tlist == 0)))
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
/* grab the actual data for this variable. this lookup routine will
|
|
* probably have to be changed for your system. for scalar variables
|
|
* there might not even be any lookup routine. */
|
|
else if ((data = radiusAuthClient_lookup()) == IP_NULL) /* !!! */
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_error(pktp, vbp, GEN_ERR);
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAuthClient_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void
|
|
radiusAuthClient_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_data *data; /* !!! */
|
|
OIDC_T instance = 0;
|
|
|
|
/* the only time there's a next for a scalar is if we're given
|
|
* no instance at all. */
|
|
if (tcount != 0)
|
|
nextproc_no_next(pktp, vbp);
|
|
/* grab the data for these variables. you'll probably have to change
|
|
* this lookup routine for your system. for scalar variables there
|
|
* might not even be any lookup routine. */
|
|
else if ((data = radiusAuthClient_lookup()) == IP_NULL) /* !!! */
|
|
getproc_error(pktp, vbp, GEN_ERR);
|
|
else {
|
|
/* find all the varbinds in this group and retrieve their
|
|
* values from the same data structure */
|
|
for (group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
vbp; vbp = vbp->vb_link) {
|
|
nextproc_next_instance(pktp, vbp, 1, &instance);
|
|
radiusAuthClient_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* Method routines for the radiusAccServerTable:
|
|
*
|
|
* radiusAccServerIndex -- not-accessible
|
|
* A number uniquely identifying each RADIUS
|
|
* Accounting server with which this client
|
|
* communicates.
|
|
*
|
|
* radiusAccServerAddress -- read-only
|
|
* The IP address of the RADIUS accounting server
|
|
* referred to in this table entry.
|
|
*
|
|
* radiusAccClientServerPortNumber -- read-only
|
|
* The UDP port the client is using to send requests to
|
|
* this server.
|
|
*
|
|
* radiusAccClientRoundTripTime -- read-only
|
|
* The time interval between the most recent
|
|
* Accounting-Response and the Accounting-Request that
|
|
* matched it from this RADIUS accounting server.
|
|
*
|
|
* radiusAccClientRequests -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* sent. This does not include retransmissions.
|
|
*
|
|
* radiusAccClientRetransmissions -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* retransmitted to this RADIUS accounting server.
|
|
* Retransmissions include retries where the
|
|
* Identifier and Acct-Delay have been updated, as
|
|
* well as those in which they remain the same.
|
|
*
|
|
* radiusAccClientResponses -- read-only
|
|
* The number of RADIUS packets received on the
|
|
* accounting port from this server.
|
|
*
|
|
* radiusAccClientMalformedResponses -- read-only
|
|
* The number of malformed RADIUS Accounting-Response
|
|
* packets received from this server. Malformed packets
|
|
* include packets with an invalid length. Bad
|
|
* authenticators and unknown types are not included as
|
|
* malformed accounting responses.
|
|
*
|
|
* radiusAccClientBadAuthenticators -- read-only
|
|
* The number of RADIUS Accounting-Response
|
|
* packets that contained invalid authenticators
|
|
* received from this server.
|
|
*
|
|
* radiusAccClientPendingRequests -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* sent to this server that have not yet timed out or
|
|
* received a response. This variable is incremented
|
|
* when an Accounting-Request is sent and decremented
|
|
* due to receipt of an Accounting-Response, a timeout,
|
|
* or a retransmission.
|
|
*
|
|
* radiusAccClientTimeouts -- read-only
|
|
* The number of accounting timeouts to this server.
|
|
* After a timeout, the client may retry to the same
|
|
* server, send to a different server, or give up.
|
|
* A retry to the same server is counted as a
|
|
* retransmit as well as a timeout. A send to a different
|
|
* server is counted as an Accounting-Request as well as
|
|
* a timeout.
|
|
*
|
|
* radiusAccClientUnknownTypes -- read-only
|
|
* The number of RADIUS packets of unknown type that
|
|
* were received from this server on the accounting port.
|
|
*
|
|
* radiusAccClientPacketsDropped -- read-only
|
|
* The number of RADIUS packets that were received from
|
|
* this server on the accounting port and dropped for some
|
|
* other reason.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAccServerEntry_get and radiusAccServerEntry_next.
|
|
* You need to replace the type STRUCT_radiusAccServerEntry with something
|
|
* appropriate to your system. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
radiusAccServerEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry * servent) /* !!! */
|
|
{
|
|
char addr[64] ={0};
|
|
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAccServerAddress:
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
ipcom_inet_ntop(IP_AF_INET, &(servent->server.server_addr.sin.sin_addr.s_addr), addr, sizeof(addr)) ;
|
|
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
ipcom_inet_ntop(IP_AF_INET6, &(servent->server.server_addr.sin6.sin6_addr), addr, sizeof(addr)) ;
|
|
#endif
|
|
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen(addr), (OCTET_T *)(addr), VT_STRING );
|
|
break;
|
|
case LEAF_radiusAccClientServerPortNumber:
|
|
getproc_got_int32(pktp, vbp, ip_htons(servent->server.server_addr.sin.sin_port)); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientRoundTripTime:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRoundTripTime , VT_TIMETICKS); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRequests, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientRetransmissions:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRetransmissions, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AccResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientMalformedResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AccMalformedResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientBadAuthenticators:
|
|
getproc_got_uint32(pktp, vbp, servent->AccBadAuthenticators, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientPendingRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->pkt_ids->account_ids.num , VT_GAUGE); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientTimeouts:
|
|
getproc_got_uint32(pktp, vbp, servent->AccTimeouts, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientUnknownTypes:
|
|
getproc_got_uint32(pktp, vbp, servent->AccUnknownTypes, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientPacketsDropped:
|
|
getproc_got_uint32(pktp, vbp, servent->AccPacketsDropped, VT_COUNTER); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
void
|
|
radiusAccServerEntry_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
int error;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* use the instance (tcount and tlist) to look up the entry in the
|
|
* table. This lookup routine will probably have to be changed to
|
|
* suit your system. */
|
|
if ((data = radiusAccServerEntry_lookup(tcount, tlist)) == 0) /* !!! */
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAccServerEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_lookup(int tcount, OIDC_T *tlist)
|
|
{
|
|
int svr_index =0;
|
|
Ipradius_server_entry * servent = IP_NULL;
|
|
if(tlist && tcount ==1)
|
|
{
|
|
svr_index = tlist[0];
|
|
}
|
|
else
|
|
{
|
|
svr_index = 1;
|
|
}
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if( (svr_index == servent->server.index) &&
|
|
((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCOUNTING_SERVER)))
|
|
{
|
|
return servent;
|
|
}
|
|
}
|
|
return IP_NULL;
|
|
}
|
|
|
|
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_first()
|
|
{
|
|
|
|
Ipradius_server_entry *servent = IP_NULL;
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if(((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCOUNTING_SERVER)))
|
|
{
|
|
|
|
return servent;
|
|
}
|
|
}
|
|
return IP_NULL;
|
|
}
|
|
|
|
Ipradius_server_entry * radiusAccServerEntry_int_next(Ipradius_server_entry * data)
|
|
{
|
|
|
|
Ipradius_server_entry *servent = IP_NULL;
|
|
|
|
for (servent = IPCOM_LIST_FIRST(&ipradius.server_head); servent; servent = IPCOM_LIST_NEXT(&servent->server_list))
|
|
{
|
|
if( (data->server.index < servent->server.index) &&
|
|
((servent->server.server_type == IPRADIUS_FULL_SERVER) ||
|
|
(servent->server.server_type == IPRADIUS_ACCOUNTING_SERVER)))
|
|
{
|
|
return servent;
|
|
}
|
|
}
|
|
|
|
return IP_NULL;
|
|
}
|
|
|
|
int radiusAccServerEntry_build_instance( Ipradius_server_entry * data,OIDC_T * tmp_inst)
|
|
{
|
|
|
|
tmp_inst [0] = data->server.index;
|
|
|
|
return (1);
|
|
}
|
|
|
|
|
|
|
|
void
|
|
radiusAccServerEntry_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
Ipradius_server_entry *best; /* !!! */
|
|
OIDC_T tmp_inst[1];
|
|
OIDC_T best_inst[1];
|
|
int i;
|
|
int error;
|
|
unsigned inst_len;
|
|
unsigned best_inst_len;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* generate the instance of each table entry and find the
|
|
* smallest instance that's larger than tcount/tlist */
|
|
best = 0;
|
|
|
|
/* This loop needs to iterate over each entry in your table */
|
|
for (data = radiusAccServerEntry_first(); data; /* !!! */
|
|
data = radiusAccServerEntry_int_next(data)) { /* !!! */
|
|
inst_len = radiusAccServerEntry_build_instance(data, tmp_inst);
|
|
|
|
if ((oidcmp2(inst_len, tmp_inst, tcount, tlist) > 0) &&
|
|
((!best || (oidcmp2(inst_len, tmp_inst,
|
|
inst_len, best_inst) < 0)))) {
|
|
best = data;
|
|
for (i = 0; i < inst_len; i++)
|
|
best_inst[i] = tmp_inst[i];
|
|
best_inst_len = inst_len;
|
|
}
|
|
}
|
|
if (best) {
|
|
/* we found a next so get the values and set the instance for all
|
|
* the varbinds for this row of this table.
|
|
* NOTE: if you allow holes in the table then this code will have to
|
|
* change significantly to accomodate that. */
|
|
for ( ; vbp ; vbp = vbp->vb_link) {
|
|
if ((error = radiusAccServerEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, best)) == NO_ERROR)
|
|
nextproc_next_instance(pktp, vbp, best_inst_len, best_inst);
|
|
else
|
|
nextproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
else /* there's no more in this table */
|
|
for ( ; vbp ; vbp = vbp->vb_link )
|
|
nextproc_no_next(pktp, vbp);
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
* Method routines for the radiusAccServerExtTable:
|
|
*
|
|
* radiusAccServerExtIndex -- not-accessible
|
|
* A number uniquely identifying each RADIUS
|
|
* Accounting server with which this client
|
|
* communicates.
|
|
*
|
|
* radiusAccServerInetAddressType -- read-only
|
|
* The type of address format used for the
|
|
* radiusAccServerInetAddress object.
|
|
*
|
|
* radiusAccServerInetAddress -- read-only
|
|
* The IP address of the RADIUS accounting
|
|
* server referred to in this table entry, using
|
|
* the version-neutral IP address format.
|
|
*
|
|
* radiusAccClientServerInetPortNumber -- read-only
|
|
* The UDP port the client is using to send requests
|
|
* to this accounting server. The value zero (0) is
|
|
* invalid.
|
|
*
|
|
* radiusAccClientExtRoundTripTime -- read-only
|
|
* The time interval between the most recent
|
|
* Accounting-Response and the Accounting-Request that
|
|
* matched it from this RADIUS accounting server.
|
|
*
|
|
* radiusAccClientExtRequests -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* sent. This does not include retransmissions.
|
|
* This counter may experience a discontinuity when the
|
|
* RADIUS Accounting Client module within the managed
|
|
* entity is reinitialized, as indicated by the current
|
|
* value of radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtRetransmissions -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* retransmitted to this RADIUS accounting server.
|
|
* Retransmissions include retries where the
|
|
* Identifier and Acct-Delay have been updated, as
|
|
* well as those in which they remain the same.
|
|
* This counter may experience a discontinuity when the
|
|
* RADIUS Accounting Client module within the managed
|
|
* entity is reinitialized, as indicated by the current
|
|
* value of radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtResponses -- read-only
|
|
* The number of RADIUS packets received on the
|
|
* accounting port from this server. This counter
|
|
* may experience a discontinuity when the RADIUS
|
|
* Accounting Client module within the managed entity is
|
|
* reinitialized, as indicated by the current value of
|
|
* radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtMalformedResponses -- read-only
|
|
* The number of malformed RADIUS Accounting-Response
|
|
* packets received from this server. Malformed packets
|
|
* include packets with an invalid length. Bad
|
|
* authenticators and unknown types are not included as
|
|
* malformed accounting responses. This counter may
|
|
* experience a discontinuity when the RADIUS Accounting
|
|
* Client module within the managed entity is
|
|
* reinitialized, as indicated by the current
|
|
* value of radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtBadAuthenticators -- read-only
|
|
* The number of RADIUS Accounting-Response
|
|
* packets that contained invalid authenticators
|
|
* received from this server. This counter may
|
|
* experience a discontinuity when the RADIUS
|
|
* Accounting Client module within the managed
|
|
* entity is reinitialized, as indicated by the
|
|
* current value of
|
|
* radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtPendingRequests -- read-only
|
|
* The number of RADIUS Accounting-Request packets
|
|
* sent to this server that have not yet timed out or
|
|
* received a response. This variable is incremented
|
|
* when an Accounting-Request is sent and decremented
|
|
* due to receipt of an Accounting-Response, a timeout,
|
|
* or a retransmission. This counter may experience a
|
|
* discontinuity when the RADIUS Accounting Client module
|
|
* within the managed entity is reinitialized, as
|
|
* indicated by the current value of
|
|
* radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtTimeouts -- read-only
|
|
* The number of accounting timeouts to this server.
|
|
* After a timeout, the client may retry to the same
|
|
* server, send to a different server, or give up.
|
|
* A retry to the same server is counted as a
|
|
* retransmit as well as a timeout. A send to a different
|
|
* server is counted as an Accounting-Request as well as
|
|
* a timeout. This counter may experience a discontinuity
|
|
* when the RADIUS Accounting Client module within the
|
|
* managed entity is reinitialized, as indicated by the
|
|
* current value of radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtUnknownTypes -- read-only
|
|
* The number of RADIUS packets of unknown type that
|
|
* were received from this server on the accounting port.
|
|
* This counter may experience a discontinuity when the
|
|
* RADIUS Accounting Client module within the managed
|
|
* entity is reinitialized, as indicated by the current
|
|
* value of radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientExtPacketsDropped -- read-only
|
|
* The number of RADIUS packets that were received from
|
|
* this server on the accounting port and dropped for some
|
|
* other reason. This counter may experience a
|
|
* discontinuity when the RADIUS Accounting Client module
|
|
* within the managed entity is reinitialized, as indicated
|
|
* by the current value of
|
|
* radiusAccClientCounterDiscontinuity.
|
|
*
|
|
* radiusAccClientCounterDiscontinuity -- read-only
|
|
* The number of centiseconds since the last
|
|
* discontinuity in the RADIUS Accounting Client
|
|
* counters. A discontinuity may be the result of a
|
|
* reinitialization of the RADIUS Accounting Client
|
|
* module within the managed entity.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAccServerExtEntry_get and radiusAccServerExtEntry_next.
|
|
* You need to replace the type STRUCT_radiusAccServerExtEntry with something
|
|
* appropriate to your system. */
|
|
static int
|
|
radiusAccServerExtEntry_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_server_entry *servent) /* !!! */
|
|
{
|
|
Ip_u32 addrtype = 0;
|
|
char addr[64] = {0};
|
|
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAccServerInetAddressType:
|
|
/* Values:
|
|
* unknown(0) = VAL_radiusAccServerInetAddressType_unknown
|
|
* ipv4(1) = VAL_radiusAccServerInetAddressType_ipv4
|
|
* ipv6(2) = VAL_radiusAccServerInetAddressType_ipv6
|
|
* ipv4z(3) = VAL_radiusAccServerInetAddressType_ipv4z
|
|
* ipv6z(4) = VAL_radiusAccServerInetAddressType_ipv6z
|
|
* dns(16) = VAL_radiusAccServerInetAddressType_dns
|
|
*/
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
{
|
|
addrtype =1;
|
|
}
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
{
|
|
addrtype = IP_IN6_IS_ADDR_LINK_LOCAL(&(servent->server.server_addr.sin6.sin6_addr)) ? 4 : 2;
|
|
}
|
|
#endif
|
|
|
|
|
|
getproc_got_int32(pktp, vbp, addrtype); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccServerInetAddress:
|
|
/* !!! This code uses the getproc_got_octet_string() API,
|
|
* which always allocates a new buffer to store the data
|
|
* provided. For more control over memory allocations,
|
|
* use getproc_got_string() instead.
|
|
*/
|
|
#ifdef IPCOM_USE_INET
|
|
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET)
|
|
ipcom_inet_ntop(IP_AF_INET, &(servent->server.server_addr.sin.sin_addr.s_addr), addr, sizeof(addr)) ;
|
|
|
|
#endif
|
|
|
|
#ifdef IPCOM_USE_INET6
|
|
if(servent->server.server_addr.sa.sa_family == IP_AF_INET6)
|
|
ipcom_inet_ntop(IP_AF_INET6, &(servent->server.server_addr.sin6.sin6_addr), addr, sizeof(addr)) ;
|
|
#endif
|
|
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen(addr), (OCTET_T *)(addr), VT_STRING );
|
|
break;
|
|
case LEAF_radiusAccClientServerInetPortNumber:
|
|
getproc_got_int32(pktp, vbp, ip_htons(servent->server.server_addr.sin.sin_port)); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtRoundTripTime:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRoundTripTime , VT_TIMETICKS); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRequests, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtRetransmissions:
|
|
getproc_got_uint32(pktp, vbp, servent->AccRetransmissions, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AccResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtMalformedResponses:
|
|
getproc_got_uint32(pktp, vbp, servent->AccMalformedResponses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtBadAuthenticators:
|
|
getproc_got_uint32(pktp, vbp, servent->AccBadAuthenticators, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtPendingRequests:
|
|
getproc_got_uint32(pktp, vbp, servent->pkt_ids->account_ids.num , VT_GAUGE); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtTimeouts:
|
|
getproc_got_uint32(pktp, vbp, servent->AccTimeouts, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtUnknownTypes:
|
|
getproc_got_uint32(pktp, vbp, servent->AccUnknownTypes, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientExtPacketsDropped:
|
|
getproc_got_uint32(pktp, vbp, servent->AccPacketsDropped, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientCounterDiscontinuity:
|
|
getproc_got_uint32(pktp, vbp, 0, VT_TIMETICKS); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
void
|
|
radiusAccServerExtEntry_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
int error;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* use the instance (tcount and tlist) to look up the entry in the
|
|
* table. This lookup routine will probably have to be changed to
|
|
* suit your system. */
|
|
if ((data = radiusAccServerEntry_lookup(tcount, tlist)) == 0) /* !!! */
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAccServerExtEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
radiusAccServerExtEntry_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_server_entry *data; /* !!! */
|
|
Ipradius_server_entry *best; /* !!! */
|
|
OIDC_T tmp_inst[1];
|
|
OIDC_T best_inst[1];
|
|
int i;
|
|
int error;
|
|
unsigned inst_len;
|
|
unsigned best_inst_len;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* generate the instance of each table entry and find the
|
|
* smallest instance that's larger than tcount/tlist */
|
|
best = 0;
|
|
/* This loop needs to iterate over each entry in your table */
|
|
for (data = radiusAccServerEntry_first(); data; /* !!! */
|
|
data = radiusAccServerEntry_int_next(data)) { /* !!! */
|
|
inst_len = radiusAccServerEntry_build_instance(data, tmp_inst);
|
|
|
|
if ((oidcmp2(inst_len, tmp_inst, tcount, tlist) > 0) &&
|
|
((!best || (oidcmp2(inst_len, tmp_inst,
|
|
inst_len, best_inst) < 0)))) {
|
|
best = data;
|
|
for (i = 0; i < inst_len; i++)
|
|
best_inst[i] = tmp_inst[i];
|
|
best_inst_len = inst_len;
|
|
}
|
|
}
|
|
if (best) {
|
|
/* we found a next so get the values and set the instance for all
|
|
* the varbinds for this row of this table.
|
|
* NOTE: if you allow holes in the table then this code will have to
|
|
* change significantly to accomodate that. */
|
|
for ( ; vbp ; vbp = vbp->vb_link) {
|
|
if ((error = radiusAccServerExtEntry_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, best)) == NO_ERROR)
|
|
nextproc_next_instance(pktp, vbp, best_inst_len, best_inst);
|
|
else
|
|
nextproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
else /* there's no more in this table */
|
|
for ( ; vbp ; vbp = vbp->vb_link )
|
|
nextproc_no_next(pktp, vbp);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Method routines for the radiusAccClient variables:
|
|
*
|
|
* radiusAccClientInvalidServerAddresses -- read-only
|
|
* The number of RADIUS Accounting-Response packets
|
|
* received from unknown addresses.
|
|
*
|
|
* radiusAccClientIdentifier -- read-only
|
|
* The NAS-Identifier of the RADIUS accounting client.
|
|
* This is not necessarily the same as sysName in MIB
|
|
* II.
|
|
*/
|
|
|
|
/* An internal routine to retrieve the values of the variables, used
|
|
* by the method routines radiusAccClient_get and radiusAccClient_next.
|
|
* You need to replace the type STRUCT_radiusAccClient with something
|
|
* appropriate to your system. */
|
|
static int
|
|
radiusAccClient_get_value(OIDC_T lastmatch,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp,
|
|
Ipradius_data *data) /* !!! */
|
|
{
|
|
switch(lastmatch) {
|
|
case LEAF_radiusAccClientInvalidServerAddresses:
|
|
getproc_got_uint32(pktp, vbp, data->mib_AccInvalidServerAddresses, VT_COUNTER); /* !!! */
|
|
break;
|
|
case LEAF_radiusAccClientIdentifier:
|
|
/* !!! This code uses the getproc_got_octet_string() API,
|
|
* which always allocates a new buffer to store the data
|
|
* provided. For more control over memory allocations,
|
|
* use getproc_got_string() instead.
|
|
*/
|
|
|
|
getproc_got_octet_string(pktp, vbp, (ALENGTH_T)strlen((const char*)data->ipradius_NAS_Identifier), data->ipradius_NAS_Identifier, VT_STRING); /* !!! */
|
|
break;
|
|
default:
|
|
return GEN_ERR;
|
|
}
|
|
return NO_ERROR;
|
|
}
|
|
|
|
|
|
Ipradius_data * radiusAccClient_lookup()
|
|
{
|
|
return &ipradius;
|
|
}
|
|
|
|
|
|
|
|
void
|
|
radiusAccClient_get(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_data *data; /* !!! */
|
|
int error;
|
|
|
|
/* find all the varbinds that share the same getproc and instance */
|
|
group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
|
|
/* check that the instance is exactly .0 */
|
|
if (!((tcount == 1) && (*tlist == 0)))
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_nosuchins(pktp, vbp);
|
|
/* grab the actual data for this variable. this lookup routine will
|
|
* probably have to be changed for your system. for scalar variables
|
|
* there might not even be any lookup routine. */
|
|
else if ((data = radiusAccClient_lookup()) == IP_NULL) /* !!! */
|
|
for ( ; vbp; vbp = vbp->vb_link)
|
|
getproc_error(pktp, vbp, GEN_ERR);
|
|
else {
|
|
/* retrieve all the values from the same data structure */
|
|
for ( ; vbp; vbp = vbp->vb_link) {
|
|
if ((error = radiusAccClient_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data)) != NO_ERROR)
|
|
getproc_error(pktp, vbp, error);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
radiusAccClient_next(OIDC_T lastmatch,
|
|
int tcount,
|
|
OIDC_T *tlist,
|
|
SNMP_PKT_T *pktp,
|
|
VB_T *vbp)
|
|
{
|
|
Ipradius_data *data; /* !!! */
|
|
OIDC_T instance = 0;
|
|
|
|
/* the only time there's a next for a scalar is if we're given
|
|
* no instance at all. */
|
|
if (tcount != 0)
|
|
nextproc_no_next(pktp, vbp);
|
|
/* grab the data for these variables. you'll probably have to change
|
|
* this lookup routine for your system. for scalar variables there
|
|
* might not even be any lookup routine. */
|
|
else if ((data = radiusAccClient_lookup()) == IP_NULL) /* !!! */
|
|
getproc_error(pktp, vbp, GEN_ERR);
|
|
else {
|
|
/* find all the varbinds in this group and retrieve their
|
|
* values from the same data structure */
|
|
for (group_by_getproc_and_instance(pktp, vbp, tcount, tlist);
|
|
vbp; vbp = vbp->vb_link) {
|
|
nextproc_next_instance(pktp, vbp, 1, &instance);
|
|
radiusAccClient_get_value(vbp->vb_ml.ml_last_match, pktp, vbp, data);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|