From owner-freebsd-audit Tue Feb 25 18: 1:25 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 80FB737B401 for ; Tue, 25 Feb 2003 18:01:22 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29E4A43F85 for ; Tue, 25 Feb 2003 18:01:22 -0800 (PST) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 011F2AE28D; Tue, 25 Feb 2003 18:01:21 -0800 (PST) Date: Wed, 26 Feb 2003 03:01:21 +0100 From: Maxime Henrion To: audit@freebsd.org Subject: syscons patch Message-ID: <20030226020121.GD18565@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="s2ZSL+KKDSLx8OML" Content-Disposition: inline User-Agent: Mutt/1.4i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --s2ZSL+KKDSLx8OML Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, I've recently experienced the fact that if you try to drop into the kernel debugger when someone disabled VTY switching (either with lock -v or vidcontrol -S), the box will freeze. I've written a patch which just disables the VTY switching protection in the DDB case when someone tries to enter the debugger. I think it makes sense since a box which is supposed to be physically secure shouldn't use DDB. However, given the security implications, I'd appreciate comments on this stuff. The attached patch implements this solution and documents it in lock(1) and vidcontrol(1). Cheers, Maxime --s2ZSL+KKDSLx8OML Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="syscons.patch" Index: sys/dev/syscons/syscons.c =================================================================== RCS file: /space2/ncvs/src/sys/dev/syscons/syscons.c,v retrieving revision 1.395 diff -u -p -r1.395 syscons.c --- sys/dev/syscons/syscons.c 25 Feb 2003 03:21:20 -0000 1.395 +++ sys/dev/syscons/syscons.c 25 Feb 2003 23:17:56 -0000 @@ -1538,6 +1538,10 @@ sccndbctl(struct consdev *cd, int on) && sc_console->smode.mode == VT_AUTO) { sc_console->sc->cur_scp->status |= MOUSE_HIDDEN; ++debugger; /* XXX */ +#ifdef DDB + /* unlock vty switching */ + sc_console->sc->flags &= ~SC_SCRN_VTYLOCK; +#endif sc_switch_scr(sc_console->sc, sc_console->index); --debugger; /* XXX */ } Index: usr.bin/lock/lock.1 =================================================================== RCS file: /space2/ncvs/src/usr.bin/lock/lock.1,v retrieving revision 1.8 diff -u -p -r1.8 lock.1 --- usr.bin/lock/lock.1 28 Jul 2002 07:13:53 -0000 1.8 +++ usr.bin/lock/lock.1 26 Feb 2003 01:43:56 -0000 @@ -70,10 +70,14 @@ This option is implemented in a way simi .Fl S option of .Xr vidcontrol 1 , -and is only available if the terminal in question is a +and thus has the same restrictions. +It is only available if the terminal in question is a .Xr syscons 4 virtual terminal. .El +.Sh SEE ALSO +.Xr vidcontrol 1 , +.Xr syscons 4 .Sh HISTORY The .Nm Index: usr.sbin/vidcontrol/vidcontrol.1 =================================================================== RCS file: /space2/ncvs/src/usr.sbin/vidcontrol/vidcontrol.1,v retrieving revision 1.53 diff -u -p -r1.53 vidcontrol.1 --- usr.sbin/vidcontrol/vidcontrol.1 19 Aug 2002 16:33:23 -0000 1.53 +++ usr.sbin/vidcontrol/vidcontrol.1 26 Feb 2003 01:46:51 -0000 @@ -228,6 +228,10 @@ Turn vty switching on or off. When vty switching is off, attempts to switch to a different virtual terminal will fail. (The default is to permit vty switching.) +This protection can be easily bypassed when the kernel is compiled with +the DDB option. +However, you probably shouldn't compile the kernel debugger on a box which +is supposed to be physically secure. .It Fl s Ar number Set the current vty to .Ar number . --s2ZSL+KKDSLx8OML-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Mar 1 18:31:54 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BCDCE37B401 for ; Sat, 1 Mar 2003 18:30:54 -0800 (PST) Received: from mail.liwing.de (mail.liwing.de [213.70.188.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 54BE043FDF for ; Sat, 1 Mar 2003 18:30:52 -0800 (PST) (envelope-from rehsack@liwing.de) Received: (qmail 42899 invoked from network); 2 Mar 2003 02:30:51 -0000 Received: from stingray.liwing.de (HELO liwing.de) ([213.70.188.164]) (envelope-sender ) by mail.liwing.de (qmail-ldap-1.03) with SMTP for ; 2 Mar 2003 02:30:51 -0000 Message-ID: <3E616CDA.50808@liwing.de> Date: Sun, 02 Mar 2003 03:30:50 +0100 From: Jens Rehsack Organization: LiWing IT-Services User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-audit@freebsd.org Subject: patch for src/sbin/atm/ilmid/ilmid.c Content-Type: multipart/mixed; boundary="------------000108030408030604070306" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------000108030408030604070306 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, I played a little with some compiler optimizations and got an error message in src/sbin/atm/ilmid/ilmid.c: ===> sbin/atm/ilmid cc -O -O3 -fforce-addr -fforce-mem -msse -mmmx -m3dnow -momit-leaf-frame-pointer -fcse-follow-jumps -fcse-skip-blocks -fgcse -frerun-cse-after-loop -fstrength-reduce -fgcse-lm -fgcse-sm -frerun-loop-opt -fschedule-insns2 -pipe -DNO_WERROR -march=athlon-tbird -I/usr/src/sbin/atm/ilmid/../../../sys -Werror -Wall -Wno-format-y2k -Wno-uninitialized -c /usr/src/sbin/atm/ilmid/ilmid.c cc1: warnings being treated as errors In file included from /usr/src/sbin/atm/ilmid/ilmid.c:861: /usr/src/sbin/atm/ilmid/ilmid.c: In function `parse_oids': /usr/src/sbin/atm/ilmid/ilmid.c:456: warning: passing arg 0 of `asn_get_pdu_len' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:867: /usr/src/sbin/atm/ilmid/ilmid.c:659: warning: passing arg 0 of `asn_get_objid' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:872: /usr/src/sbin/atm/ilmid/ilmid.c:538: warning: passing arg 0 of `asn_get_int' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:879: /usr/src/sbin/atm/ilmid/ilmid.c:659: warning: passing arg 0 of `asn_get_objid' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:882: /usr/src/sbin/atm/ilmid/ilmid.c:737: warning: passing arg 0 of `asn_get_octet' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:2144: /usr/src/sbin/atm/ilmid/ilmid.c: In function `process_get': /usr/src/sbin/atm/ilmid/ilmid.c:1833: warning: passing arg 0 of `get_local_ip' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:2328: /usr/src/sbin/atm/ilmid/ilmid.c: In function `ilmi_do_state': /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:2384: /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type In file included from /usr/src/sbin/atm/ilmid/ilmid.c:2425: /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type /usr/src/sbin/atm/ilmid/ilmid.c:1074: warning: passing arg 0 of `oid_ncmp' from incompatible pointer type *** Error code 1 Stop in /usr/src/sbin/atm/ilmid. *** Error code 1 Stop in /usr/src/sbin/atm. *** Error code 1 I checked the messages and submit a patch to current@freebsd.org. I got some replies and all suggesting together appended result was coming out. I was told to send the 'final' patch (in context format) to audit for review. It would be nice to inform me about the further steps and time frames, because I submit sth. to the core distribution first time. Thanks for patience, Jens --------------000108030408030604070306 Content-Type: text/plain; name="patch-sbin_atm_ilmid_ilmid_c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-sbin_atm_ilmid_ilmid_c" *** sbin/atm/ilmid/ilmid.c.orig Sun Mar 2 00:30:57 2003 --- sbin/atm/ilmid/ilmid.c Sun Mar 2 01:45:06 2003 *************** *** 92,98 **** #define ASN_IPADDR 0x40 #define ASN_TIMESTAMP 0x43 ! static char *Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", "ASN_NULL", "ASN_OBJID" }; /* * Define SNMP PDU types --- 92,99 ---- #define ASN_IPADDR 0x40 #define ASN_TIMESTAMP 0x43 ! static const char * const Var_Types[] = { "", "", "ASN_INTEGER", "", "ASN_OCTET", ! "ASN_NULL", "ASN_OBJID" }; /* * Define SNMP PDU types *************** *** 103,110 **** #define PDU_TYPE_SET 0xA3 #define PDU_TYPE_TRAP 0xA4 ! static char *PDU_Types[] = { "GET REQUEST", "GETNEXT REQUEST", "GET RESPONSE", "SET REQUEST", ! "TRAP" }; /* * Define TRAP codes --- 104,111 ---- #define PDU_TYPE_SET 0xA3 #define PDU_TYPE_TRAP 0xA4 ! static const char * const PDU_Types[] = { "GET REQUEST", "GETNEXT REQUEST", ! "GET RESPONSE", "SET REQUEST", "TRAP" }; /* * Define TRAP codes *************** *** 162,168 **** union { int ival; /* INTEGER/TIMESTAMP */ Objid oval; /* OBJID */ ! long aval; /* IPADDR */ char sval[STRLEN]; /* OCTET */ } var; Variable *next; --- 163,169 ---- union { int ival; /* INTEGER/TIMESTAMP */ Objid oval; /* OBJID */ ! uint32_t aval; /* IPADDR */ char sval[STRLEN]; /* OCTET */ } var; Variable *next; *************** *** 173,182 **** * which doesn't have the last three fields is the TRAP type. */ struct snmp_header { ! int pdulen; ! int version; char community[64]; ! int pdutype; /* GET/GETNEXT/GETRESP/SET */ int reqid; --- 174,183 ---- * which doesn't have the last three fields is the TRAP type. */ struct snmp_header { ! uint32_t pdulen; ! uint32_t version; char community[64]; ! uint32_t pdutype; /* GET/GETNEXT/GETRESP/SET */ int reqid; *************** *** 185,195 **** /* TRAP */ Objid enterprise; ! int ipaddr; int generic_trap; int specific_trap; ! int varlen; Variable *head, *tail; }; --- 186,196 ---- /* TRAP */ Objid enterprise; ! uint32_t ipaddr; int generic_trap; int specific_trap; ! uint32_t varlen; Variable *head, *tail; }; *************** *** 210,216 **** * foresiggrp: FORE specific Objid we see alot of (being connected to FORE * switches...) */ ! Objid Objids[] = { #define SYS_OBJID 0 {{ 8, 43, 6, 1, 2, 1, 1, 2, 0 }}, #define UPTIME_OBJID 1 --- 211,217 ---- * foresiggrp: FORE specific Objid we see alot of (being connected to FORE * switches...) */ ! const Objid Objids[] = { #define SYS_OBJID 0 {{ 8, 43, 6, 1, 2, 1, 1, 2, 0 }}, #define UPTIME_OBJID 1 *************** *** 279,285 **** * Temporary buffer for building response packets. Should help ensure * that we aren't accidently overwriting some other memory. */ ! u_char Resp_Buf[1024]; /* * Copy the reponse into a buffer we can modify without --- 280,286 ---- * Temporary buffer for building response packets. Should help ensure * that we aren't accidently overwriting some other memory. */ ! char Resp_Buf[1024]; /* * Copy the reponse into a buffer we can modify without *************** *** 291,298 **** /* * TRAP generic trap types */ ! char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp", ! "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" }; --- 292,299 ---- /* * TRAP generic trap types */ ! const char *Traps[] = { "coldStart", "warmStart", "linkDown", "linkUp", ! "authenticationFailure", "egpNeighborLoss", "enterpriseSpecific" }; *************** *** 320,325 **** --- 321,329 ---- */ Objid addressEntry[MAX_UNITS + 1]; + static const char ilmi_ident_str[] = "ILMI"; + static const size_t ilmi_ident_str_len = strlen("ILMI"); + /* * When this daemon started */ *************** *** 335,345 **** #define LOG_FILE "/var/log/ilmid" FILE *Log; /* File descriptor for log messages */ ! void set_reqid( u_char *, int ); ! void Increment_DL( int ); ! void Decrement_DL( int ); ! static char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; /* --- 339,349 ---- #define LOG_FILE "/var/log/ilmid" FILE *Log; /* File descriptor for log messages */ ! static void set_reqid( char *, uint32_t ); ! static void Increment_DL( int ); ! static void Decrement_DL( int ); ! static const char *Months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; /* *************** *** 355,368 **** * none * */ ! void ! write_timestamp() { ! time_t clock; struct tm *tm; ! clock = time ( (time_t)NULL ); ! tm = localtime ( &clock ); if ( Log && Debug_Level > 1 ) if ( Log != stderr ) --- 359,372 ---- * none * */ ! static void ! write_timestamp(void) { ! time_t cur_clock; struct tm *tm; ! cur_clock = time ( NULL ); ! tm = localtime ( &cur_clock ); if ( Log && Debug_Level > 1 ) if ( Log != stderr ) *************** *** 385,396 **** * none * */ ! void ! hexdump ( bp, len ) ! u_char *bp; ! int len; { ! int i, j; /* * Print as 4 groups of four bytes. Each byte is separated --- 389,398 ---- * none * */ ! static void ! hexdump ( const char *bp, const uint32_t len ) { ! uint32_t i, j; /* * Print as 4 groups of four bytes. Each byte is separated *************** *** 449,471 **** * - decoded length * */ ! int ! asn_get_pdu_len ( bufp, plen ) ! u_char **bufp; ! int *plen; ! { ! u_char *bp = *bufp; ! int len = 0; ! int i, b; b = *bp++; if ( plen ) ! (*plen)--; ! if ( b & 0x80 ) { ! for ( i = 0; i < (b & ~0x80); i++ ) { len = len * 256 + *bp++; if ( plen ) ! (*plen)--; } } else len = b; --- 451,471 ---- * - decoded length * */ ! static int ! asn_get_pdu_len ( const char ** const bufp, uint32_t * const plen ) ! { ! const char *bp = *bufp; ! uint32_t len = 0; ! uint32_t i, b; b = *bp++; if ( plen ) ! --(*plen); ! if ( b & 0x80 ) { ! for ( i = 0; i < (b & ~0x80); ++i ) { len = len * 256 + *bp++; if ( plen ) ! --(*plen); } } else len = b; *************** *** 490,503 **** * - value encoding represented * */ ! int ! asn_get_encoded ( bufp, len ) ! u_char **bufp; ! int *len; ! { ! u_char *bp = *bufp; ! int val = 0; ! int l = *len; /* * Keep going while high bit is set --- 490,501 ---- * - value encoding represented * */ ! static int ! asn_get_encoded ( const char ** const bufp, uint32_t * const len ) ! { ! const char *bp = *bufp; ! int val = 0; /* FIXME: signed? sure? */ ! uint32_t l = *len; /* * Keep going while high bit is set *************** *** 507,513 **** * Each byte can represent 7 bits */ val = ( val << 7 ) + ( *bp & ~0x80 ); ! l--; } while ( *bp++ & 0x80 ); *bufp = bp; /* update buffer pointer */ --- 505,511 ---- * Each byte can represent 7 bits */ val = ( val << 7 ) + ( *bp & ~0x80 ); ! --l; } while ( *bp++ & 0x80 ); *bufp = bp; /* update buffer pointer */ *************** *** 531,553 **** * - value of encoded integer * */ ! int ! asn_get_int ( bufp, plen ) ! u_char **bufp; ! int *plen; { ! int i; ! int len; ! int v = 0; ! u_char *bp = *bufp; len = *bp++; if ( plen ) ! (*plen)--; ! for ( i = 0; i < len; i++ ) { v = (v * 256) + *bp++; if ( plen ) ! (*plen)--; } *bufp = bp; return ( v ); --- 529,549 ---- * - value of encoded integer * */ ! static int ! asn_get_int ( const char ** const bufp, uint32_t * const plen ) { ! uint32_t i; ! uint32_t len; ! int v = 0; ! const char *bp = *bufp; len = *bp++; if ( plen ) ! --(*plen); ! for ( i = 0; i < len; ++i ) { v = (v * 256) + *bp++; if ( plen ) ! --(*plen); } *bufp = bp; return ( v ); *************** *** 565,582 **** * - updated buffer pointer * */ ! void ! asn_set_int ( bufp, val ) ! u_char **bufp; ! int val; { union { ! int i; ! u_char c[4]; } u; ! int len = sizeof(int); ! int i = 0; ! u_char *bp = *bufp; /* Check for special case where val == 0 */ if ( val == 0 ) { --- 561,576 ---- * - updated buffer pointer * */ ! static void ! asn_set_int ( char **bufp, const uint32_t val ) { union { ! uint32_t i; ! u_char c[sizeof(uint32_t)]; } u; ! uint32_t len = sizeof(uint32_t); ! uint32_t i = 0; ! char *bp = *bufp; /* Check for special case where val == 0 */ if ( val == 0 ) { *************** *** 588,603 **** u.i = htonl ( val ); ! while ( u.c[i] == 0 && i++ < sizeof(int) ) ! len--; if ( u.c[i] > 0x7f ) { ! i--; ! len++; } ! *bp++ = len; ! bcopy ( (caddr_t)&u.c[sizeof(int)-len], bp, len ); bp += len; *bufp = bp; --- 582,597 ---- u.i = htonl ( val ); ! while ( u.c[i] == 0 && ++i < sizeof(u.i) ) /* 'i++ < x' increases x even if increase break bounds */ ! --len; if ( u.c[i] > 0x7f ) { ! --i; ! ++len; } ! *bp++ = (char)len; ! bcopy ( &u.c[sizeof(u.i)-len], bp, len ); bp += len; *bufp = bp; *************** *** 614,624 **** * none * */ ! void ! print_objid ( objid ) ! Objid *objid; { ! int i; /* * First oid coded as 40 * X + Y --- 608,617 ---- * none * */ ! static void ! print_objid ( const Objid * const objid ) { ! uint32_t i, cmp = objid->oid[0]; /* * First oid coded as 40 * X + Y *************** *** 628,634 **** fprintf ( Log, ".%d.%d", objid->oid[1] / 40, objid->oid[1] % 40 ); } ! for ( i = 2; i <= objid->oid[0]; i++ ) if ( Log ) fprintf ( Log, ".%d", objid->oid[i] ); if ( Log ) --- 621,627 ---- fprintf ( Log, ".%d.%d", objid->oid[1] / 40, objid->oid[1] % 40 ); } ! for ( i = 2; i <= cmp; ++i ) if ( Log ) fprintf ( Log, ".%d", objid->oid[i] ); if ( Log ) *************** *** 651,675 **** * plen - (possibly) adjusted PDU length * */ ! void ! asn_get_objid ( bufp, objid, plen ) ! u_char **bufp; ! Objid *objid; ! int *plen; ! { ! int len; ! u_char *bp = *bufp; ! int *ip = (int *)objid + 1; /* First byte will contain length */ ! int oidlen = 0; len = *bp++; if ( plen ) ! (*plen)--; while ( len ) { *ip++ = asn_get_encoded ( &bp, &len ); if ( plen ) ! (*plen)--; ! oidlen++; } objid->oid[0] = oidlen; *bufp = bp; --- 644,665 ---- * plen - (possibly) adjusted PDU length * */ ! static void ! asn_get_objid ( const char **bufp, Objid * const objid, uint32_t * const plen ) ! { ! uint32_t len; ! const char *bp = *bufp; ! int *ip = (int *)objid + 1; /* First byte will contain length */ /* FIXME: first byte or first word? */ ! uint32_t oidlen = 0; len = *bp++; if ( plen ) ! --(*plen); while ( len ) { *ip++ = asn_get_encoded ( &bp, &len ); if ( plen ) ! --(*plen); ! ++oidlen; } objid->oid[0] = oidlen; *bufp = bp; *************** *** 681,710 **** * Put OBJID - assumes elements <= 16383 for two byte coding * */ ! int ! asn_put_objid ( bufp, objid ) ! u_char **bufp; ! Objid *objid; ! { ! int len = 0; ! u_char *bp = *bufp; ! u_char *cpp; ! int i; cpp = bp; *bp++ = objid->oid[0]; ! len++; ! for ( i = 1; i <= objid->oid[0]; i++ ) { ! u_int c = objid->oid[i]; while ( c > 127 ) { *bp++ = ( ( c >> 7 ) & 0x7f ) | 0x80; ! len++; c &= 0x7f; /* XXX - assumption of two bytes */ ! (*cpp)++; } *bp++ = c; ! len++; } *bufp = bp; --- 671,699 ---- * Put OBJID - assumes elements <= 16383 for two byte coding * */ ! static int ! asn_put_objid ( char **bufp, const Objid * const objid ) ! { ! uint32_t len = 0; ! char *bp = *bufp; ! char *cpp; ! uint32_t i; ! const uint32_t oidlen = objid->oid[0]; cpp = bp; *bp++ = objid->oid[0]; ! ++len; ! for ( i = 1; i <= oidlen; ++i ) { /* FIXME: objid->oid[0] can be greater than 128 which is sizeof(objid->oid) */ ! unsigned char c = objid->oid[i]; while ( c > 127 ) { *bp++ = ( ( c >> 7 ) & 0x7f ) | 0x80; ! ++len; c &= 0x7f; /* XXX - assumption of two bytes */ ! ++(*cpp); } *bp++ = c; ! ++len; } *bufp = bp; *************** *** 729,754 **** * plen - (possibly) adjusted PDU length * */ ! void ! asn_get_octet ( bufp, octet, plen ) ! u_char **bufp; ! char *octet; ! int *plen; ! { ! u_char *bp = *bufp; ! int i = 0; ! int len = 0; /* * &i is really a dummy value here as we don't keep track * of the ongoing buffer length */ ! len = asn_get_encoded ( &bp, &i, plen ); ! for ( i = 0; i < len; i++ ) { *octet++ = *bp++; if ( plen ) ! (*plen)--; } *bufp = bp; --- 718,740 ---- * plen - (possibly) adjusted PDU length * */ ! static void ! asn_get_octet ( const char ** const bufp, char *octet, uint32_t * const plen ) ! { ! const char *bp = *bufp; ! uint32_t i = 0; ! uint32_t len = 0; /* * &i is really a dummy value here as we don't keep track * of the ongoing buffer length */ ! len = (uint32_t)asn_get_encoded ( &bp, &i /* FIXME: what's that? , plen */ ); ! for ( i = 0; i < len; ++i ) { *octet++ = *bp++; if ( plen ) ! --(*plen); } *bufp = bp; *************** *** 767,777 **** * none * */ ! void ! print_header ( Hdr ) ! Snmp_Header *Hdr; { ! Variable *var; if ( Log ) { write_timestamp(); --- 753,762 ---- * none * */ ! static void ! print_header ( const Snmp_Header * const Hdr ) { ! const Variable *var; if ( Log ) { write_timestamp(); *************** *** 826,852 **** * none * */ ! void ! parse_oids ( h, bp ) ! Snmp_Header *h; ! caddr_t *bp; { ! int len = h->varlen; ! int sublen; Variable *var; ! caddr_t bufp = *bp; while ( len > 0 ) { if ( *bufp++ == ASN_SEQUENCE ) { ! len--; /* Create new Variable instance */ ! if ( ( var = (Variable *)malloc(sizeof(Variable)) ) == NULL ) { *bp = bufp; return; } ! bzero(var, sizeof(Variable)); /* Link to tail */ if ( h->tail ) h->tail->next = var; --- 811,835 ---- * none * */ ! static void ! parse_oids ( Snmp_Header * const h, const char ** const bp ) { ! uint32_t len = h->varlen; ! uint32_t sublen; Variable *var; ! const char *bufp = *bp; while ( len > 0 ) { if ( *bufp++ == ASN_SEQUENCE ) { ! --len; /* Create new Variable instance */ ! if ( ( var = malloc(sizeof(*var)) ) == NULL ) { *bp = bufp; return; } ! bzero(var, sizeof(*var)); /* Link to tail */ if ( h->tail ) h->tail->next = var; *************** *** 872,879 **** var->var.ival = asn_get_int ( &bufp, &len ); break; case ASN_NULL: ! bufp++; ! len--; break; case ASN_OBJID: asn_get_objid ( &bufp, &var->var.oval, &len ); --- 855,862 ---- var->var.ival = asn_get_int ( &bufp, &len ); break; case ASN_NULL: ! ++bufp; ! --len; break; case ASN_OBJID: asn_get_objid ( &bufp, &var->var.oval, &len ); *************** *** 913,937 **** * - generated SNMP header * */ ! Snmp_Header * ! asn_get_header ( bufp ) ! u_char **bufp; { Snmp_Header *h; ! u_char *bp = *bufp; ! int len = 0; ! int dummy = 0; /* * Allocate memory to hold the SNMP header */ ! if ( ( h = (Snmp_Header *)malloc(sizeof(Snmp_Header)) ) == NULL ) return ( (Snmp_Header *)NULL ); /* * Ensure that we wipe the slate clean */ ! bzero(h, sizeof(Snmp_Header)); /* * PDU has to start as SEQUENCE OF --- 896,921 ---- * - generated SNMP header * */ ! static Snmp_Header * ! asn_get_header ( const char **bufp ) { Snmp_Header *h; ! const char *bp = *bufp; ! uint32_t len = 0; ! /* ! uint32_t dummy = 0; ! */ /* * Allocate memory to hold the SNMP header */ ! if ( ( h = malloc(sizeof(*h)) ) == NULL ) /* void * matches any pointer type */ return ( (Snmp_Header *)NULL ); /* * Ensure that we wipe the slate clean */ ! bzero(h, sizeof(*h)); /* * PDU has to start as SEQUENCE OF *************** *** 970,976 **** */ if ( h->pdutype != PDU_TYPE_TRAP ) { /* TRAP uses different format */ ! (void) asn_get_pdu_len ( &bp, &dummy ); /* Request ID */ if ( *bp++ != ASN_INTEGER ) { --- 954,960 ---- */ if ( h->pdutype != PDU_TYPE_TRAP ) { /* TRAP uses different format */ ! (void) asn_get_pdu_len ( &bp, NULL ); /* &dummy -> NULL */ /* Request ID */ if ( *bp++ != ASN_INTEGER ) { *************** *** 1025,1041 **** * 1 - Objid's don't match * */ ! int ! oid_cmp ( oid1, oid2 ) ! Objid *oid1, *oid2; { ! int i; ! int len; /* * Compare lengths */ ! if ( !(oid1->oid[0] == oid2->oid[0] ) ) /* Different lengths */ return ( 1 ); --- 1009,1024 ---- * 1 - Objid's don't match * */ ! static int ! oid_cmp ( const Objid * const oid1, const Objid * const oid2 ) { ! uint32_t i; ! uint32_t len; /* * Compare lengths */ ! if ( !(oid1->oid[0] == oid2->oid[0] ) ) /* FIXME: how about if( oid1->oid[0] != oid2->oid[0] ) */ /* Different lengths */ return ( 1 ); *************** *** 1067,1078 **** * 1 - Objid's don't match * */ ! int ! oid_ncmp ( oid1, oid2, len ) ! Objid *oid1, *oid2; ! int len; { ! int i; /* * value by value compare --- 1050,1059 ---- * 1 - Objid's don't match * */ ! static int ! oid_ncmp ( const Objid * const oid1, const Objid * const oid2, const uint32_t len ) { ! uint32_t i; /* * value by value compare *************** *** 1098,1108 **** * -1 - no matching Variable found * */ ! int ! find_var ( var ) ! Variable *var; { ! int i; for ( i = 0; i < NUM_OIDS; i++ ) if ( oid_cmp ( &var->oid, &Objids[i] ) == 0 ) { --- 1079,1088 ---- * -1 - no matching Variable found * */ ! static int ! find_var ( const Variable * const var ) { ! size_t i; for ( i = 0; i < NUM_OIDS; i++ ) if ( oid_cmp ( &var->oid, &Objids[i] ) == 0 ) { *************** *** 1167,1185 **** * none * */ ! void ! build_pdu ( hdr, type ) ! Snmp_Header *hdr; ! int type; { ! u_char *bp = Resp_Buf; ! u_char *vpp; ! u_char *ppp; int erridx = 0; int varidx = 1; ! int varlen = 0; ! int pdulen = 0; ! int traplen = 0; Variable *var; /* --- 1147,1163 ---- * none * */ ! static void ! build_pdu ( Snmp_Header * const hdr, const int type ) { ! char *bp = Resp_Buf; ! char *vpp; ! char *ppp; int erridx = 0; int varidx = 1; ! uint32_t varlen = 0; ! uint32_t pdulen = 0; ! uint32_t traplen = 0; Variable *var; /* *************** *** 1188,1201 **** bzero ( Resp_Buf, sizeof(Resp_Buf) ); /* [0] is reserved for overall length */ ! bp++; /* Start with SEQUENCE OF */ *bp++ = ASN_SEQUENCE; /* - assume we can code length in two octets */ ! *bp++ = 0x82; ! bp++; ! bp++; /* Version */ *bp++ = ASN_INTEGER; asn_set_int ( &bp, hdr->version ); --- 1166,1179 ---- bzero ( Resp_Buf, sizeof(Resp_Buf) ); /* [0] is reserved for overall length */ ! ++bp; /* Start with SEQUENCE OF */ *bp++ = ASN_SEQUENCE; /* - assume we can code length in two octets */ ! *bp++ = (unsigned char)0x82; ! ++bp; ! ++bp; /* Version */ *bp++ = ASN_INTEGER; asn_set_int ( &bp, hdr->version ); *************** *** 1208,1214 **** *bp++ = type; ppp = bp; /* Length of OID data - assume it'll fit in one octet */ ! bp++; if ( type != PDU_TYPE_TRAP ) { /* Sequence ID */ --- 1186,1192 ---- *bp++ = type; ppp = bp; /* Length of OID data - assume it'll fit in one octet */ ! ++bp; if ( type != PDU_TYPE_TRAP ) { /* Sequence ID */ *************** *** 1250,1256 **** /* Fill in IP address */ *bp++ = ASN_IPADDR; *bp++ = sizeof ( hdr->ipaddr ); ! bcopy ( (caddr_t)&hdr->ipaddr, bp, sizeof(hdr->ipaddr) ); bp += sizeof(hdr->ipaddr); /* Fill in generic and specific trap types */ --- 1228,1234 ---- /* Fill in IP address */ *bp++ = ASN_IPADDR; *bp++ = sizeof ( hdr->ipaddr ); ! bcopy ( &hdr->ipaddr, bp, sizeof(hdr->ipaddr) ); bp += sizeof(hdr->ipaddr); /* Fill in generic and specific trap types */ *************** *** 1271,1314 **** /* SEQUENCE OF */ *bp++ = ASN_SEQUENCE; ! *bp++ = 0x82; /* - assume we can code length in two octets */ vpp = bp; varlen = 0; ! bp++; ! bp++; /* Install Variables */ var = hdr->head; varidx = 1; while ( var ) { ! u_char *bpp; ! int len = 0; /* SEQUENCE OF */ *bp++ = ASN_SEQUENCE; ! *bp++ = 0x82; /* - assume we can code length in two octets */ bpp = bp; ! bp++; ! bp++; /* OBJID */ *bp++ = ASN_OBJID; ! len++; len += asn_put_objid ( &bp, &var->oid ); if ( erridx && varidx >= erridx ) { /* Code this variable as NULL */ *bp++ = ASN_NULL; ! len++; ! bp++; ! len++; } else { ! u_char *lpp; /* Variable type */ *bp++ = var->type; ! len++; lpp = bp; switch ( var->type ) { case ASN_INTEGER: --- 1249,1292 ---- /* SEQUENCE OF */ *bp++ = ASN_SEQUENCE; ! *bp++ = (unsigned char)0x82; /* - assume we can code length in two octets */ vpp = bp; varlen = 0; ! ++bp; ! ++bp; /* Install Variables */ var = hdr->head; varidx = 1; while ( var ) { ! char *bpp; ! uint32_t len = 0; /* SEQUENCE OF */ *bp++ = ASN_SEQUENCE; ! *bp++ = (unsigned char)0x82; /* - assume we can code length in two octets */ bpp = bp; ! ++bp; ! ++bp; /* OBJID */ *bp++ = ASN_OBJID; ! ++len; len += asn_put_objid ( &bp, &var->oid ); if ( erridx && varidx >= erridx ) { /* Code this variable as NULL */ *bp++ = ASN_NULL; ! ++len; ! ++bp; ! ++len; } else { ! char *lpp; /* Variable type */ *bp++ = var->type; ! ++len; lpp = bp; switch ( var->type ) { case ASN_INTEGER: *************** *** 1317,1331 **** break; case ASN_OCTET: *bp++ = var->var.sval[0]; ! len++; ! bcopy ( (caddr_t)&var->var.sval[1], bp, var->var.sval[0] ); len += var->var.sval[0]; bp += var->var.sval[0]; break; case ASN_NULL: *bp++ = 0x00; ! len++; break; case ASN_OBJID: len += asn_put_objid ( &bp, &var->var.oval ); --- 1295,1309 ---- break; case ASN_OCTET: *bp++ = var->var.sval[0]; ! ++len; ! bcopy ( &var->var.sval[1], bp, var->var.sval[0] ); len += var->var.sval[0]; bp += var->var.sval[0]; break; case ASN_NULL: *bp++ = 0x00; ! ++len; break; case ASN_OBJID: len += asn_put_objid ( &bp, &var->var.oval ); *************** *** 1333,1343 **** case ASN_SEQUENCE: break; case ASN_IPADDR: ! *bp++ = 4; ! len++; ! bcopy ( (caddr_t)&var->var.aval, bp, 4 ); ! len += 4; ! bp += 4; break; case ASN_TIMESTAMP: asn_set_int ( &bp, var->var.ival ); --- 1311,1321 ---- case ASN_SEQUENCE: break; case ASN_IPADDR: ! *bp++ = sizeof(var->var.aval); ! ++len; ! bcopy ( &var->var.aval, bp, sizeof(var->var.aval) ); ! len += sizeof(var->var.aval); ! bp += sizeof(var->var.aval); break; case ASN_TIMESTAMP: asn_set_int ( &bp, var->var.ival ); *************** *** 1349,1355 **** } /* Accumulate total Variable sequence length */ ! varlen += (len + 4); /* Fill in length of this sequence */ bpp[1] = len & 0xff; --- 1327,1333 ---- } /* Accumulate total Variable sequence length */ ! varlen += (len + 4); /* FIXME: why 4? is it sizeof(var->var.aval) */ /* Fill in length of this sequence */ bpp[1] = len & 0xff; *************** *** 1385,1402 **** return; } ! void ! free_pdu ( hdr ) ! Snmp_Header *hdr; { ! Variable *var; ! while ( hdr->head ) { ! var = hdr->head->next; /* Save next link */ ! free ( hdr->head ); /* Free current var */ ! hdr->head = var; /* Set head to next link */ } free ( hdr ); /* Free fixed portion */ } --- 1363,1380 ---- return; } ! static void ! free_pdu ( Snmp_Header *hdr ) { ! Variable *var = hdr->head, *var_next; ! while ( var ) { ! var_next = var->next; /* Save next link */ ! free ( var ); /* Free current var */ ! var_next = var; /* Set head to saved next link */ } + hdr->head = NULL; free ( hdr ); /* Free fixed portion */ } *************** *** 1411,1439 **** * none - request id may/may not be set * */ ! void ! set_reqid ( resp, reqid ) ! u_char *resp; ! int reqid; { ! u_char *bp = (u_char *)&resp[18]; union { ! int i; ! u_char c[4]; } u; ! u.i = htonl(reqid); /* * Replace the current Request ID with the supplied value */ ! bcopy ( (caddr_t)&u.c[4-resp[17]], bp, resp[17] ); return; } /* ! * Send a generic response packet * * Arguments: * sd - socket to send the reply on --- 1389,1415 ---- * none - request id may/may not be set * */ ! static void ! set_reqid ( char *resp, uint32_t reqid ) { ! char *bp = resp+18; union { ! uint32_t i; ! char c[sizeof(uint32_t)]; } u; ! u.i = htonl( reqid ); /* * Replace the current Request ID with the supplied value */ ! bcopy ( &u.c[4-resp[17]], bp, resp[17] ); return; } /* ! * Send a generic response packet - FIXME: documentation doesn't match declaration * * Arguments: * sd - socket to send the reply on *************** *** 1444,1465 **** * none - response sent * */ ! void ! send_resp ( intf, Hdr, resp ) ! int intf; ! Snmp_Header *Hdr; ! u_char *resp; { int n; ! if ( ilmi_fd[intf] > 0 ) { ! n = write ( ilmi_fd[intf], (caddr_t)&resp[1], resp[0] ); if ( Log && Debug_Level > 1 ) { write_timestamp(); fprintf ( Log, "===== Sent %d of %d bytes (%d) =====\n", n, resp[0], ilmi_fd[intf] ); print_header ( Hdr ); if ( Debug_Level > 2 ) ! hexdump ( (u_char *)&resp[1], resp[0] ); } } --- 1420,1438 ---- * none - response sent * */ ! static void ! send_resp ( const int intf, Snmp_Header *Hdr, unsigned char *resp ) { int n; ! if ( ilmi_fd[intf] > 0 ) { /* FIXME: does ilmi_fd[intf] exists? out of range? */ ! n = write ( ilmi_fd[intf], resp+1, resp[0] ); if ( Log && Debug_Level > 1 ) { write_timestamp(); fprintf ( Log, "===== Sent %d of %d bytes (%d) =====\n", n, resp[0], ilmi_fd[intf] ); print_header ( Hdr ); if ( Debug_Level > 2 ) ! hexdump ( &resp[1], resp[0] ); } } *************** *** 1471,1509 **** * Build a COLD_START TRAP PDU * */ ! Snmp_Header * ! build_cold_start() { Snmp_Header *hdr; Variable *var; ! hdr = (Snmp_Header *)malloc(sizeof(Snmp_Header)); if (hdr == NULL) { ! fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(hdr, sizeof(Snmp_Header)); hdr->pdulen = 0; hdr->version = SNMP_VERSION_1 - 1; ! snprintf ( hdr->community, sizeof(hdr->community), "ILMI" ); ! hdr->ipaddr = 0x0; /* 0.0.0.0 */ hdr->generic_trap = TRAP_COLDSTART; ! hdr->specific_trap = 0; ! bcopy ( (caddr_t)&Objids[ENTERPRISE_OBJID], (caddr_t)&hdr->enterprise, sizeof(Objid) ); ! hdr->head = (Variable *)malloc(sizeof(Variable)); ! if (hdr == NULL) { ! fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(hdr->head, sizeof(Variable)); var = hdr->head; ! bcopy ( (caddr_t)&Objids[UPTIME_OBJID], (caddr_t)&var->oid, ! sizeof(Objid) ); var->type = ASN_NULL; return ( hdr ); --- 1444,1483 ---- * Build a COLD_START TRAP PDU * */ ! static Snmp_Header * ! build_cold_start(void) { Snmp_Header *hdr; Variable *var; ! hdr = malloc(sizeof(*hdr)); if (hdr == NULL) { ! fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } ! bzero(hdr, sizeof(*hdr)); + /* FIXME: bzero has done that hdr->pdulen = 0; + */ hdr->version = SNMP_VERSION_1 - 1; ! snprintf ( hdr->community, ilmi_ident_str_len, ilmi_ident_str ); ! /* FIXME: bzero: hdr->ipaddr = 0x0; */ /* 0.0.0.0 */ hdr->generic_trap = TRAP_COLDSTART; ! /* FIXME: bzero: hdr->specific_trap = 0; */ ! bcopy ( &Objids[ENTERPRISE_OBJID], &hdr->enterprise, sizeof(Objid) ); ! hdr->head = malloc(sizeof(*hdr->head)); ! if (hdr->head == NULL) { ! fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } ! bzero(hdr->head, sizeof(*hdr->head)); var = hdr->head; ! bcopy ( &Objids[UPTIME_OBJID], &var->oid, sizeof(var->oid) ); var->type = ASN_NULL; return ( hdr ); *************** *** 1513,1533 **** * Build a Generic PDU Header * */ ! Snmp_Header * ! build_generic_header() { Snmp_Header *hdr; ! hdr = (Snmp_Header *)malloc(sizeof(Snmp_Header)); if (hdr == NULL) { fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(hdr, sizeof(Snmp_Header)); ! hdr->pdulen = 0; hdr->version = SNMP_VERSION_1 - 1; ! snprintf ( hdr->community, sizeof(hdr->community), "ILMI" ); return ( hdr ); } --- 1487,1507 ---- * Build a Generic PDU Header * */ ! static Snmp_Header * ! build_generic_header( void ) { Snmp_Header *hdr; ! hdr = malloc(sizeof(*hdr)); if (hdr == NULL) { fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(hdr, sizeof(*hdr)); ! /* FIXME: bzero: hdr->pdulen = 0; */ hdr->version = SNMP_VERSION_1 - 1; ! snprintf ( hdr->community, ilmi_ident_str_len, ilmi_ident_str ); return ( hdr ); } *************** *** 1546,1557 **** * none Information from HARP available * */ ! void ! init_ilmi() { ! struct air_cfg_rsp *cfg_info = NULL; ! struct air_int_rsp *intf_info = NULL; ! int buf_len; /* * Get configuration info - what's available with 'atm sh config' --- 1520,1531 ---- * none Information from HARP available * */ ! static void ! init_ilmi(void) { ! struct air_cfg_rsp *cfg_info = NULL; ! struct air_int_rsp *intf_info = NULL; ! int buf_len; /* * Get configuration info - what's available with 'atm sh config' *************** *** 1562,1568 **** */ if ( buf_len <= 0 ) { bzero ( Cfg, sizeof(Cfg) ); ! bzero( Intf, sizeof(Intf) ); NUnits = 0; return; } --- 1536,1542 ---- */ if ( buf_len <= 0 ) { bzero ( Cfg, sizeof(Cfg) ); ! bzero ( Intf, sizeof(Intf) ); NUnits = 0; return; } *************** *** 1570,1580 **** /* * Move to local storage */ ! bcopy ( cfg_info, (caddr_t)Cfg, buf_len ); /* * Compute how many units information was returned for */ ! NUnits = buf_len / sizeof(struct air_cfg_rsp); /* Housecleaning */ free ( cfg_info ); cfg_info = NULL; --- 1544,1554 ---- /* * Move to local storage */ ! bcopy ( cfg_info, Cfg, buf_len ); /* * Compute how many units information was returned for */ ! NUnits = buf_len / sizeof(*cfg_info); /* Housecleaning */ free ( cfg_info ); cfg_info = NULL; *************** *** 1593,1599 **** /* * Move to local storage */ ! bcopy ( intf_info, (caddr_t)Intf, buf_len ); /* Housecleaning */ free ( intf_info ); intf_info = NULL; --- 1567,1573 ---- /* * Move to local storage */ ! bcopy ( intf_info, Intf, buf_len ); /* Housecleaning */ free ( intf_info ); intf_info = NULL; *************** *** 1617,1647 **** * none * */ ! void ! ilmi_open () { ! struct sockaddr_atm satm; ! struct t_atm_aal5 aal5; ! struct t_atm_traffic traffic; ! struct t_atm_bearer bearer; ! struct t_atm_qos qos; struct t_atm_app_name appname; ! Atm_addr subaddr; ! char nifname[IFNAMSIZ]; ! int optlen; ! int unit = 0; u_char sig_proto; init_ilmi(); ! for ( unit = 0; unit < NUnits; unit++ ) { /* * ILMI only makes sense for UNI signalling protocols */ sig_proto = Intf[unit].anp_sig_proto; if ( sig_proto != ATM_SIG_UNI30 && sig_proto != ATM_SIG_UNI31 && ! sig_proto != ATM_SIG_UNI40 ) continue; if ( ilmi_fd[unit] == -1 ) { --- 1591,1621 ---- * none * */ ! static void ! ilmi_open (void) { ! struct sockaddr_atm satm; ! struct t_atm_aal5 aal5; ! struct t_atm_traffic traffic; ! struct t_atm_bearer bearer; ! struct t_atm_qos qos; struct t_atm_app_name appname; ! Atm_addr subaddr; ! char nifname[IFNAMSIZ]; ! socklen_t optlen; ! int unit = 0; u_char sig_proto; init_ilmi(); ! for ( unit = 0; unit < NUnits; ++unit ) { /* * ILMI only makes sense for UNI signalling protocols */ sig_proto = Intf[unit].anp_sig_proto; if ( sig_proto != ATM_SIG_UNI30 && sig_proto != ATM_SIG_UNI31 && ! sig_proto != ATM_SIG_UNI40 ) continue; if ( ilmi_fd[unit] == -1 ) { *************** *** 1668,1674 **** sprintf ( nifname, "%s0", Intf[unit].anp_nif_pref ); optlen = sizeof ( nifname ); if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING, ! T_ATM_NET_INTF, (caddr_t)nifname, optlen ) < 0 ) { perror ( "setsockopt" ); if ( Log ) { write_timestamp(); --- 1642,1648 ---- sprintf ( nifname, "%s0", Intf[unit].anp_nif_pref ); optlen = sizeof ( nifname ); if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING, ! T_ATM_NET_INTF, (char *)nifname, optlen ) < 0 ) { perror ( "setsockopt" ); if ( Log ) { write_timestamp(); *************** *** 1688,1694 **** /* * Set up destination SAP */ ! bzero ( (caddr_t) &satm, sizeof(satm) ); satm.satm_family = AF_ATM; #if (defined(BSD) && (BSD >= 199103)) satm.satm_len = sizeof(satm); --- 1662,1668 ---- /* * Set up destination SAP */ ! bzero ( &satm, sizeof(satm) ); satm.satm_family = AF_ATM; #if (defined(BSD) && (BSD >= 199103)) satm.satm_len = sizeof(satm); *************** *** 1719,1725 **** aal5.SSCS_type = T_ATM_NULL; optlen = sizeof(aal5); if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_AAL5, ! (caddr_t) &aal5, optlen ) < 0 ) { perror ( "setsockopt(aal5)" ); if ( Debug_Level > 1 && Log ) { write_timestamp(); --- 1693,1699 ---- aal5.SSCS_type = T_ATM_NULL; optlen = sizeof(aal5); if ( setsockopt ( ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_AAL5, ! (char *) &aal5, optlen ) < 0 ) { perror ( "setsockopt(aal5)" ); if ( Debug_Level > 1 && Log ) { write_timestamp(); *************** *** 1747,1753 **** traffic.best_effort = T_YES; optlen = sizeof(traffic); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_TRAFFIC, ! (caddr_t)&traffic, optlen) < 0) { perror("setsockopt(traffic)"); } bearer.bearer_class = T_ATM_CLASS_X; --- 1721,1727 ---- traffic.best_effort = T_YES; optlen = sizeof(traffic); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_TRAFFIC, ! &traffic, optlen) < 0) { perror("setsockopt(traffic)"); } bearer.bearer_class = T_ATM_CLASS_X; *************** *** 1757,1763 **** bearer.connection_configuration = T_ATM_1_TO_1; optlen = sizeof(bearer); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_BEARER_CAP, ! (caddr_t)&bearer, optlen) < 0) { perror("setsockopt(bearer)"); } --- 1731,1737 ---- bearer.connection_configuration = T_ATM_1_TO_1; optlen = sizeof(bearer); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_BEARER_CAP, ! &bearer, optlen) < 0) { perror("setsockopt(bearer)"); } *************** *** 1765,1771 **** qos.forward.qos_class = T_ATM_QOS_CLASS_0; qos.backward.qos_class = T_ATM_QOS_CLASS_0; optlen = sizeof(qos); ! if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_QOS, (caddr_t)&qos, optlen) < 0) { perror("setsockopt(qos)"); } --- 1739,1745 ---- qos.forward.qos_class = T_ATM_QOS_CLASS_0; qos.backward.qos_class = T_ATM_QOS_CLASS_0; optlen = sizeof(qos); ! if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_QOS, &qos, optlen) < 0) { perror("setsockopt(qos)"); } *************** *** 1774,1787 **** subaddr.address_length = 0; optlen = sizeof(subaddr); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_DEST_SUB, ! (caddr_t)&subaddr, optlen) < 0) { perror("setsockopt(dest_sub)"); } strncpy(appname.app_name, "ILMI", T_ATM_APP_NAME_LEN); optlen = sizeof(appname); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_APP_NAME, ! (caddr_t)&appname, optlen) < 0) { perror("setsockopt(appname)"); } --- 1748,1761 ---- subaddr.address_length = 0; optlen = sizeof(subaddr); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_DEST_SUB, ! &subaddr, optlen) < 0) { perror("setsockopt(dest_sub)"); } strncpy(appname.app_name, "ILMI", T_ATM_APP_NAME_LEN); optlen = sizeof(appname); if (setsockopt(ilmi_fd[unit], T_ATM_SIGNALING, T_ATM_APP_NAME, ! &appname, optlen) < 0) { perror("setsockopt(appname)"); } *************** *** 1826,1846 **** * none * */ ! void ! get_local_ip ( s, aval ) ! int s; ! long *aval; { char intf_name[IFNAMSIZ]; ! int namelen = IFNAMSIZ; struct air_netif_rsp *net_info = NULL; ! struct sockaddr_in *sin; /* * Get physical interface name */ if ( getsockopt ( s, T_ATM_SIGNALING, T_ATM_NET_INTF, ! (caddr_t) intf_name, &namelen ) ) return; /* --- 1800,1818 ---- * none * */ ! static void ! get_local_ip ( int s, uint32_t *aval ) { char intf_name[IFNAMSIZ]; ! socklen_t namelen = IFNAMSIZ; struct air_netif_rsp *net_info = NULL; ! struct sockaddr_in *s_in; /* * Get physical interface name */ if ( getsockopt ( s, T_ATM_SIGNALING, T_ATM_NET_INTF, ! intf_name, &namelen ) ) return; /* *************** *** 1850,1861 **** if ( net_info == NULL ) return; ! sin = (struct sockaddr_in *)&net_info->anp_proto_addr; /* * Fill in answer */ ! bcopy ( (caddr_t)&sin->sin_addr.s_addr, aval, 4 ); free ( net_info ); --- 1822,1833 ---- if ( net_info == NULL ) return; ! s_in = (struct sockaddr_in *)&net_info->anp_proto_addr; /* * Fill in answer */ ! bcopy ( &s_in->sin_addr.s_addr, aval, sizeof(*aval) ); free ( net_info ); *************** *** 1872,1878 **** * * Arguments: * oid - objid from SET message ! * hdr - pointer to internal SNMP header * buf - pointer to SET buffer * s - socket to send messages on * --- 1844,1850 ---- * * Arguments: * oid - objid from SET message ! * hdr - pointer to internal SNMP header - unused * buf - pointer to SET buffer * s - socket to send messages on * *************** *** 1880,1896 **** * none * */ ! void ! set_prefix ( oid, hdr, intf ) ! Objid *oid; ! Snmp_Header *hdr; ! int intf; { struct atmsetreq asr; Atm_addr *aa; int fd; int i; /* * Build IOCTL request to set prefix */ --- 1852,1867 ---- * none * */ ! static void ! set_prefix ( const Objid * const oid, const Snmp_Header * const hdr, const int intf ) { struct atmsetreq asr; Atm_addr *aa; int fd; int i; + (void)hdr; /* to make the ansi compiler happy */ + /* * Build IOCTL request to set prefix */ *************** *** 1901,1907 **** * Pull prefix out of received Objid * save in set_prefix IOCTL and addressEntry table */ ! for ( i = 0; i < oid->oid[13]; i++ ) { asr.asr_prf_pref[i] = oid->oid[i + 14]; } --- 1872,1878 ---- * Pull prefix out of received Objid * save in set_prefix IOCTL and addressEntry table */ ! for ( i = 0; i < oid->oid[13]; ++i ) { asr.asr_prf_pref[i] = oid->oid[i + 14]; } *************** *** 1911,1917 **** fd = socket ( AF_ATM, SOCK_DGRAM, 0 ); if ( fd < 0 ) return; ! if ( ioctl ( fd, AIOCSET, (caddr_t)&asr ) < 0 ) { if ( errno != EALREADY ) { syslog ( LOG_ERR, "ilmid: error setting prefix: %m" ); if ( Log ) { --- 1882,1888 ---- fd = socket ( AF_ATM, SOCK_DGRAM, 0 ); if ( fd < 0 ) return; ! if ( ioctl ( fd, AIOCSET, (char *)&asr ) < 0 ) { if ( errno != EALREADY ) { syslog ( LOG_ERR, "ilmid: error setting prefix: %m" ); if ( Log ) { *************** *** 1947,1973 **** } ! void ! set_address ( hdr, intf ) ! Snmp_Header *hdr; ! int intf; { Variable *var; int i, j; PDU_Header = build_generic_header(); ! PDU_Header->head = (Variable *)malloc(sizeof(Variable)); if (PDU_Header->head == NULL) { ! fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(PDU_Header->head, sizeof(Variable)); var = PDU_Header->head; /* Copy generic addressEntry OBJID */ ! bcopy ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid, ! sizeof(Objid) ); /* Set specific instance */ i = var->oid.oid[0] + 1; /* Get length */ var->oid.oid[i++] = 1; --- 1918,1944 ---- } ! static void ! set_address ( const Snmp_Header * const hdr, const int intf ) { Variable *var; int i, j; + (void)hdr; /* to make ansi compiler happy */ + PDU_Header = build_generic_header(); ! PDU_Header->head = malloc(sizeof(*PDU_Header->head)); if (PDU_Header->head == NULL) { ! fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } ! bzero(PDU_Header->head, sizeof(*PDU_Header->head)); var = PDU_Header->head; /* Copy generic addressEntry OBJID */ ! bcopy ( &Objids[ADDRESS_OBJID], &var->oid, ! sizeof(var->oid) ); /* Set specific instance */ i = var->oid.oid[0] + 1; /* Get length */ var->oid.oid[i++] = 1; *************** *** 2001,2016 **** * fname striped filename * */ ! char * ! basename ( path ) ! char *path; { char *fname; ! if ( ( fname = (char *)strrchr ( path, '/' ) ) != NULL ) ! fname++; else ! fname = path; return ( fname ); } --- 1972,1986 ---- * fname striped filename * */ ! static char * ! basename ( const char *path ) { char *fname; ! if ( ( fname = strrchr ( path, '/' ) ) != NULL ) ! ++fname; else ! fname = (char *)path; return ( fname ); } *************** *** 2027,2036 **** * none - Debug_Level incremented * */ ! void ! Increment_DL ( sig ) ! int sig; { Debug_Level++; if ( Debug_Level && Log == (FILE *)NULL ) { if ( foregnd ) { --- 1997,2006 ---- * none - Debug_Level incremented * */ ! static void ! Increment_DL ( int sig ) { + (void)sig; /* make the ansi compiler happy */ Debug_Level++; if ( Debug_Level && Log == (FILE *)NULL ) { if ( foregnd ) { *************** *** 2061,2070 **** * none - Debug_Level decremented * */ ! void ! Decrement_DL ( sig ) ! int sig; { Debug_Level--; if ( Debug_Level <= 0 ) { Debug_Level = 0; --- 2031,2040 ---- * none - Debug_Level decremented * */ ! static void ! Decrement_DL ( int sig ) { + (void)sig; /* make the ansi compiler happy */ Debug_Level--; if ( Debug_Level <= 0 ) { Debug_Level = 0; *************** *** 2084,2093 **** * Loop through GET variable list looking for matches * */ ! void ! process_get ( hdr, intf ) ! Snmp_Header *hdr; ! int intf; { Variable *var; int idx; --- 2054,2061 ---- * Loop through GET variable list looking for matches * */ ! static void ! process_get ( Snmp_Header * const hdr, const int intf ) { Variable *var; int idx; *************** *** 2098,2106 **** switch ( idx ) { case SYS_OBJID: var->type = ASN_OBJID; ! bcopy ( (caddr_t)&Objids[MY_OBJID], ! (caddr_t)&var->var.oval, ! sizeof(Objid) ); break; case UPTIME_OBJID: var->type = ASN_TIMESTAMP; --- 2066,2074 ---- switch ( idx ) { case SYS_OBJID: var->type = ASN_OBJID; ! bcopy ( &Objids[MY_OBJID], ! &var->var.oval, ! sizeof(var->var.oval) ); break; case UPTIME_OBJID: var->type = ASN_TIMESTAMP; *************** *** 2142,2148 **** case IPNM_OBJID: var->type = ASN_IPADDR; get_local_ip ( ilmi_fd[intf], ! &var->var.ival ); break; case ADDRESS_OBJID: break; --- 2110,2116 ---- case IPNM_OBJID: var->type = ASN_IPADDR; get_local_ip ( ilmi_fd[intf], ! &var->var.aval ); break; case ADDRESS_OBJID: break; *************** *** 2152,2160 **** break; case ATMF_SYSID: var->type = ASN_OCTET; ! var->var.sval[0] = 6; ! bcopy ( (caddr_t)&Cfg[intf].acp_macaddr, ! (caddr_t)&var->var.sval[1], 6 ); break; default: /* NO_SUCH */ --- 2120,2128 ---- break; case ATMF_SYSID: var->type = ASN_OCTET; ! var->var.sval[0] = sizeof(Cfg[intf].acp_macaddr); ! bcopy ( &Cfg[intf].acp_macaddr, ! &var->var.sval[1], sizeof(Cfg[intf].acp_macaddr) ); break; default: /* NO_SUCH */ *************** *** 2172,2183 **** * * */ ! void ! ilmi_do_state () { struct timeval tvp; fd_set rfd; ! u_char buf[1024]; Variable *var; int intf; int maxfd = 0; --- 2140,2151 ---- * * */ ! static void ! ilmi_do_state (void) { struct timeval tvp; fd_set rfd; ! char buf[1024]; Variable *var; int intf; int maxfd = 0; *************** *** 2188,2194 **** for ( ; ; ) { int count; int n; ! caddr_t bpp; Snmp_Header *Hdr; /* --- 2156,2162 ---- for ( ; ; ) { int count; int n; ! char *bpp; Snmp_Header *Hdr; /* *************** *** 2222,2228 **** /* * Clear addressTable */ ! bzero ( (caddr_t)&addressEntry[intf], sizeof(Objid) ); /* * Start by sending a COLD_START trap. This should cause the --- 2190,2196 ---- /* * Clear addressTable */ ! bzero ( &addressEntry[intf], sizeof(Objid) ); /* * Start by sending a COLD_START trap. This should cause the *************** *** 2252,2267 **** */ PDU_Header = build_generic_header(); ! PDU_Header->head = (Variable *)malloc(sizeof(Variable)); if (PDU_Header->head == NULL) { ! fprintf(stderr, "malloc() failed in %s()\n", __func__); exit(1); } ! bzero(PDU_Header->head, sizeof(Variable)); var = PDU_Header->head; ! bcopy ( (caddr_t)&Objids[ADDRESS_OBJID], (caddr_t)&var->oid, ! sizeof(Objid) ); var->type = ASN_NULL; var->next = NULL; --- 2220,2235 ---- */ PDU_Header = build_generic_header(); ! PDU_Header->head = malloc(sizeof(*PDU_Header->head)); if (PDU_Header->head == NULL) { ! fprintf(stderr, "malloc() failed in %s() line %d\n", __func__, __LINE__); exit(1); } ! bzero(PDU_Header->head, sizeof(*PDU_Header->head)); var = PDU_Header->head; ! bcopy ( &Objids[ADDRESS_OBJID], &var->oid, ! sizeof(var->oid) ); var->type = ASN_NULL; var->next = NULL; *************** *** 2296,2302 **** */ if ( ilmi_fd[intf] > 0 && FD_ISSET ( ilmi_fd[intf], & rfd ) ) { ! n = read ( ilmi_fd[intf], (caddr_t)&buf[1], sizeof(buf) - 1 ); if ( n == -1 && ( errno == ECONNRESET || errno == EBADF ) ) { ilmi_state[intf] = ILMI_COLDSTART; close ( ilmi_fd[intf] ); --- 2264,2270 ---- */ if ( ilmi_fd[intf] > 0 && FD_ISSET ( ilmi_fd[intf], & rfd ) ) { ! n = read ( ilmi_fd[intf], &buf[1], sizeof(buf) - 1 ); if ( n == -1 && ( errno == ECONNRESET || errno == EBADF ) ) { ilmi_state[intf] = ILMI_COLDSTART; close ( ilmi_fd[intf] ); *************** *** 2305,2314 **** if ( Log && Debug_Level > 1 ) fprintf ( Log, "***** state %d ***** read %d bytes from %d (%d) ***** %s *****\n", ilmi_state[intf], n, intf, ilmi_fd[intf], PDU_Types[buf[14] - 0xA0] ); { if ( Debug_Level > 2 ) ! hexdump ( (caddr_t)&buf[1], n ); } ! bpp = (caddr_t)&buf[1]; ! if ( ( Hdr = asn_get_header ( &bpp ) ) == NULL ) continue; /* What we do with this messages depends upon the state we're in */ --- 2273,2282 ---- if ( Log && Debug_Level > 1 ) fprintf ( Log, "***** state %d ***** read %d bytes from %d (%d) ***** %s *****\n", ilmi_state[intf], n, intf, ilmi_fd[intf], PDU_Types[buf[14] - 0xA0] ); { if ( Debug_Level > 2 ) ! hexdump ( &buf[1], n ); } ! bpp = &buf[1]; ! if ( ( Hdr = asn_get_header ( (const char **)&bpp ) ) == NULL ) continue; /* What we do with this messages depends upon the state we're in */ *************** *** 2325,2333 **** * 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 */ --- 2293,2301 ---- * Should be because the remote side is attempting * to verify that our table is empty */ ! if ( oid_ncmp ( &Hdr->head->oid, ! &Objids[ADDRESS_OBJID], ! Objids[ADDRESS_OBJID].oid[0] ) == 0 ) { if ( addressEntry[intf].oid[0] ) { /* XXX - FIXME */ /* Our table is not empty - return address */ *************** *** 2381,2392 **** break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ ! if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, ! (caddr_t)&Objids[SETPFX_OBJID], ! Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ ! build_pdu(Hdr, PDU_TYPE_GETRESP); send_resp( intf, Hdr, Resp_Buf ); set_address ( Hdr, intf ); } else { --- 2349,2360 ---- break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ ! if ( oid_ncmp ( &Hdr->head->oid, ! &Objids[SETPFX_OBJID], ! Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ ! build_pdu( Hdr, PDU_TYPE_GETRESP ); send_resp( intf, Hdr, Resp_Buf ); set_address ( Hdr, intf ); } else { *************** *** 2422,2430 **** break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ ! if ( oid_ncmp ( (caddr_t)&Hdr->head->oid, ! (caddr_t)&Objids[SETPFX_OBJID], ! Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ build_pdu(Hdr, PDU_TYPE_GETRESP); --- 2390,2398 ---- break; case PDU_TYPE_SET: /* Look for SET_PREFIX Objid */ ! if ( oid_ncmp ( &Hdr->head->oid, ! &Objids[SETPFX_OBJID], ! Objids[SETPFX_OBJID].oid[0] ) == 0 ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ build_pdu(Hdr, PDU_TYPE_GETRESP); *************** *** 2453,2461 **** } int ! main ( argc, argv ) ! int argc; ! char *argv[]; { int c; int i; --- 2421,2427 ---- } int ! main ( int argc, char *argv[] ) { int c; int i; *************** *** 2507,2513 **** if ( daemon ( 0, 0 ) ) err ( 1, "Can't fork" ); } else ! ; /* setbuf ( stdout, NULL ); */ signal ( SIGUSR1, Increment_DL ); signal ( SIGUSR2, Decrement_DL ); --- 2473,2479 ---- if ( daemon ( 0, 0 ) ) err ( 1, "Can't fork" ); } else ! (void)0; /* setbuf ( stdout, NULL ); */ signal ( SIGUSR1, Increment_DL ); signal ( SIGUSR2, Decrement_DL ); --------------000108030408030604070306-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message