From owner-freebsd-audit Sun Mar 23 17:22:41 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 1799D37B401 for ; Sun, 23 Mar 2003 17:22:08 -0800 (PST) Received: from mail.liwing.de (mail.liwing.de [213.70.188.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC56643FA3 for ; Sun, 23 Mar 2003 17:22:03 -0800 (PST) (envelope-from rehsack@liwing.de) Received: (qmail 31178 invoked from network); 24 Mar 2003 01:22:01 -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 ; 24 Mar 2003 01:22:01 -0000 Message-ID: <3E7E5DB9.7020406@liwing.de> Date: Mon, 24 Mar 2003 02:22:01 +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: audit@freebsd.org Cc: Tom Rhodes , Harti Brandt Subject: 1st new patch for src/sbin/atm/ilmid/ilmid.c Content-Type: multipart/mixed; boundary="------------060206080004090609010000" 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. --------------060206080004090609010000 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, here is the 1st patch for src/sbin/atm/ilmid/ilmid.c as discussed with Tom Rhodes. It contains only a declaration for each function which is implemented (prototype) and fixes some errors resulting from the change. I attach 2 patches: The first one is just the patch which declares the prototypes and is informational only. The 2nd one fixes the errors the compiler reports, too. Hope this is a little better than last (big) one. Jens --------------060206080004090609010000 Content-Type: text/plain; name="patch-ilmid.c.diff-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-ilmid.c.diff-1" --- ilmid.c.orig Mon Mar 24 00:32:18 2003 +++ ilmid.c Mon Mar 24 01:04:11 2003 @@ -335,14 +335,62 @@ #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" }; /* + * function declarations (in order of implementation) + */ +static void write_timestamp( void ); +static void hexdump( u_char *bp, int len ); + +static int asn_get_pdu_len( u_char **bufp, int *plen ); +static int asn_get_encoded( u_char **bufp, int *len ); +static int asn_get_int( u_char **bufp, int *plen ); +static void asn_set_int( u_char **bufp, int val ); + +static void print_objid( Objid *objid ); +static void asn_get_objid( u_char **bufp, Objid *objid, int *plen ); +static int asn_put_objid( u_char **bufp, Objid *objid ); +static void asn_get_octet( u_char **bufp, char *octet, int *plen ); + +static void print_header( Snmp_Header *Hdr ); + +static void parse_oids( Snmp_Header *h, caddr_t *bp ); +static Snmp_Header * asn_get_header( u_char **bufp ); + +static int oid_cmp( Objid *oid1, Objid *oid2 ); +static int oid_ncmp( Objid *oid1, Objid *oid2, int len ); + +static int find_var( Variable *var ); +static int get_ticks(void); +static void build_pdu( Snmp_Header *hdr, int type ); + +static void free_pdu( Snmp_Header *hdr ); +static void set_reqid( u_char *resp, int reqid ); +static void send_resp( int intf, Snmp_Header *Hdr, u_char *resp ); + +static Snmp_Header * build_cold_start(void); +static Snmp_Header * build_generic_header(void); + +static void init_ilmi(void); +static void ilmi_open(void); + +static void get_local_ip( int s, long *aval ); +static void set_prefix( Objid *oid, Snmp_Header *hdr, int intf ); + +static void set_address( Snmp_Header *hdr, int intf ); +static char * basename( char *path ); + +static void process_get( Snmp_Header *hdr, int intf ); + +static void ilmi_do_state(void); + +static void Increment_DL( int sig ); +static void Decrement_DL( int sig ); + +/* * Write a syslog() style timestamp * * Write a syslog() style timestamp with month, day, time and hostname @@ -355,8 +403,8 @@ * none * */ -void -write_timestamp() +static void +write_timestamp(void) { time_t clock; struct tm *tm; @@ -376,7 +424,7 @@ /* * Utility to pretty print buffer as hex dumps - * + * * Arguments: * bp - buffer pointer * len - length to pretty print @@ -385,10 +433,8 @@ * none * */ -void -hexdump ( bp, len ) - u_char *bp; - int len; +static void +hexdump( u_char *bp, int len ) { int i, j; @@ -443,16 +489,14 @@ * bufp - pointer to buffer pointer * plen - pointer to PDU length or NULL if not a concern * - * Returns: + * Returns: * bufp - updated buffer pointer * plen - (possibly) adjusted pdu length * - decoded length * */ -int -asn_get_pdu_len ( bufp, plen ) - u_char **bufp; - int *plen; +static int +asn_get_pdu_len ( u_char **bufp, int *plen ) { u_char *bp = *bufp; int len = 0; @@ -490,10 +534,8 @@ * - value encoding represented * */ -int -asn_get_encoded ( bufp, len ) - u_char **bufp; - int *len; +static int +asn_get_encoded ( u_char **bufp, int *len ) { u_char *bp = *bufp; int val = 0; @@ -526,15 +568,13 @@ * plen - pointer to PDU length or NULL if not a concern * * Returns: - * bufp - updated buffer pointer + * bufp - updated buffer pointer * plen - (possibly) updated PDU length * - value of encoded integer * */ -int -asn_get_int ( bufp, plen ) - u_char **bufp; - int *plen; +static int +asn_get_int ( u_char **bufp, int *plen ) { int i; int len; @@ -565,10 +605,8 @@ * - updated buffer pointer * */ -void -asn_set_int ( bufp, val ) - u_char **bufp; - int val; +static void +asn_set_int( u_char **bufp, int val ) { union { int i; @@ -614,9 +652,8 @@ * none * */ -void -print_objid ( objid ) - Objid *objid; +static void +print_objid( Objid *objid ) { int i; @@ -651,11 +688,8 @@ * plen - (possibly) adjusted PDU length * */ -void -asn_get_objid ( bufp, objid, plen ) - u_char **bufp; - Objid *objid; - int *plen; +static void +asn_get_objid( u_char **bufp, Objid *objid, int *plen ) { int len; u_char *bp = *bufp; @@ -681,10 +715,8 @@ * Put OBJID - assumes elements <= 16383 for two byte coding * */ -int -asn_put_objid ( bufp, objid ) - u_char **bufp; - Objid *objid; +static int +asn_put_objid( u_char **bufp, Objid *objid ) { int len = 0; u_char *bp = *bufp; @@ -728,12 +760,9 @@ * octet - encoded Octet String * plen - (possibly) adjusted PDU length * - */ -void -asn_get_octet ( bufp, octet, plen ) - u_char **bufp; - char *octet; - int *plen; + */ +static void +asn_get_octet( u_char **bufp, char *octet, int *plen ) { u_char *bp = *bufp; int i = 0; @@ -743,7 +772,7 @@ * &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 ); + len = asn_get_encoded ( &bp, &i ); for ( i = 0; i < len; i++ ) { *octet++ = *bp++; @@ -767,9 +796,8 @@ * none * */ -void -print_header ( Hdr ) - Snmp_Header *Hdr; +static void +print_header( Snmp_Header *Hdr ) { Variable *var; @@ -826,10 +854,8 @@ * none * */ -void -parse_oids ( h, bp ) - Snmp_Header *h; - caddr_t *bp; +static void +parse_oids( Snmp_Header *h, caddr_t *bp ) { int len = h->varlen; int sublen; @@ -858,13 +884,13 @@ h->tail = var; /* Get length of variable sequence */ - sublen = asn_get_pdu_len ( &bufp, &len ); + sublen = asn_get_pdu_len( &bufp, &len ); /* Should be OBJID type */ if ( *bufp++ != ASN_OBJID ) { *bp = bufp; return; } - asn_get_objid ( &bufp, &var->oid, &len ); + asn_get_objid ( (u_char **)&bufp, &var->oid, &len ); var->type = *bufp++; len--; switch ( var->type ) { @@ -913,9 +939,8 @@ * - generated SNMP header * */ -Snmp_Header * -asn_get_header ( bufp ) - u_char **bufp; +static Snmp_Header * +asn_get_header( u_char **bufp ) { Snmp_Header *h; u_char *bp = *bufp; @@ -1025,9 +1050,8 @@ * 1 - Objid's don't match * */ -int -oid_cmp ( oid1, oid2 ) - Objid *oid1, *oid2; +static int +oid_cmp( Objid *oid1, Objid *oid2 ) { int i; int len; @@ -1067,10 +1091,8 @@ * 1 - Objid's don't match * */ -int -oid_ncmp ( oid1, oid2, len ) - Objid *oid1, *oid2; - int len; +static int +oid_ncmp( Objid *oid1, Objid *oid2, int len ) { int i; @@ -1098,9 +1120,8 @@ * -1 - no matching Variable found * */ -int -find_var ( var ) - Variable *var; +static int +find_var( Variable *var ) { int i; @@ -1114,7 +1135,7 @@ } /* - * Return the time process has been running as a number of ticks + * Return the time process has been running as a number of ticks * * Arguments: * none @@ -1123,8 +1144,8 @@ * number of ticks * */ -int -get_ticks() +static int +get_ticks(void) { struct timeval timenow; struct timeval timediff; @@ -1167,10 +1188,8 @@ * none * */ -void -build_pdu ( hdr, type ) - Snmp_Header *hdr; - int type; +static void +build_pdu( Snmp_Header *hdr, int type ) { u_char *bp = Resp_Buf; u_char *vpp; @@ -1262,7 +1281,7 @@ /* Fill in time-stamp - assume 0 for now */ *bp++ = ASN_TIMESTAMP; asn_set_int ( &bp, 0 ); - + /* encoded length */ traplen = ( bp - ppp - 1 ); @@ -1385,9 +1404,8 @@ return; } -void -free_pdu ( hdr ) -Snmp_Header *hdr; +static void +free_pdu( Snmp_Header *hdr ) { Variable *var; @@ -1411,16 +1429,14 @@ * none - request id may/may not be set * */ -void -set_reqid ( resp, reqid ) - u_char *resp; - int reqid; +static void +set_reqid( u_char *resp, int reqid ) { u_char *bp = (u_char *)&resp[18]; union { int i; u_char c[4]; - } u; + } u; u.i = htonl(reqid); @@ -1444,11 +1460,8 @@ * none - response sent * */ -void -send_resp ( intf, Hdr, resp ) - int intf; - Snmp_Header *Hdr; - u_char *resp; +static void +send_resp( int intf, Snmp_Header *Hdr, u_char *resp ) { int n; @@ -1471,8 +1484,8 @@ * Build a COLD_START TRAP PDU * */ -Snmp_Header * -build_cold_start() +static Snmp_Header * +build_cold_start(void) { Snmp_Header *hdr; Variable *var; @@ -1513,8 +1526,8 @@ * Build a Generic PDU Header * */ -Snmp_Header * -build_generic_header() +static Snmp_Header * +build_generic_header(void) { Snmp_Header *hdr; @@ -1532,22 +1545,22 @@ return ( hdr ); } -/* +/* * Initialize information on what physical adapters HARP knows about * * Query the HARP subsystem about configuration and physical interface * information for any currently registered ATM adapters. Store the information * as arrays for easier indexing by SNMP port/index numbers. - * + * * Arguments: * none * * Returns: - * none Information from HARP available - * + * none Information from HARP available + * */ -void -init_ilmi() +static void +init_ilmi(void) { struct air_cfg_rsp *cfg_info = NULL; struct air_int_rsp *intf_info = NULL; @@ -1617,8 +1630,8 @@ * none * */ -void -ilmi_open () +static void +ilmi_open(void) { struct sockaddr_atm satm; struct t_atm_aal5 aal5; @@ -1702,7 +1715,7 @@ 0 ); ATM_PVC_SET_VCI((Atm_addr_pvc *)satm.satm_addr.t_atm_sap_addr.address, 16 ); - + satm.satm_addr.t_atm_sap_layer2.SVE_tag = T_ATM_PRESENT; satm.satm_addr.t_atm_sap_layer2.ID_type = T_ATM_SIMPLE_ID; satm.satm_addr.t_atm_sap_layer2.ID.simple_ID = T_ATM_BLLI2_I8802; @@ -1826,10 +1839,8 @@ * none * */ -void -get_local_ip ( s, aval ) - int s; - long *aval; +static void +get_local_ip( int s, long *aval ) { char intf_name[IFNAMSIZ]; int namelen = IFNAMSIZ; @@ -1880,11 +1891,8 @@ * none * */ -void -set_prefix ( oid, hdr, intf ) - Objid *oid; - Snmp_Header *hdr; - int intf; +static void +set_prefix( Objid *oid, Snmp_Header *hdr, int intf ) { struct atmsetreq asr; Atm_addr *aa; @@ -1909,7 +1917,7 @@ * Pass new prefix to the HARP kernel */ fd = socket ( AF_ATM, SOCK_DGRAM, 0 ); - if ( fd < 0 ) + if ( fd < 0 ) return; if ( ioctl ( fd, AIOCSET, (caddr_t)&asr ) < 0 ) { if ( errno != EALREADY ) { @@ -1947,10 +1955,8 @@ } -void -set_address ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +set_address( Snmp_Header *hdr, int intf ) { Variable *var; int i, j; @@ -1991,20 +1997,19 @@ send_resp ( intf, PDU_Header, Resp_Buf ); } -/* +/* * Utility to strip off any leading path information from a filename - * + * * Arguments: * path pathname to strip - * + * * Returns: * fname striped filename - * - */ -char * -basename ( path ) - char *path; -{ + * + */ +static char * +basename( char *path ) +{ char *fname; if ( ( fname = (char *)strrchr ( path, '/' ) ) != NULL ) @@ -2027,16 +2032,15 @@ * none - Debug_Level incremented * */ -void -Increment_DL ( sig ) - int sig; +static void +Increment_DL( int sig ) { Debug_Level++; if ( Debug_Level && Log == (FILE *)NULL ) { if ( foregnd ) { Log = stderr; } else { - if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) + if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) Log = NULL; } if ( Log ) { @@ -2061,9 +2065,8 @@ * none - Debug_Level decremented * */ -void -Decrement_DL ( sig ) - int sig; +static void +Decrement_DL( int sig ) { Debug_Level--; if ( Debug_Level <= 0 ) { @@ -2084,10 +2087,8 @@ * Loop through GET variable list looking for matches * */ -void -process_get ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +process_get( Snmp_Header *hdr, int intf ) { Variable *var; int idx; @@ -2172,8 +2173,8 @@ * * */ -void -ilmi_do_state () +static void +ilmi_do_state(void) { struct timeval tvp; fd_set rfd; @@ -2238,7 +2239,7 @@ * ILMI_COLDSTART. */ /* atm_timeout() */ - + /* Enter new state */ ilmi_state[intf] = ILMI_INIT; /* fall into ILMI_INIT */ @@ -2264,25 +2265,25 @@ sizeof(Objid) ); var->type = ASN_NULL; var->next = NULL; - + /* * Send GETNEXT request looking for empty ATM Address Table */ PDU_Header->reqid = Req_ID++; build_pdu ( PDU_Header, PDU_TYPE_GETNEXT ); send_resp ( intf, PDU_Header, Resp_Buf ); - + /* * Start a timeout while looking for SET message. If we don't receive * a SET, then go back to COLD_START state. */ /* atm_timeout() */ break; - + case ILMI_RUNNING: /* Normal SNMP processing */ break; - + default: break; } @@ -2295,7 +2296,7 @@ * Check for received messages */ 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; @@ -2310,7 +2311,7 @@ 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 */ switch ( ilmi_state[intf] ) { case ILMI_COLDSTART: @@ -2453,9 +2454,7 @@ } int -main ( argc, argv ) - int argc; - char *argv[]; +main( int argc, char *argv[] ) { int c; int i; --------------060206080004090609010000 Content-Type: text/plain; name="patch-ilmid.c.diff-2" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch-ilmid.c.diff-2" --- ilmid.c.orig Mon Mar 24 00:32:18 2003 +++ ilmid.c Mon Mar 24 01:16:23 2003 @@ -335,14 +335,61 @@ #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" }; /* + * function declarations (in order of implementation) + */ +static void write_timestamp( void ); +static void hexdump( u_char *bp, int len ); + +static int asn_get_pdu_len( u_char **bufp, int *plen ); +static int asn_get_encoded( u_char **bufp, int *len ); +static int asn_get_int( u_char **bufp, int *plen ); +static void asn_set_int( u_char **bufp, int val ); + +static void print_objid( Objid *objid ); +static void asn_get_objid( u_char **bufp, Objid *objid, int *plen ); +static int asn_put_objid( u_char **bufp, Objid *objid ); +static void asn_get_octet( u_char **bufp, char *octet, int *plen ); + +static void print_header( Snmp_Header *Hdr ); + +static void parse_oids( Snmp_Header *h, u_char **bp ); +static Snmp_Header * asn_get_header( u_char **bufp ); + +static int oid_cmp( Objid *oid1, Objid *oid2 ); +static int oid_ncmp( Objid *oid1, Objid *oid2, int len ); + +static int find_var( Variable *var ); +static int get_ticks(void); +static void build_pdu( Snmp_Header *hdr, int type ); + +static void free_pdu( Snmp_Header *hdr ); +static void send_resp( int intf, Snmp_Header *Hdr, u_char *resp ); + +static Snmp_Header * build_cold_start(void); +static Snmp_Header * build_generic_header(void); + +static void init_ilmi(void); +static void ilmi_open(void); + +static void get_local_ip( int s, long *aval ); +static void set_prefix( Objid *oid, Snmp_Header *hdr, int intf ); + +static void set_address( Snmp_Header *hdr, int intf ); +static char * basename( char *path ); + +static void process_get( Snmp_Header *hdr, int intf ); + +static void ilmi_do_state(void); + +static void Increment_DL( int sig ); +static void Decrement_DL( int sig ); + +/* * Write a syslog() style timestamp * * Write a syslog() style timestamp with month, day, time and hostname @@ -355,8 +402,8 @@ * none * */ -void -write_timestamp() +static void +write_timestamp(void) { time_t clock; struct tm *tm; @@ -376,7 +423,7 @@ /* * Utility to pretty print buffer as hex dumps - * + * * Arguments: * bp - buffer pointer * len - length to pretty print @@ -385,10 +432,8 @@ * none * */ -void -hexdump ( bp, len ) - u_char *bp; - int len; +static void +hexdump( u_char *bp, int len ) { int i, j; @@ -443,16 +488,14 @@ * bufp - pointer to buffer pointer * plen - pointer to PDU length or NULL if not a concern * - * Returns: + * Returns: * bufp - updated buffer pointer * plen - (possibly) adjusted pdu length * - decoded length * */ -int -asn_get_pdu_len ( bufp, plen ) - u_char **bufp; - int *plen; +static int +asn_get_pdu_len ( u_char **bufp, int *plen ) { u_char *bp = *bufp; int len = 0; @@ -490,10 +533,8 @@ * - value encoding represented * */ -int -asn_get_encoded ( bufp, len ) - u_char **bufp; - int *len; +static int +asn_get_encoded ( u_char **bufp, int *len ) { u_char *bp = *bufp; int val = 0; @@ -526,15 +567,13 @@ * plen - pointer to PDU length or NULL if not a concern * * Returns: - * bufp - updated buffer pointer + * bufp - updated buffer pointer * plen - (possibly) updated PDU length * - value of encoded integer * */ -int -asn_get_int ( bufp, plen ) - u_char **bufp; - int *plen; +static int +asn_get_int ( u_char **bufp, int *plen ) { int i; int len; @@ -565,10 +604,8 @@ * - updated buffer pointer * */ -void -asn_set_int ( bufp, val ) - u_char **bufp; - int val; +static void +asn_set_int( u_char **bufp, int val ) { union { int i; @@ -614,9 +651,8 @@ * none * */ -void -print_objid ( objid ) - Objid *objid; +static void +print_objid( Objid *objid ) { int i; @@ -651,11 +687,8 @@ * plen - (possibly) adjusted PDU length * */ -void -asn_get_objid ( bufp, objid, plen ) - u_char **bufp; - Objid *objid; - int *plen; +static void +asn_get_objid( u_char **bufp, Objid *objid, int *plen ) { int len; u_char *bp = *bufp; @@ -681,10 +714,8 @@ * Put OBJID - assumes elements <= 16383 for two byte coding * */ -int -asn_put_objid ( bufp, objid ) - u_char **bufp; - Objid *objid; +static int +asn_put_objid( u_char **bufp, Objid *objid ) { int len = 0; u_char *bp = *bufp; @@ -728,12 +759,9 @@ * octet - encoded Octet String * plen - (possibly) adjusted PDU length * - */ -void -asn_get_octet ( bufp, octet, plen ) - u_char **bufp; - char *octet; - int *plen; + */ +static void +asn_get_octet( u_char **bufp, char *octet, int *plen ) { u_char *bp = *bufp; int i = 0; @@ -743,7 +771,7 @@ * &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 ); + len = asn_get_encoded ( &bp, &i ); for ( i = 0; i < len; i++ ) { *octet++ = *bp++; @@ -767,9 +795,8 @@ * none * */ -void -print_header ( Hdr ) - Snmp_Header *Hdr; +static void +print_header( Snmp_Header *Hdr ) { Variable *var; @@ -826,15 +853,13 @@ * none * */ -void -parse_oids ( h, bp ) - Snmp_Header *h; - caddr_t *bp; +static void +parse_oids( Snmp_Header *h, u_char **bp ) { int len = h->varlen; int sublen; Variable *var; - caddr_t bufp = *bp; + u_char *bufp = *bp; while ( len > 0 ) { if ( *bufp++ == ASN_SEQUENCE ) { @@ -858,13 +883,13 @@ h->tail = var; /* Get length of variable sequence */ - sublen = asn_get_pdu_len ( &bufp, &len ); + sublen = asn_get_pdu_len( &bufp, &len ); /* Should be OBJID type */ if ( *bufp++ != ASN_OBJID ) { *bp = bufp; return; } - asn_get_objid ( &bufp, &var->oid, &len ); + asn_get_objid ( (u_char **)&bufp, &var->oid, &len ); var->type = *bufp++; len--; switch ( var->type ) { @@ -913,9 +938,8 @@ * - generated SNMP header * */ -Snmp_Header * -asn_get_header ( bufp ) - u_char **bufp; +static Snmp_Header * +asn_get_header( u_char **bufp ) { Snmp_Header *h; u_char *bp = *bufp; @@ -1025,9 +1049,8 @@ * 1 - Objid's don't match * */ -int -oid_cmp ( oid1, oid2 ) - Objid *oid1, *oid2; +static int +oid_cmp( Objid *oid1, Objid *oid2 ) { int i; int len; @@ -1067,10 +1090,8 @@ * 1 - Objid's don't match * */ -int -oid_ncmp ( oid1, oid2, len ) - Objid *oid1, *oid2; - int len; +static int +oid_ncmp( Objid *oid1, Objid *oid2, int len ) { int i; @@ -1098,9 +1119,8 @@ * -1 - no matching Variable found * */ -int -find_var ( var ) - Variable *var; +static int +find_var( Variable *var ) { int i; @@ -1114,7 +1134,7 @@ } /* - * Return the time process has been running as a number of ticks + * Return the time process has been running as a number of ticks * * Arguments: * none @@ -1123,8 +1143,8 @@ * number of ticks * */ -int -get_ticks() +static int +get_ticks(void) { struct timeval timenow; struct timeval timediff; @@ -1167,10 +1187,8 @@ * none * */ -void -build_pdu ( hdr, type ) - Snmp_Header *hdr; - int type; +static void +build_pdu( Snmp_Header *hdr, int type ) { u_char *bp = Resp_Buf; u_char *vpp; @@ -1262,7 +1280,7 @@ /* Fill in time-stamp - assume 0 for now */ *bp++ = ASN_TIMESTAMP; asn_set_int ( &bp, 0 ); - + /* encoded length */ traplen = ( bp - ppp - 1 ); @@ -1385,9 +1403,8 @@ return; } -void -free_pdu ( hdr ) -Snmp_Header *hdr; +static void +free_pdu( Snmp_Header *hdr ) { Variable *var; @@ -1401,38 +1418,6 @@ } /* - * Set Request ID in PDU - * - * Arguments: - * resp - Response PDU buffer - * reqid - request id value - * - * Returns: - * 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: @@ -1444,11 +1429,8 @@ * none - response sent * */ -void -send_resp ( intf, Hdr, resp ) - int intf; - Snmp_Header *Hdr; - u_char *resp; +static void +send_resp( int intf, Snmp_Header *Hdr, u_char *resp ) { int n; @@ -1471,8 +1453,8 @@ * Build a COLD_START TRAP PDU * */ -Snmp_Header * -build_cold_start() +static Snmp_Header * +build_cold_start(void) { Snmp_Header *hdr; Variable *var; @@ -1513,8 +1495,8 @@ * Build a Generic PDU Header * */ -Snmp_Header * -build_generic_header() +static Snmp_Header * +build_generic_header(void) { Snmp_Header *hdr; @@ -1532,22 +1514,22 @@ return ( hdr ); } -/* +/* * Initialize information on what physical adapters HARP knows about * * Query the HARP subsystem about configuration and physical interface * information for any currently registered ATM adapters. Store the information * as arrays for easier indexing by SNMP port/index numbers. - * + * * Arguments: * none * * Returns: - * none Information from HARP available - * + * none Information from HARP available + * */ -void -init_ilmi() +static void +init_ilmi(void) { struct air_cfg_rsp *cfg_info = NULL; struct air_int_rsp *intf_info = NULL; @@ -1617,8 +1599,8 @@ * none * */ -void -ilmi_open () +static void +ilmi_open(void) { struct sockaddr_atm satm; struct t_atm_aal5 aal5; @@ -1702,7 +1684,7 @@ 0 ); ATM_PVC_SET_VCI((Atm_addr_pvc *)satm.satm_addr.t_atm_sap_addr.address, 16 ); - + satm.satm_addr.t_atm_sap_layer2.SVE_tag = T_ATM_PRESENT; satm.satm_addr.t_atm_sap_layer2.ID_type = T_ATM_SIMPLE_ID; satm.satm_addr.t_atm_sap_layer2.ID.simple_ID = T_ATM_BLLI2_I8802; @@ -1826,10 +1808,8 @@ * none * */ -void -get_local_ip ( s, aval ) - int s; - long *aval; +static void +get_local_ip( int s, long *aval ) { char intf_name[IFNAMSIZ]; int namelen = IFNAMSIZ; @@ -1880,11 +1860,8 @@ * none * */ -void -set_prefix ( oid, hdr, intf ) - Objid *oid; - Snmp_Header *hdr; - int intf; +static void +set_prefix( Objid *oid, Snmp_Header *hdr, int intf ) { struct atmsetreq asr; Atm_addr *aa; @@ -1909,7 +1886,7 @@ * Pass new prefix to the HARP kernel */ fd = socket ( AF_ATM, SOCK_DGRAM, 0 ); - if ( fd < 0 ) + if ( fd < 0 ) return; if ( ioctl ( fd, AIOCSET, (caddr_t)&asr ) < 0 ) { if ( errno != EALREADY ) { @@ -1947,10 +1924,8 @@ } -void -set_address ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +set_address( Snmp_Header *hdr, int intf ) { Variable *var; int i, j; @@ -1991,20 +1966,19 @@ send_resp ( intf, PDU_Header, Resp_Buf ); } -/* +/* * Utility to strip off any leading path information from a filename - * + * * Arguments: * path pathname to strip - * + * * Returns: * fname striped filename - * - */ -char * -basename ( path ) - char *path; -{ + * + */ +static char * +basename( char *path ) +{ char *fname; if ( ( fname = (char *)strrchr ( path, '/' ) ) != NULL ) @@ -2027,16 +2001,15 @@ * none - Debug_Level incremented * */ -void -Increment_DL ( sig ) - int sig; +static void +Increment_DL( int sig ) { Debug_Level++; if ( Debug_Level && Log == (FILE *)NULL ) { if ( foregnd ) { Log = stderr; } else { - if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) + if ( ( Log = fopen ( LOG_FILE, "a" ) ) == NULL ) Log = NULL; } if ( Log ) { @@ -2061,9 +2034,8 @@ * none - Debug_Level decremented * */ -void -Decrement_DL ( sig ) - int sig; +static void +Decrement_DL( int sig ) { Debug_Level--; if ( Debug_Level <= 0 ) { @@ -2084,10 +2056,8 @@ * Loop through GET variable list looking for matches * */ -void -process_get ( hdr, intf ) - Snmp_Header *hdr; - int intf; +static void +process_get( Snmp_Header *hdr, int intf ) { Variable *var; int idx; @@ -2141,8 +2111,7 @@ break; case IPNM_OBJID: var->type = ASN_IPADDR; - get_local_ip ( ilmi_fd[intf], - &var->var.ival ); + get_local_ip( ilmi_fd[intf], &var->var.aval ); break; case ADDRESS_OBJID: break; @@ -2172,8 +2141,8 @@ * * */ -void -ilmi_do_state () +static void +ilmi_do_state(void) { struct timeval tvp; fd_set rfd; @@ -2188,7 +2157,7 @@ for ( ; ; ) { int count; int n; - caddr_t bpp; + u_char *bpp; Snmp_Header *Hdr; /* @@ -2238,7 +2207,7 @@ * ILMI_COLDSTART. */ /* atm_timeout() */ - + /* Enter new state */ ilmi_state[intf] = ILMI_INIT; /* fall into ILMI_INIT */ @@ -2264,25 +2233,25 @@ sizeof(Objid) ); var->type = ASN_NULL; var->next = NULL; - + /* * Send GETNEXT request looking for empty ATM Address Table */ PDU_Header->reqid = Req_ID++; build_pdu ( PDU_Header, PDU_TYPE_GETNEXT ); send_resp ( intf, PDU_Header, Resp_Buf ); - + /* * Start a timeout while looking for SET message. If we don't receive * a SET, then go back to COLD_START state. */ /* atm_timeout() */ break; - + case ILMI_RUNNING: /* Normal SNMP processing */ break; - + default: break; } @@ -2295,22 +2264,25 @@ * Check for received messages */ 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] ); ilmi_fd[intf] = -1; } else { - 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 ( 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 ( &bpp ) ) == NULL ) continue; - + /* What we do with this messages depends upon the state we're in */ switch ( ilmi_state[intf] ) { case ILMI_COLDSTART: @@ -2325,9 +2297,9 @@ * 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 ( 0 == oid_ncmp( &Hdr->head->oid, + &Objids[ADDRESS_OBJID], + Objids[ADDRESS_OBJID].oid[0] ) ) { if ( addressEntry[intf].oid[0] ) { /* XXX - FIXME */ /* Our table is not empty - return address */ @@ -2381,9 +2353,9 @@ 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 ) { + if ( 0 == oid_ncmp( &Hdr->head->oid, + &Objids[SETPFX_OBJID], + Objids[SETPFX_OBJID].oid[0] ) ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ build_pdu(Hdr, PDU_TYPE_GETRESP); @@ -2422,9 +2394,9 @@ 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 ) { + if ( 0 == oid_ncmp( &Hdr->head->oid, + &Objids[SETPFX_OBJID], + Objids[SETPFX_OBJID].oid[0] ) ) { set_prefix ( &Hdr->head->oid, Hdr, intf ); /* Reply to SET before sending our ADDRESS */ build_pdu(Hdr, PDU_TYPE_GETRESP); @@ -2453,9 +2425,7 @@ } int -main ( argc, argv ) - int argc; - char *argv[]; +main( int argc, char *argv[] ) { int c; int i; --------------060206080004090609010000-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Mar 28 2:15:50 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 42E5837B401 for ; Fri, 28 Mar 2003 02:15:48 -0800 (PST) Received: from mx0.gmx.net (mx0.gmx.de [213.165.64.100]) by mx1.FreeBSD.org (Postfix) with SMTP id 0276B43F3F for ; Fri, 28 Mar 2003 02:15:45 -0800 (PST) (envelope-from sebastian.ssmoller@gmx.net) Received: (qmail 31240 invoked by uid 0); 28 Mar 2003 10:15:43 -0000 Date: Fri, 28 Mar 2003 11:15:43 +0100 (MET) From: Sebastian Ssmoller To: audit@freebsd.org MIME-Version: 1.0 Subject: X-Priority: 3 (Normal) X-Authenticated-Sender: #0015005775@gmx.net X-Authenticated-IP: [192.102.158.90] Message-ID: <32044.1048846543@www30.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, hits=0.0 required=5.0 tests=none version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) 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 hello auditors/reviewers, i was interested in your work, so i subscribed to this list last week but there seem to be not much activity. am i on the wrong list ? i thought of becoming an auditor/reviewer too. but i am not that freebsd and security guru (but willing to learn ;-) ). so my first question: is there a list of recommanded reading? (of course i read the papers linked on the project page and i am currently reading the freebsd developer handbook) and my second question is: where to start ? is there a good place for beginners of this project ? and last question (for now ;-) ): what tools are you using ? (lint, ...) thanx sebastian -- +++ GMX - Mail, Messaging & more http://www.gmx.net +++ Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message