- Handle the 'GET PREFIX' request.
- Deal with MADGE_OBJECT1 requests. - Move code inside of switch cases to separate functions. Submitted by: Richard Hodges <rh@matriplex.com>
This commit is contained in:
parent
a5454382a3
commit
d66e94ca99
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112638
@ -2116,11 +2116,34 @@ process_get ( hdr, intf )
|
|||||||
{
|
{
|
||||||
Variable *var;
|
Variable *var;
|
||||||
int idx;
|
int idx;
|
||||||
|
int x;
|
||||||
|
int oidlen;
|
||||||
|
|
||||||
var = hdr->head;
|
var = hdr->head;
|
||||||
while ( var ) {
|
while ( var ) {
|
||||||
|
|
||||||
|
/* Handle the 'GET PREFIX' request */
|
||||||
|
oidlen = Objids[SETPFX_OBJID].oid[0];
|
||||||
|
if (oid_ncmp(&var->oid, &Objids[SETPFX_OBJID], oidlen) == 0) {
|
||||||
|
var->var.ival = 2; /* assume not valid */
|
||||||
|
for(x = 0; x < 13; x++)
|
||||||
|
if (var->oid.oid[oidlen + x + 2] !=
|
||||||
|
addressEntry[intf].oid[x + 1])
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Address Match */
|
||||||
|
if (x == 13)
|
||||||
|
hdr->head->var.ival = 1;
|
||||||
|
var = var->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
idx = find_var ( var );
|
idx = find_var ( var );
|
||||||
switch ( idx ) {
|
switch ( idx ) {
|
||||||
|
case MADGE_OBJECT1:
|
||||||
|
/* reply with NO SUCH OBJECT */
|
||||||
|
var->type = ASN_NULL;
|
||||||
|
break;
|
||||||
case SYS_OBJID:
|
case SYS_OBJID:
|
||||||
var->type = ASN_OBJID;
|
var->type = ASN_OBJID;
|
||||||
bcopy ( (caddr_t)&Objids[MY_OBJID],
|
bcopy ( (caddr_t)&Objids[MY_OBJID],
|
||||||
@ -2192,6 +2215,138 @@ process_get ( hdr, intf )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Find an OBJID from known ones
|
||||||
|
*
|
||||||
|
* in: Variable with valid OID
|
||||||
|
* out: OID number (index), -1 = not found
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
lmi_object_find(Variable *var)
|
||||||
|
{
|
||||||
|
Objid * obj_var;
|
||||||
|
Objid * obj_cur;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
obj_var = &var->oid;
|
||||||
|
|
||||||
|
for (x = 0; x < NUM_OIDS; x++) {
|
||||||
|
obj_cur = &Objids[x];
|
||||||
|
for (y = 0; y < 128; y++) {
|
||||||
|
if (obj_var->oid[y] != obj_cur->oid[y])
|
||||||
|
break;
|
||||||
|
if (obj_var->oid[y] == 0) /* object ID endmark */
|
||||||
|
return (x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Append instance number to OID
|
||||||
|
*
|
||||||
|
* in: Variable, instance number
|
||||||
|
* out: zero = success
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
lmi_object_instance(Variable *var, int instnum)
|
||||||
|
{
|
||||||
|
int * oidptr;
|
||||||
|
int curlen;
|
||||||
|
|
||||||
|
oidptr = var->oid.oid;
|
||||||
|
curlen = oidptr[0]; /* current length */
|
||||||
|
if (curlen > 126)
|
||||||
|
return (1);
|
||||||
|
curlen++;
|
||||||
|
oidptr[curlen] = instnum;
|
||||||
|
oidptr[0] = curlen;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Handle received GETNEXT
|
||||||
|
*
|
||||||
|
* in: Header with valid fields, interface number
|
||||||
|
* out: zero = success
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
lmi_rcvcmd_getnext(Snmp_Header *header, int intf)
|
||||||
|
{
|
||||||
|
int * oidptr;
|
||||||
|
int oidlen;
|
||||||
|
int oidnum;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
oidnum = lmi_object_find(header->head);
|
||||||
|
oidptr = header->head->oid.oid;
|
||||||
|
oidlen = oidptr[0];
|
||||||
|
|
||||||
|
switch(oidnum) {
|
||||||
|
/* Should be because the remote side is attempting
|
||||||
|
* to verify that our table is empty
|
||||||
|
*/
|
||||||
|
case ADDRESS_OBJID:
|
||||||
|
if ( addressEntry[intf].oid[0] ) {
|
||||||
|
/* XXX - FIXME */
|
||||||
|
/* Our table is not empty - return address */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Madge Collage sends GETNEXT for this */
|
||||||
|
case SETPFX_OBJID:
|
||||||
|
if(addressEntry[intf].oid[0]) { /* we have a prefix */
|
||||||
|
oidptr[0] += 14;
|
||||||
|
oidptr += oidlen; /* skip to last number */
|
||||||
|
oidptr++;
|
||||||
|
*oidptr++ = 13; /* length of prefix */
|
||||||
|
|
||||||
|
/* fill in the prefix */
|
||||||
|
for(x = 0; x < 13; x++) {
|
||||||
|
*oidptr++ = addressEntry[intf].oid[x+1];
|
||||||
|
}
|
||||||
|
header->head->type = ASN_INTEGER;
|
||||||
|
/* 1=valid, 2=invalid -- only 2 values */
|
||||||
|
header->head->var.ival = 1;
|
||||||
|
} else { /* no prefix available */
|
||||||
|
header->head->type = ASN_NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return (1); /* unknown object ID */
|
||||||
|
}
|
||||||
|
|
||||||
|
build_pdu(header, PDU_TYPE_GETRESP);
|
||||||
|
send_resp(intf, header, Resp_Buf);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* Handle received TRAP
|
||||||
|
*
|
||||||
|
* in: Header with valid fields, interface number
|
||||||
|
* out: zero = success
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
lmi_rcvcmd_trap(Snmp_Header *header, int intf)
|
||||||
|
{
|
||||||
|
|
||||||
|
bzero((caddr_t)&addressEntry[intf], sizeof(Objid));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ILMI State Processing Loop
|
* ILMI State Processing Loop
|
||||||
*
|
*
|
||||||
@ -2346,20 +2501,7 @@ ilmi_do_state ()
|
|||||||
/* The only messages we care about are GETNEXTs, GETRESPs, and TRAPs */
|
/* The only messages we care about are GETNEXTs, GETRESPs, and TRAPs */
|
||||||
switch ( Hdr->pdutype ) {
|
switch ( Hdr->pdutype ) {
|
||||||
case PDU_TYPE_GETNEXT:
|
case PDU_TYPE_GETNEXT:
|
||||||
/*
|
lmi_rcvcmd_getnext(Hdr, intf);
|
||||||
* Should be because the remote side is attempting
|
|
||||||
* to verify that our table is empty
|
|
||||||
*/
|
|
||||||
if ( oid_ncmp ( (caddr_t)&Hdr->head->oid,
|
|
||||||
(caddr_t)&Objids[ADDRESS_OBJID],
|
|
||||||
Objids[ADDRESS_OBJID].oid[0] ) == 0 ) {
|
|
||||||
if ( addressEntry[intf].oid[0] ) {
|
|
||||||
/* XXX - FIXME */
|
|
||||||
/* Our table is not empty - return address */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
build_pdu ( Hdr, PDU_TYPE_GETRESP );
|
|
||||||
send_resp ( intf, Hdr, Resp_Buf );
|
|
||||||
break;
|
break;
|
||||||
case PDU_TYPE_GETRESP:
|
case PDU_TYPE_GETRESP:
|
||||||
/*
|
/*
|
||||||
@ -2421,6 +2563,7 @@ ilmi_do_state ()
|
|||||||
break;
|
break;
|
||||||
case PDU_TYPE_TRAP:
|
case PDU_TYPE_TRAP:
|
||||||
/* Remote side wants us to start fresh */
|
/* Remote side wants us to start fresh */
|
||||||
|
lmi_rcvcmd_trap(Hdr, intf);
|
||||||
free_pdu ( Hdr );
|
free_pdu ( Hdr );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2442,8 +2585,7 @@ ilmi_do_state ()
|
|||||||
free_pdu ( Hdr );
|
free_pdu ( Hdr );
|
||||||
break;
|
break;
|
||||||
case PDU_TYPE_GETNEXT:
|
case PDU_TYPE_GETNEXT:
|
||||||
build_pdu ( Hdr, PDU_TYPE_GETRESP );
|
lmi_rcvcmd_getnext(Hdr, intf);
|
||||||
send_resp ( intf, Hdr, Resp_Buf );
|
|
||||||
break;
|
break;
|
||||||
case PDU_TYPE_SET:
|
case PDU_TYPE_SET:
|
||||||
/* Look for SET_PREFIX Objid */
|
/* Look for SET_PREFIX Objid */
|
||||||
@ -2461,6 +2603,7 @@ ilmi_do_state ()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PDU_TYPE_TRAP:
|
case PDU_TYPE_TRAP:
|
||||||
|
lmi_rcvcmd_trap(Hdr, intf);
|
||||||
free_pdu ( Hdr );
|
free_pdu ( Hdr );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user