/***************************************************************************/ /* Module: $Id: dosnmp.c,v 1.3 1999/05/07 04:15:25 maf Exp $ /* Description: KarlBridge authentication system high level snmp /* Author: maf /* Notes: /***************************************************************************/ /* $Log: */ #include "snmp.h" #include "kbauth.h" #include #include #include /*********************************************************************/ /* Function: DoKBRemoteAuth /* /* Description: /* /* Sends remote authorization packet /* /* Returns: 0 for good /* !0 for bad /* /*********************************************************************/ DoKBRemoteAuth(hostname, community, auth) char *hostname, *community; struct KBridgeAuthenRecord auth; { struct SNMPConnection sc; extern int SNMPErrno; extern int errno, sys_nerr; #ifdef ANSI extern char const * const sys_errlist[]; #else extern char *sys_errlist[]; #endif /* ANSI */ extern char *snmp_errlist[]; int err; ASN_Integer val; err = 1; /* bad */ bzero(&sc, sizeof(struct SNMPConnection)); /* make a connection, allowing 1 request/response at a time */ if (SNMPConnect(&sc, hostname, community, 1)) { fprintf(stderr, "SNMPConnect: %s\n", snmp_errlist[SNMPErrno]); goto DoKBRemoteAuth; } /****************************************/ /* initialize */ /****************************************/ sc.req->command = snmpSetRequest; sc.req->communityName = (u_char*)sc.community; sc.req->communityLen = strlen(sc.community); sc.req->reqCount = 1; /* 1 request */ /*...Kbridge.KBControl */ sc.req->list[0].oid[0] = 0x2b; sc.req->list[0].oid[1] = 6; sc.req->list[0].oid[2] = 1; sc.req->list[0].oid[3] = 4; sc.req->list[0].oid[4] = 1; sc.req->list[0].oid[5] = 762; sc.req->list[0].oid[6] = 2; sc.req->list[0].oid[7] = 1; sc.req->list[0].oid[9] = 0; sc.req->list[0].oidLen = 10; val = auth.timout; sc.req->list[0].oid[7] = 4; /* authentication */ sc.req->list[0].oid[8] = 1; sc.req->list[0].oid[9] = 1; sc.req->list[0].oid[10] = 4; /* set timeout (sets rest too) */ sc.req->list[0].oid[11] = auth.src_ipaddr[0]; /* src ipaddr */ sc.req->list[0].oid[12] = auth.src_ipaddr[1]; sc.req->list[0].oid[13] = auth.src_ipaddr[2]; sc.req->list[0].oid[14] = auth.src_ipaddr[3]; sc.req->list[0].oid[15] = auth.dst_ipaddr[0]; /* dst ipaddr */ sc.req->list[0].oid[16] = auth.dst_ipaddr[1]; sc.req->list[0].oid[17] = auth.dst_ipaddr[2]; sc.req->list[0].oid[18] = auth.dst_ipaddr[3]; sc.req->list[0].oid[19] = auth.mask[0]; /* mask */ sc.req->list[0].oid[20] = auth.mask[1]; sc.req->list[0].oid[21] = auth.mask[2]; sc.req->list[0].oid[22] = auth.mask[3]; sc.req->list[0].oidLen = 23; sc.req->list[0].objLen = sizeof (ASN_Integer); sc.req->list[0].objType = PC_Integer4; sc.req->list[0].obj = (u_char*)&val; if (SNMPRequestObj(&sc)) { fprintf(stderr, "SNMPRequestObj: %s\n", snmp_errlist[SNMPErrno]); goto DoKBRemoteAuth; } err = 0; DoKBRemoteAuth: return err; } /* DoKBRemoteAuth */