--------------------- PatchSet 1154 Date: 2001/01/07 09:48:26 Author: hno Branch: auth_rewrite Tag: (none) Log: indent Members: ChangeLog:1.1.1.3.10.7.2.2->1.1.1.3.10.7.2.3 auth_modules/LDAP/squid_ldap_auth.c:1.1.1.1->1.1.1.1.26.1 auth_modules/MSNT/allowusers.c:1.1.4.1->1.1.4.1.2.1 auth_modules/MSNT/byteorder.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/confload.c:1.1.4.1->1.1.4.1.2.1 auth_modules/MSNT/denyusers.c:1.1.6.2->1.1.6.2.2.1 auth_modules/MSNT/md4.c:1.1.1.1->1.1.1.1.26.1 auth_modules/MSNT/msntauth.c:1.1.4.1->1.1.4.1.2.1 auth_modules/MSNT/rfcnb-common.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb-error.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb-io.c:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb-io.h:1.1.1.1->1.1.1.1.26.1 auth_modules/MSNT/rfcnb-priv.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb-util.c:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb-util.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/rfcnb.h:1.1.1.1->1.1.1.1.26.1 auth_modules/MSNT/session.c:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/smbdes.c:1.1.1.1->1.1.1.1.26.1 auth_modules/MSNT/smbencrypt.c:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/smblib-common.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/smblib-priv.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/smblib-util.c:1.1.1.1.10.1.2.1->1.1.1.1.10.1.2.2 auth_modules/MSNT/smblib.c:1.1.1.1.10.2.2.1->1.1.1.1.10.2.2.2 auth_modules/MSNT/smblib.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/std-defines.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/std-includes.h:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/valid.c:1.1.1.1.10.1->1.1.1.1.10.1.2.1 auth_modules/MSNT/valid.h:1.1.1.1->1.1.1.1.26.1 auth_modules/NCSA/ncsa_auth.c:1.1.1.1->1.1.1.1.30.1 auth_modules/SMB/smb_auth.c:1.1.1.2.10.1->1.1.1.2.10.1.2.1 auth_modules/getpwnam/getpwnam_auth.c:1.1.1.1->1.1.1.1.30.1 include/Array.h:1.1.1.1->1.1.1.1.26.1 include/Stack.h:1.1.1.1->1.1.1.1.26.1 include/asn1.h:1.1.1.1->1.1.1.1.26.1 include/ntlmauth.h:1.1.4.2->1.1.4.3 include/radix.h:1.1.1.1->1.1.1.1.26.1 include/snmp_client.h:1.1.1.1->1.1.1.1.26.1 include/snmp_pdu.h:1.1.1.1->1.1.1.1.26.1 include/snmp_vars.h:1.1.1.2->1.1.1.2.22.1 lib/GNUregex.c:1.1.1.1->1.1.1.1.26.1 lib/base64.c:1.1.1.1.14.1->1.1.1.1.14.1.2.1 lib/dlmalloc.c:1.1.1.1->1.1.1.1.26.1 lib/ntlmauth.c:1.1.4.4->1.1.4.5 lib/util.c:1.1.1.3.10.5.2.1->1.1.1.3.10.5.2.2 lib/uudecode.c:1.1.1.1->1.1.1.1.26.1 ntlm_auth_modules/NTLMSSP/libntlmssp.c:1.1.2.12.2.7->1.1.2.12.2.8 ntlm_auth_modules/NTLMSSP/ntlm.h:1.1.2.12.2.7->1.1.2.12.2.8 ntlm_auth_modules/NTLMSSP/ntlm_auth.c:1.1.2.10.2.7->1.1.2.10.2.8 ntlm_auth_modules/NTLMSSP/smbval/byteorder.h:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/NTLMSSP/smbval/md4.c:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-common.h:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-error.h:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-io.c:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-io.h:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-priv.h:1.1.2.2.2.3->1.1.2.2.2.4 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-util.c:1.1.2.1.2.4->1.1.2.1.2.5 ntlm_auth_modules/NTLMSSP/smbval/rfcnb-util.h:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/rfcnb.h:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/session.c:1.1.2.1.2.4->1.1.2.1.2.5 ntlm_auth_modules/NTLMSSP/smbval/smbdes.c:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/NTLMSSP/smbval/smbdes.h:1.1.2.3->1.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/smbencrypt.c:1.1.2.1.2.4->1.1.2.1.2.5 ntlm_auth_modules/NTLMSSP/smbval/smbencrypt.h:1.1.2.3->1.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/smblib-common.h:1.1.2.2.2.2->1.1.2.2.2.3 ntlm_auth_modules/NTLMSSP/smbval/smblib-priv.h:1.1.2.2.2.4->1.1.2.2.2.5 ntlm_auth_modules/NTLMSSP/smbval/smblib-util.c:1.1.2.1.2.5->1.1.2.1.2.6 ntlm_auth_modules/NTLMSSP/smbval/smblib.c:1.1.2.6.2.5->1.1.2.6.2.6 ntlm_auth_modules/NTLMSSP/smbval/smblib.h:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/std-defines.h:1.1.2.3.2.2->1.1.2.3.2.3 ntlm_auth_modules/NTLMSSP/smbval/std-includes.h:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/NTLMSSP/smbval/valid.c:1.1.2.1.2.3->1.1.2.1.2.4 ntlm_auth_modules/NTLMSSP/smbval/valid.h:1.1.2.1.2.2->1.1.2.1.2.3 ntlm_auth_modules/fakeauth/fakeauth_auth.c:1.1.2.6.2.7->1.1.2.6.2.8 ntlm_auth_modules/fakeauth/ntlm.h:1.1.2.3.2.2->1.1.2.3.2.3 snmplib/coexistance.c:1.1.1.1->1.1.1.1.30.1 snmplib/mib.c:1.1.1.1->1.1.1.1.30.1 snmplib/snmp_api.c:1.1.1.1->1.1.1.1.30.1 snmplib/snmp_api_error.c:1.1.1.1->1.1.1.1.30.1 snmplib/snmp_msg.c:1.1.1.1->1.1.1.1.30.1 snmplib/snmp_pdu.c:1.1.1.1->1.1.1.1.30.1 src/HttpRequest.c:1.1.1.3.10.2.2.3->1.1.1.3.10.2.2.4 src/access_log.c:1.1.1.3.12.7.2.4->1.1.1.3.12.7.2.5 src/acl.c:1.1.1.3.12.26.2.22->1.1.1.3.12.26.2.23 src/authenticate.c:1.1.1.3.12.17.2.23->1.1.1.3.12.17.2.24 src/cache_cf.c:1.1.1.3.4.1.2.9.2.15->1.1.1.3.4.1.2.9.2.16 src/client_side.c:1.1.1.3.4.1.2.30.2.16->1.1.1.3.4.1.2.30.2.17 src/defines.h:1.1.1.3.12.9.2.4->1.1.1.3.12.9.2.5 src/enums.h:1.1.1.3.12.15.2.6->1.1.1.3.12.15.2.7 src/errorpage.c:1.1.1.3.10.9.2.8->1.1.1.3.10.9.2.9 src/ftp.c:1.1.1.3.4.1.2.8.2.3->1.1.1.3.4.1.2.8.2.4 src/globals.h:1.1.1.3.12.8.2.3->1.1.1.3.12.8.2.4 src/helper.c:1.1.1.3.12.13.2.6->1.1.1.3.12.13.2.7 src/http.c:1.1.1.3.4.1.2.10.2.5->1.1.1.3.4.1.2.10.2.6 src/main.c:1.1.1.3.4.1.2.12.2.5->1.1.1.3.4.1.2.12.2.6 src/mem.c:1.1.1.3.12.9.2.2->1.1.1.3.12.9.2.3 src/protos.h:1.1.1.3.12.17.2.20->1.1.1.3.12.17.2.21 src/redirect.c:1.1.1.3.4.1.2.2.2.3->1.1.1.3.4.1.2.2.2.4 src/structs.h:1.1.1.3.4.1.2.26.2.25->1.1.1.3.4.1.2.26.2.26 src/tools.c:1.1.1.3.10.7.2.5->1.1.1.3.10.7.2.6 src/typedefs.h:1.1.1.3.12.13.2.17->1.1.1.3.12.13.2.18 src/auth/basic/auth_basic.c:1.1.2.20->1.1.2.21 src/auth/basic/auth_basic.h:1.1.2.6->1.1.2.7 src/auth/ntlm/auth_ntlm.c:1.1.2.17->1.1.2.18 src/auth/ntlm/auth_ntlm.h:1.1.2.6->1.1.2.7 src/fs/ufs/store_dir_ufs.c:1.1.10.8.2.4->1.1.10.8.2.5 src/repl/lru/store_repl_lru.c:1.1.10.2.2.1->1.1.10.2.2.2 test-suite/hash.c:1.1.1.1->1.1.1.1.26.1 test-suite/hash.h:1.1.1.1->1.1.1.1.30.1 test-suite/membanger.c:1.1.1.1->1.1.1.1.30.1 test-suite/pconn-banger.c:1.1.1.1->1.1.1.1.30.1 test-suite/tcp-banger3.c:1.1.1.2->1.1.1.2.30.1 test-suite/waiter.c:1.1.1.1->1.1.1.1.30.1 Index: squid/ChangeLog =================================================================== RCS file: /cvsroot/squid-sf//squid/ChangeLog,v retrieving revision 1.1.1.3.10.7.2.2 retrieving revision 1.1.1.3.10.7.2.3 diff -u -r1.1.1.3.10.7.2.2 -r1.1.1.3.10.7.2.3 --- squid/ChangeLog 30 Dec 2000 22:48:18 -0000 1.1.1.3.10.7.2.2 +++ squid/ChangeLog 7 Jan 2001 09:48:26 -0000 1.1.1.3.10.7.2.3 @@ -1,5 +1,12 @@ Changes to squid-2.5 + - Major rewrite of proxy authentication to support other schemes + than basic. First in the line is NTLM support but others can + easily be added (digest is on the way). See Programmers Guide. + (Robert Collins & Chemolli Francesco) + - Reworked how request bodies are passed down to the protocols. + Now all client side processing is inside client_side.c, and + the pass and pump modules is no longer used. - Fixed forwarding/peer loop detection code (Brian Degenhardt) - now a peer is ignored if it turns out to be us, rather than committing suicide @@ -71,9 +78,6 @@ a more modular fashion. The object replacement and IO is now responsibility of the storage directory, and not of the storage manager. - - Reworked how request bodies are passed down to the protocols. - Now all client side processing is inside client_side.c, and - the pass and pump modules is no longer used. - Fixed a bogous MD5 mismatch warning sometimes seen when using aufs or diskd stores - Added --enable-stacktraces configure option to set PRINT_STACK_TRACE, Index: squid/auth_modules/LDAP/squid_ldap_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/LDAP/Attic/squid_ldap_auth.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.26.1 diff -u -r1.1.1.1 -r1.1.1.1.26.1 --- squid/auth_modules/LDAP/squid_ldap_auth.c 26 Jan 2000 03:25:00 -0000 1.1.1.1 +++ squid/auth_modules/LDAP/squid_ldap_auth.c 7 Jan 2001 09:48:27 -0000 1.1.1.1.26.1 @@ -1,22 +1,22 @@ /* - - squid_ldap_auth: authentication via ldap for squid proxy server - - Author: Glen Newton - glen.newton@nrc.ca - Advanced Services - CISTI - National Research Council - - Usage: squid_ldap_auth - - Dependencies: You need to get the OpenLDAP libraries - from http://www.openldap.org - - License: squid_ldap_auth is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2, - or (at your option) any later version. + * + * squid_ldap_auth: authentication via ldap for squid proxy server + * + * Author: Glen Newton + * glen.newton@nrc.ca + * Advanced Services + * CISTI + * National Research Council + * + * Usage: squid_ldap_auth + * + * Dependencies: You need to get the OpenLDAP libraries + * from http://www.openldap.org + * + * License: squid_ldap_auth is free software; you can redistribute it + * and/or modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2, + * or (at your option) any later version. */ #include @@ -28,79 +28,70 @@ /* Change this to your search base */ #define SEARCHBASE "ou=people,o=nrc.ca" -int checkLDAP( LDAP *ld, char *userid, char *password); +int checkLDAP(LDAP * ld, char *userid, char *password); -int main(int argc, char **argv) +int +main(int argc, char **argv) { - char buf[256]; - char *user, *passwd, *p; - char *ldapServer; - LDAP *ld; - LDAPMessage *result, *e; - - setbuf(stdout, NULL); - - if (argc != 2) - { - fprintf(stderr, "Usage: squid_ldap_auth ldap_server_name\n"); - exit(1); + char buf[256]; + char *user, *passwd, *p; + char *ldapServer; + LDAP *ld; + LDAPMessage *result, *e; + + setbuf(stdout, NULL); + + if (argc != 2) { + fprintf(stderr, "Usage: squid_ldap_auth ldap_server_name\n"); + exit(1); } + ldapServer = (char *) argv[1]; - ldapServer = (char*)argv[1]; - - while (fgets(buf, 256, stdin) != NULL) - { - /* You can put this ldap connect outside the loop, but i didn't want to - have the connection open too much. If you have a site which will - be doing >1 authentication per second, you should move this (and the - below ldap_unbind()) outside the loop. - */ - if( (ld = ldap_init(ldapServer, LDAP_PORT)) == NULL) - { - fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n", - ldapServer, LDAP_PORT); - exit(1); + while (fgets(buf, 256, stdin) != NULL) { + /* You can put this ldap connect outside the loop, but i didn't want to + * have the connection open too much. If you have a site which will + * be doing >1 authentication per second, you should move this (and the + * below ldap_unbind()) outside the loop. + */ + if ((ld = ldap_init(ldapServer, LDAP_PORT)) == NULL) { + fprintf(stderr, "\nUnable to connect to LDAP server:%s port:%d\n", + ldapServer, LDAP_PORT); + exit(1); } + if ((p = strchr(buf, '\n')) != NULL) + *p = '\0'; /* strip \n */ - if ((p = strchr(buf, '\n')) != NULL) - *p = '\0'; /* strip \n */ - - if ((user = strtok(buf, " ")) == NULL) - { - printf("ERR\n"); - continue; + if ((user = strtok(buf, " ")) == NULL) { + printf("ERR\n"); + continue; } - if ((passwd = strtok(NULL, "")) == NULL) - { - printf("ERR\n"); - continue; + if ((passwd = strtok(NULL, "")) == NULL) { + printf("ERR\n"); + continue; } - if(checkLDAP(ld, user, passwd) != 0) - { - printf("ERR\n"); - continue; + if (checkLDAP(ld, user, passwd) != 0) { + printf("ERR\n"); + continue; + } else { + printf("OK\n"); } - else - { - printf("OK\n"); - } - ldap_unbind(ld); + ldap_unbind(ld); } } -int checkLDAP( LDAP *ld, char *userid, char *password) +int +checkLDAP(LDAP * ld, char *userid, char *password) { - char str[256]; + char str[256]; + + /*sprintf(str,"uid=[%s][%s], %s",userid, password, SEARCHBASE); */ + sprintf(str, "uid=%s, %s", userid, SEARCHBASE); - /*sprintf(str,"uid=[%s][%s], %s",userid, password, SEARCHBASE); */ - sprintf(str,"uid=%s, %s",userid, SEARCHBASE); - - if(ldap_simple_bind_s(ld, str, password) != LDAP_SUCCESS) - { - /*fprintf(stderr, "\nUnable to bind\n");*/ - return 33; + if (ldap_simple_bind_s(ld, str, password) != LDAP_SUCCESS) { + /*fprintf(stderr, "\nUnable to bind\n"); */ + return 33; } - return 0; + return 0; } Index: squid/auth_modules/MSNT/allowusers.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/allowusers.c,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.1.2.1 diff -u -r1.1.4.1 -r1.1.4.1.2.1 --- squid/auth_modules/MSNT/allowusers.c 5 Nov 2000 13:42:35 -0000 1.1.4.1 +++ squid/auth_modules/MSNT/allowusers.c 7 Jan 2001 09:48:27 -0000 1.1.4.1.2.1 @@ -1,13 +1,13 @@ /* - allowusers.c - (C) 2000 Antonino Iannella, Stellar-X Pty Ltd - Released under GPL, see COPYING-2.0 for details. - - These routines are to allow users attempting to use the proxy which - have been explicitly allowed by the system administrator. - The code originated from denyusers.c. -*/ + * allowusers.c + * (C) 2000 Antonino Iannella, Stellar-X Pty Ltd + * Released under GPL, see COPYING-2.0 for details. + * + * These routines are to allow users attempting to use the proxy which + * have been explicitly allowed by the system administrator. + * The code originated from denyusers.c. + */ #include #include @@ -20,191 +20,173 @@ #include #include -#define NAMELEN 50 /* Maximum username length */ +#define NAMELEN 50 /* Maximum username length */ /* Global variables */ -char *AllowedUsers; /* Pointer to string of allowed users */ -off_t AllowUserSize; /* Size of allowed users file */ -struct stat FileBuf; /* Stat data buffer */ -time_t LastModTime; /* Last allowed user file modification time */ +char *AllowedUsers; /* Pointer to string of allowed users */ +off_t AllowUserSize; /* Size of allowed users file */ +struct stat FileBuf; /* Stat data buffer */ +time_t LastModTime; /* Last allowed user file modification time */ -char Allowuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */ +char Allowuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */ /* Function declarations */ -int Read_allowusers(); -int Check_ifuserallowed(char *); +int Read_allowusers(); +int Check_ifuserallowed(char *); void Checkforchange(); void Checktimer(); /* - Reads the allowed users file for all users to be permitted. - Returns 0 if the user list was successfully loaded, - and 1 in case of error. - Logs any messages to the syslog daemon. -*/ - -int Read_allowusers() + * Reads the allowed users file for all users to be permitted. + * Returns 0 if the user list was successfully loaded, + * and 1 in case of error. + * Logs any messages to the syslog daemon. + */ + +int +Read_allowusers() { - FILE *AFile; /* Allowed users file pointer */ - off_t APos = 0; /* File counter */ - char AChar; /* Character buffer */ - - /* Stat the file. If it does not exist, save the size as zero. - Clear the allowed user string. Return. */ - if (stat(Allowuserpath, &FileBuf) == -1) - { - if (errno == ENOENT) - { - LastModTime = (time_t) 0; - AllowUserSize = 0; - free(AllowedUsers); - AllowedUsers = malloc(sizeof(char)); - AllowedUsers[0] = '\0'; - return 0; - } - else - { - syslog(LOG_USER | LOG_ERR, strerror(errno)); - return 1; - } - } - - /* If it exists, save the modification time and size */ - LastModTime = FileBuf.st_mtime; - AllowUserSize = FileBuf.st_size; - - /* Handle the special case of a zero length file */ - if (AllowUserSize == 0) - { - free(AllowedUsers); - AllowedUsers = malloc(sizeof(char)); - AllowedUsers[0] = '\0'; - return 0; - } - - /* Free and allocate space for a string to store the allowed usernames */ - free(AllowedUsers); - - if ((AllowedUsers = malloc(sizeof(char) * (AllowUserSize + 3))) == NULL) - { - syslog(LOG_USER | LOG_ERR, "Read_allowusers: malloc(AllowedUsers) failed."); - return 1; - } - - /* Open the allowed users file. Report any errors. */ - - if ((AFile = fopen(Allowuserpath, "r")) == NULL) - { - syslog(LOG_USER | LOG_ERR, "Read_allowusers: Failed to open allowed user file."); - syslog(LOG_USER | LOG_ERR, strerror(errno)); - return 1; - } - - /* Read user names into the AllowedUsers string. - Make sure each string is delimited by a space. */ - - AllowedUsers[APos++] = ' '; - - while (!feof(AFile)) - { - if ((AChar = fgetc(AFile)) == EOF) - break; - else - { - if (isspace(AChar)) - AllowedUsers[APos++] = ' '; - else - AllowedUsers[APos++] = toupper(AChar); - } - } - - AllowedUsers[APos++] = ' '; - AllowedUsers[APos] = '\0'; - fclose(AFile); - return 0; + FILE *AFile; /* Allowed users file pointer */ + off_t APos = 0; /* File counter */ + char AChar; /* Character buffer */ + + /* Stat the file. If it does not exist, save the size as zero. + * Clear the allowed user string. Return. */ + if (stat(Allowuserpath, &FileBuf) == -1) { + if (errno == ENOENT) { + LastModTime = (time_t) 0; + AllowUserSize = 0; + free(AllowedUsers); + AllowedUsers = malloc(sizeof(char)); + AllowedUsers[0] = '\0'; + return 0; + } else { + syslog(LOG_USER | LOG_ERR, strerror(errno)); + return 1; + } + } + /* If it exists, save the modification time and size */ + LastModTime = FileBuf.st_mtime; + AllowUserSize = FileBuf.st_size; + + /* Handle the special case of a zero length file */ + if (AllowUserSize == 0) { + free(AllowedUsers); + AllowedUsers = malloc(sizeof(char)); + AllowedUsers[0] = '\0'; + return 0; + } + /* Free and allocate space for a string to store the allowed usernames */ + free(AllowedUsers); + + if ((AllowedUsers = malloc(sizeof(char) * (AllowUserSize + 3))) == NULL) { + syslog(LOG_USER | LOG_ERR, "Read_allowusers: malloc(AllowedUsers) failed."); + return 1; + } + /* Open the allowed users file. Report any errors. */ + + if ((AFile = fopen(Allowuserpath, "r")) == NULL) { + syslog(LOG_USER | LOG_ERR, "Read_allowusers: Failed to open allowed user file."); + syslog(LOG_USER | LOG_ERR, strerror(errno)); + return 1; + } + /* Read user names into the AllowedUsers string. + * Make sure each string is delimited by a space. */ + + AllowedUsers[APos++] = ' '; + + while (!feof(AFile)) { + if ((AChar = fgetc(AFile)) == EOF) + break; + else { + if (isspace(AChar)) + AllowedUsers[APos++] = ' '; + else + AllowedUsers[APos++] = toupper(AChar); + } + } + + AllowedUsers[APos++] = ' '; + AllowedUsers[APos] = '\0'; + fclose(AFile); + return 0; } /* - Check to see if the username provided by Squid appears in the allowed - user list. Returns 0 if the user was not found, and 1 if they were. -*/ + * Check to see if the username provided by Squid appears in the allowed + * user list. Returns 0 if the user was not found, and 1 if they were. + */ -int Check_ifuserallowed(char *ConnectingUser) +int +Check_ifuserallowed(char *ConnectingUser) { - static char CUBuf[NAMELEN + 1]; - static int x; - static char AllowMsg[256]; - - /* If user string is empty, allow */ - if (ConnectingUser[0] == '\0') - return 1; - - /* If allowed user list is empty, allow all users. - If no users are supposed to be using the proxy, stop squid instead. */ - if (AllowUserSize == 0) - return 1; - - /* Check if username string is found in the allowed user list. - If so, allow. If not, deny. Reconstruct the username - to have whitespace, to avoid finding wrong string subsets. */ - - sscanf(ConnectingUser, " %s ", CUBuf); - sprintf(CUBuf, " %s ", CUBuf); - - for (x = 0; x <= strlen(CUBuf); x++) - CUBuf[x] = toupper(CUBuf[x]); - - if (strstr(AllowedUsers, CUBuf) != NULL) - return 1; - else /* If NULL, they are not allowed to use the proxy */ - { - sprintf(AllowMsg, "Denied access to user '%s'.", CUBuf); - syslog(LOG_USER | LOG_ERR, AllowMsg); - return 0; - } + static char CUBuf[NAMELEN + 1]; + static int x; + static char AllowMsg[256]; + + /* If user string is empty, allow */ + if (ConnectingUser[0] == '\0') + return 1; + + /* If allowed user list is empty, allow all users. + * If no users are supposed to be using the proxy, stop squid instead. */ + if (AllowUserSize == 0) + return 1; + + /* Check if username string is found in the allowed user list. + * If so, allow. If not, deny. Reconstruct the username + * to have whitespace, to avoid finding wrong string subsets. */ + + sscanf(ConnectingUser, " %s ", CUBuf); + sprintf(CUBuf, " %s ", CUBuf); + + for (x = 0; x <= strlen(CUBuf); x++) + CUBuf[x] = toupper(CUBuf[x]); + + if (strstr(AllowedUsers, CUBuf) != NULL) + return 1; + else { /* If NULL, they are not allowed to use the proxy */ + sprintf(AllowMsg, "Denied access to user '%s'.", CUBuf); + syslog(LOG_USER | LOG_ERR, AllowMsg); + return 0; + } } /* - Checks if there has been a change in the allowed users file. - If the modification time has changed, then reload the allowed user list. - This function is called by the SIGHUP signal handler. -*/ + * Checks if there has been a change in the allowed users file. + * If the modification time has changed, then reload the allowed user list. + * This function is called by the SIGHUP signal handler. + */ -void Check_forallowchange() +void +Check_forallowchange() { - struct stat ChkBuf; /* Stat data buffer */ - - /* Stat the allowed users file. If it cannot be accessed, return. */ - - if (stat(Allowuserpath, &ChkBuf) == -1) - { - if (errno == ENOENT) - { - LastModTime = (time_t) 0; - AllowUserSize = 0; - free(AllowedUsers); - AllowedUsers = malloc(sizeof(char)); - AllowedUsers[0] = '\0'; - return; - } - else /* Report error when accessing file */ - { - syslog(LOG_USER | LOG_ERR, strerror(errno)); - return; - } - } - - /* If found, compare the modification time with the previously-recorded - modification time. - If the modification time has changed, reload the allowed user list. - Log a message of its actions. */ - - if (ChkBuf.st_mtime != LastModTime) - { - syslog(LOG_USER | LOG_INFO, "Check_forallowchange: Reloading allowed user list."); - Read_allowusers(); - } -} + struct stat ChkBuf; /* Stat data buffer */ + /* Stat the allowed users file. If it cannot be accessed, return. */ + + if (stat(Allowuserpath, &ChkBuf) == -1) { + if (errno == ENOENT) { + LastModTime = (time_t) 0; + AllowUserSize = 0; + free(AllowedUsers); + AllowedUsers = malloc(sizeof(char)); + AllowedUsers[0] = '\0'; + return; + } else { /* Report error when accessing file */ + syslog(LOG_USER | LOG_ERR, strerror(errno)); + return; + } + } + /* If found, compare the modification time with the previously-recorded + * modification time. + * If the modification time has changed, reload the allowed user list. + * Log a message of its actions. */ + + if (ChkBuf.st_mtime != LastModTime) { + syslog(LOG_USER | LOG_INFO, "Check_forallowchange: Reloading allowed user list."); + Read_allowusers(); + } +} Index: squid/auth_modules/MSNT/byteorder.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/byteorder.h,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/byteorder.h 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/byteorder.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,36 +1,36 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. - SMB Byte handling - Copyright (C) Andrew Tridgell 1992-1995 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Unix SMB/Netbios implementation. + * Version 1.9. + * SMB Byte handling + * Copyright (C) Andrew Tridgell 1992-1995 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #ifndef _BYTEORDER_H_ #define _BYTEORDER_H_ /* - This file implements macros for machine independent short and - int manipulation -*/ + * This file implements macros for machine independent short and + * int manipulation + */ #undef CAREFUL_ALIGNMENT /* we know that the 386 can handle misalignment and has the "right" - byteorder */ + * byteorder */ #ifdef __i386__ #define CAREFUL_ALIGNMENT 0 #endif @@ -44,7 +44,7 @@ #define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val)) typedef unsigned short uint16; -typedef unsigned int uint32; +typedef unsigned int uint32; #if CAREFUL_ALIGNMENT #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) @@ -59,11 +59,11 @@ #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val))) #else /* this handles things for architectures like the 386 that can handle - alignment errors */ + * alignment errors */ /* - WARNING: This section is dependent on the length of int16 and int32 - being correct -*/ + * WARNING: This section is dependent on the length of int16 and int32 + * being correct + */ #define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) #define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) #define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos))) Index: squid/auth_modules/MSNT/confload.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/confload.c,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.1.2.1 diff -u -r1.1.4.1 -r1.1.4.1.2.1 --- squid/auth_modules/MSNT/confload.c 5 Nov 2000 13:42:35 -0000 1.1.4.1 +++ squid/auth_modules/MSNT/confload.c 7 Jan 2001 09:48:27 -0000 1.1.4.1.2.1 @@ -1,14 +1,14 @@ /* - confload.c - (C) 2000 Antonino Iannella, Stellar-X Pty Ltd - Released under GPL, see COPYING-2.0 for details. - - These routines load the msntauth configuration file. - It stores the servers to query, sets the denied and - allowed user files, and provides the - authenticating function. -*/ + * confload.c + * (C) 2000 Antonino Iannella, Stellar-X Pty Ltd + * Released under GPL, see COPYING-2.0 for details. + * + * These routines load the msntauth configuration file. + * It stores the servers to query, sets the denied and + * allowed user files, and provides the + * authenticating function. + */ #include #include @@ -17,234 +17,219 @@ #include #include -#define CONFIGFILE "/usr/local/squid/etc/msntauth.conf" /* Path to configuration file */ +#define CONFIGFILE "/usr/local/squid/etc/msntauth.conf" /* Path to configuration file */ #define DENYUSERSDEFAULT "/usr/local/squid/etc/denyusers" #define ALLOWUSERSDEFAULT "/usr/local/squid/etc/allowusers" -#define MAXSERVERS 5 /* Maximum number of servers to query. This number can be increased. */ +#define MAXSERVERS 5 /* Maximum number of servers to query. This number can be increased. */ #define NTHOSTLEN 65 -extern char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */ +extern char Denyuserpath[MAXPATHLEN]; /* MAXPATHLEN defined in param.h */ extern char Allowuserpath[MAXPATHLEN]; -typedef struct _ServerTuple -{ - char pdc[NTHOSTLEN]; - char bdc[NTHOSTLEN]; - char domain[NTHOSTLEN]; +typedef struct _ServerTuple { + char pdc[NTHOSTLEN]; + char bdc[NTHOSTLEN]; + char domain[NTHOSTLEN]; } ServerTuple; -ServerTuple ServerArray[MAXSERVERS]; /* Array of servers to query */ -int Serversqueried = 0; /* Number of servers queried */ +ServerTuple ServerArray[MAXSERVERS]; /* Array of servers to query */ +int Serversqueried = 0; /* Number of servers queried */ /* Declarations */ -int OpenConfigFile(); +int OpenConfigFile(); void ProcessLine(char *); void AddServer(char *, char *, char *); -int QueryServers(char *, char *); -int QueryServerForUser(int, char *, char *); -extern int Valid_User(char *,char *,char *,char *, char *); +int QueryServers(char *, char *); +int QueryServerForUser(int, char *, char *); +extern int Valid_User(char *, char *, char *, char *, char *); /* - Opens and reads the configuration file. - Returns 0 on success, or 1 for error. -*/ - -int OpenConfigFile() -{ - FILE *ConfigFile; - char Confbuf[2049]; /* Line reading buffer */ - - /* Initialise defaults */ + * Opens and reads the configuration file. + * Returns 0 on success, or 1 for error. + */ + +int +OpenConfigFile() +{ + FILE *ConfigFile; + char Confbuf[2049]; /* Line reading buffer */ + + /* Initialise defaults */ + + Serversqueried = 0; + strcpy(Denyuserpath, DENYUSERSDEFAULT); + strcpy(Allowuserpath, ALLOWUSERSDEFAULT); + + /* Open file */ + if ((ConfigFile = fopen(CONFIGFILE, "r")) == NULL) { + syslog(LOG_USER | LOG_ERR, "OpenConfigFile: Failed to open %s.", CONFIGFILE); + syslog(LOG_USER | LOG_ERR, strerror(errno)); + return 1; + } + /* Read in, one line at a time */ - Serversqueried = 0; - strcpy(Denyuserpath, DENYUSERSDEFAULT); - strcpy(Allowuserpath, ALLOWUSERSDEFAULT); - - /* Open file */ - if ((ConfigFile = fopen(CONFIGFILE, "r")) == NULL) - { - syslog(LOG_USER | LOG_ERR, "OpenConfigFile: Failed to open %s.", CONFIGFILE); - syslog(LOG_USER | LOG_ERR, strerror(errno)); - return 1; - } - - /* Read in, one line at a time */ - - while (!feof(ConfigFile)) - { - Confbuf[0] = '\0'; - fgets(Confbuf, 2049, ConfigFile); - ProcessLine(Confbuf); - } - - /* Check that at least one server is being queried. Report error if not. - Denied and allowed user files are hardcoded, so it's fine if they're - not set in the confugration file. */ - - if (Serversqueried == 0) - { - syslog(LOG_USER | LOG_ERR, "OpenConfigFile: No servers set in %s. At least one is needed.", CONFIGFILE); - return 1; - } + while (!feof(ConfigFile)) { + Confbuf[0] = '\0'; + fgets(Confbuf, 2049, ConfigFile); + ProcessLine(Confbuf); + } - fclose(ConfigFile); - return 0; + /* Check that at least one server is being queried. Report error if not. + * Denied and allowed user files are hardcoded, so it's fine if they're + * not set in the confugration file. */ + + if (Serversqueried == 0) { + syslog(LOG_USER | LOG_ERR, "OpenConfigFile: No servers set in %s. At least one is needed.", CONFIGFILE); + return 1; + } + fclose(ConfigFile); + return 0; } /* Parses a configuration file line. */ -void ProcessLine(char *Linebuf) +void +ProcessLine(char *Linebuf) { - char *Directive; - char *Param1; - char *Param2; - char *Param3; - - /* Ignore empty lines */ - if (strlen(Linebuf) == 0) - return; - - /* Break up on whitespaces */ - if ((Directive = strtok(Linebuf, " \t\n")) == NULL) - return; - - /* Check for a comment line. If found, stop . */ - if (Directive[0] == '#') - return; - - /* Check for server line. Check for 3 parameters. */ - if (strcasecmp(Directive, "server") == 0) - { - Param1 = strtok(NULL, " \t\n"); - Param2 = strtok(NULL, " \t\n"); - Param3 = strtok(NULL, " \t\n"); - - if ((Param1[0] == '\0') || - (Param2[0] == '\0') || - (Param3[0] == '\0')) - { - syslog(LOG_USER | LOG_ERR, "ProcessLine: A 'server' line needs PDC, BDC, and domain parameters."); - return; - } - - AddServer(Param1, Param2, Param3); - return; - } - - /* Check for denyusers line */ - if (strcasecmp(Directive, "denyusers") == 0) - { - Param1 = strtok(NULL, " \t\n"); - - if (Param1[0] == '\0') - { - syslog(LOG_USER | LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter."); - return; - } - - strcpy(Denyuserpath, Param1); - return; - } - - /* Check for allowusers line */ - if (strcasecmp(Directive, "allowusers") == 0) - { - Param1 = strtok(NULL, " \t\n"); - - if (Param1[0] == '\0') - { - syslog(LOG_USER | LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter."); - return; - } - - strcpy(Allowuserpath, Param1); - return; - } - - /* Reports error for unknown line */ - syslog(LOG_USER | LOG_ERR, "ProcessLine: Ignoring '%s' line.", Directive); + char *Directive; + char *Param1; + char *Param2; + char *Param3; + + /* Ignore empty lines */ + if (strlen(Linebuf) == 0) + return; + + /* Break up on whitespaces */ + if ((Directive = strtok(Linebuf, " \t\n")) == NULL) + return; + + /* Check for a comment line. If found, stop . */ + if (Directive[0] == '#') + return; + + /* Check for server line. Check for 3 parameters. */ + if (strcasecmp(Directive, "server") == 0) { + Param1 = strtok(NULL, " \t\n"); + Param2 = strtok(NULL, " \t\n"); + Param3 = strtok(NULL, " \t\n"); + + if ((Param1[0] == '\0') || + (Param2[0] == '\0') || + (Param3[0] == '\0')) { + syslog(LOG_USER | LOG_ERR, "ProcessLine: A 'server' line needs PDC, BDC, and domain parameters."); + return; + } + AddServer(Param1, Param2, Param3); + return; + } + /* Check for denyusers line */ + if (strcasecmp(Directive, "denyusers") == 0) { + Param1 = strtok(NULL, " \t\n"); + + if (Param1[0] == '\0') { + syslog(LOG_USER | LOG_ERR, "ProcessLine: A 'denyusers' line needs a filename parameter."); + return; + } + strcpy(Denyuserpath, Param1); + return; + } + /* Check for allowusers line */ + if (strcasecmp(Directive, "allowusers") == 0) { + Param1 = strtok(NULL, " \t\n"); + + if (Param1[0] == '\0') { + syslog(LOG_USER | LOG_ERR, "ProcessLine: An 'allowusers' line needs a filename parameter."); + return; + } + strcpy(Allowuserpath, Param1); + return; + } + /* Reports error for unknown line */ + syslog(LOG_USER | LOG_ERR, "ProcessLine: Ignoring '%s' line.", Directive); } /* - Adds a server to query to the server array. - Checks if the number of servers to query is not exceeded. - Does not allow parameters longer than NTHOSTLEN. -*/ - -void AddServer(char *ParamPDC, char *ParamBDC, char *ParamDomain) -{ - if (Serversqueried + 1 > MAXSERVERS) - { - syslog(LOG_USER | LOG_ERR, "ProcessLine: Ignoring '%s' server line; too many servers.", ParamPDC); - return; - } - - Serversqueried++; - strncpy(ServerArray[Serversqueried].pdc, ParamPDC, NTHOSTLEN); - strncpy(ServerArray[Serversqueried].bdc, ParamBDC, NTHOSTLEN); - strncpy(ServerArray[Serversqueried].domain, ParamDomain, NTHOSTLEN); - ServerArray[Serversqueried].pdc[NTHOSTLEN - 1] = '\0'; - ServerArray[Serversqueried].bdc[NTHOSTLEN - 1] = '\0'; - ServerArray[Serversqueried].domain[NTHOSTLEN - 1] = '\0'; + * Adds a server to query to the server array. + * Checks if the number of servers to query is not exceeded. + * Does not allow parameters longer than NTHOSTLEN. + */ + +void +AddServer(char *ParamPDC, char *ParamBDC, char *ParamDomain) +{ + if (Serversqueried + 1 > MAXSERVERS) { + syslog(LOG_USER | LOG_ERR, "ProcessLine: Ignoring '%s' server line; too many servers.", ParamPDC); + return; + } + Serversqueried++; + strncpy(ServerArray[Serversqueried].pdc, ParamPDC, NTHOSTLEN); + strncpy(ServerArray[Serversqueried].bdc, ParamBDC, NTHOSTLEN); + strncpy(ServerArray[Serversqueried].domain, ParamDomain, NTHOSTLEN); + ServerArray[Serversqueried].pdc[NTHOSTLEN - 1] = '\0'; + ServerArray[Serversqueried].bdc[NTHOSTLEN - 1] = '\0'; + ServerArray[Serversqueried].domain[NTHOSTLEN - 1] = '\0'; } /* - Cycles through all servers to query. - Returns 0 if one server could authenticate the user. - Returns 1 if no server authenticated the user. -*/ - -int QueryServers(char *username, char *password) -{ - int Queryresult = 1; /* Default result is an error */ - int x = 1; - - while (x <= Serversqueried) - { /* Query one server. Change Queryresult if user passed. */ - if (QueryServerForUser(x++, username, password) == 0) - { - Queryresult = 0; - break; + * Cycles through all servers to query. + * Returns 0 if one server could authenticate the user. + * Returns 1 if no server authenticated the user. + */ + +int +QueryServers(char *username, char *password) +{ + int Queryresult = 1; /* Default result is an error */ + int x = 1; + + while (x <= Serversqueried) { /* Query one server. Change Queryresult if user passed. */ + if (QueryServerForUser(x++, username, password) == 0) { + Queryresult = 0; + break; + } } - } - return Queryresult; + return Queryresult; } /* - Attempts to authenticate the user with one server. - Logs syslog messages for different errors. - Returns 0 on success, non-zero on failure. -*/ - -int QueryServerForUser(int x, char *username, char *password) -{ - int result = 1; - - result = Valid_User(username, password, ServerArray[x].pdc, - ServerArray[x].bdc, ServerArray[x].domain); - - switch (result) /* Write any helpful syslog messages */ - { - case 0 : break; - case 1 : syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.", username); - break; - case 2 : syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.", username); - break; - case 3 : syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.", username); - } + * Attempts to authenticate the user with one server. + * Logs syslog messages for different errors. + * Returns 0 on success, non-zero on failure. + */ + +int +QueryServerForUser(int x, char *username, char *password) +{ + int result = 1; + + result = Valid_User(username, password, ServerArray[x].pdc, + ServerArray[x].bdc, ServerArray[x].domain); + + switch (result) { /* Write any helpful syslog messages */ + case 0: + break; + case 1: + syslog(LOG_AUTHPRIV | LOG_INFO, "Server error when checking %s.", username); + break; + case 2: + syslog(LOG_AUTHPRIV | LOG_INFO, "Protocol error when checking %s.", username); + break; + case 3: + syslog(LOG_AUTHPRIV | LOG_INFO, "Authentication failed for %s.", username); + } - return result; + return result; } /* Valid_User return codes - - - 0 - User authenticated successfully. - 1 - Server error. - 2 - Protocol error. - 3 - Logon error; Incorrect password or username given. -*/ - + * + * 0 - User authenticated successfully. + * 1 - Server error. + * 2 - Protocol error. + * 3 - Logon error; Incorrect password or username given. + */ Index: squid/auth_modules/MSNT/denyusers.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/denyusers.c,v retrieving revision 1.1.6.2 retrieving revision 1.1.6.2.2.1 diff -u -r1.1.6.2 -r1.1.6.2.2.1 --- squid/auth_modules/MSNT/denyusers.c 4 Nov 2000 00:30:04 -0000 1.1.6.2 +++ squid/auth_modules/MSNT/denyusers.c 7 Jan 2001 09:48:27 -0000 1.1.6.2.2.1 @@ -49,7 +49,7 @@ * Logs any messages to the syslog daemon. */ -int +int Read_denyusers() { FILE *DFile; /* Denied user file pointer */ @@ -123,7 +123,7 @@ * user list. Returns 0 if the user was not found, and 1 if they were. */ -int +int Check_ifuserdenied(char *ConnectingUser) { static char CUBuf[NAMELEN + 1]; @@ -163,7 +163,7 @@ * This function is called by the SIGHUP signal handler. */ -void +void Check_fordenychange() { struct stat ChkBuf; /* Stat data buffer */ @@ -200,7 +200,7 @@ * Else return 0. */ -int +int Check_user(char *ConnectingUser) { if (Check_ifuserdenied(ConnectingUser) == 1) @@ -218,7 +218,7 @@ * It is also run after every 60 seconds, at the next request. */ -void +void Check_forchange() { Check_fordenychange(); @@ -231,7 +231,7 @@ * denied user file. If longer than one minute hasn't passed, return. */ -void +void Checktimer() { static time_t Lasttime; /* The last time the timer was checked */ Index: squid/auth_modules/MSNT/md4.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/md4.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.26.1 diff -u -r1.1.1.1 -r1.1.1.1.26.1 --- squid/auth_modules/MSNT/md4.c 26 Jan 2000 03:25:00 -0000 1.1.1.1 +++ squid/auth_modules/MSNT/md4.c 7 Jan 2001 09:48:27 -0000 1.1.1.1.26.1 @@ -1,53 +1,57 @@ /* - Unix SMB/Netbios implementation. - Version 1.9. - a implementation of MD4 designed for use in the SMB authentication protocol - Copyright (C) Andrew Tridgell 1997 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Unix SMB/Netbios implementation. + * Version 1.9. + * a implementation of MD4 designed for use in the SMB authentication protocol + * Copyright (C) Andrew Tridgell 1997 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /* NOTE: This code makes no attempt to be fast! - - It assumes that a int is at least 32 bits long -*/ + * + * It assumes that a int is at least 32 bits long + */ typedef unsigned int uint32; static uint32 A, B, C, D; -static uint32 F(uint32 X, uint32 Y, uint32 Z) +static uint32 +F(uint32 X, uint32 Y, uint32 Z) { - return (X&Y) | ((~X)&Z); + return (X & Y) | ((~X) & Z); } -static uint32 G(uint32 X, uint32 Y, uint32 Z) +static uint32 +G(uint32 X, uint32 Y, uint32 Z) { - return (X&Y) | (X&Z) | (Y&Z); + return (X & Y) | (X & Z) | (Y & Z); } -static uint32 H(uint32 X, uint32 Y, uint32 Z) +static uint32 +H(uint32 X, uint32 Y, uint32 Z) { - return X^Y^Z; + return X ^ Y ^ Z; } -static uint32 lshift(uint32 x, int s) +static uint32 +lshift(uint32 x, int s) { - x &= 0xFFFFFFFF; - return ((x<>(32-s)); + x &= 0xFFFFFFFF; + return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); } #define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s) @@ -55,117 +59,151 @@ #define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s) /* this applies md4 to 64 byte chunks */ -static void mdfour64(uint32 *M) +static void +mdfour64(uint32 * M) { - int j; - uint32 AA, BB, CC, DD; - uint32 X[16]; - - for (j=0;j<16;j++) - X[j] = M[j]; - - AA = A; BB = B; CC = C; DD = D; - - ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); - ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); - ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); - ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); - ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); - ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); - ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); - ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); - - ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); - ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); - ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); - ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); - ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); - ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); - ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); - ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); - - ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); - ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); - ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); - ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); - ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); - ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); - ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); - ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); - - A += AA; B += BB; C += CC; D += DD; - - A &= 0xFFFFFFFF; B &= 0xFFFFFFFF; - C &= 0xFFFFFFFF; D &= 0xFFFFFFFF; - - for (j=0;j<16;j++) - X[j] = 0; -} - -static void copy64(uint32 *M, unsigned char *in) -{ - int i; - - for (i=0;i<16;i++) - M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | - (in[i*4+1]<<8) | (in[i*4+0]<<0); -} - -static void copy4(unsigned char *out,uint32 x) -{ - out[0] = x&0xFF; - out[1] = (x>>8)&0xFF; - out[2] = (x>>16)&0xFF; - out[3] = (x>>24)&0xFF; + int j; + uint32 AA, BB, CC, DD; + uint32 X[16]; + + for (j = 0; j < 16; j++) + X[j] = M[j]; + + AA = A; + BB = B; + CC = C; + DD = D; + + ROUND1(A, B, C, D, 0, 3); + ROUND1(D, A, B, C, 1, 7); + ROUND1(C, D, A, B, 2, 11); + ROUND1(B, C, D, A, 3, 19); + ROUND1(A, B, C, D, 4, 3); + ROUND1(D, A, B, C, 5, 7); + ROUND1(C, D, A, B, 6, 11); + ROUND1(B, C, D, A, 7, 19); + ROUND1(A, B, C, D, 8, 3); + ROUND1(D, A, B, C, 9, 7); + ROUND1(C, D, A, B, 10, 11); + ROUND1(B, C, D, A, 11, 19); + ROUND1(A, B, C, D, 12, 3); + ROUND1(D, A, B, C, 13, 7); + ROUND1(C, D, A, B, 14, 11); + ROUND1(B, C, D, A, 15, 19); + + ROUND2(A, B, C, D, 0, 3); + ROUND2(D, A, B, C, 4, 5); + ROUND2(C, D, A, B, 8, 9); + ROUND2(B, C, D, A, 12, 13); + ROUND2(A, B, C, D, 1, 3); + ROUND2(D, A, B, C, 5, 5); + ROUND2(C, D, A, B, 9, 9); + ROUND2(B, C, D, A, 13, 13); + ROUND2(A, B, C, D, 2, 3); + ROUND2(D, A, B, C, 6, 5); + ROUND2(C, D, A, B, 10, 9); + ROUND2(B, C, D, A, 14, 13); + ROUND2(A, B, C, D, 3, 3); + ROUND2(D, A, B, C, 7, 5); + ROUND2(C, D, A, B, 11, 9); + ROUND2(B, C, D, A, 15, 13); + + ROUND3(A, B, C, D, 0, 3); + ROUND3(D, A, B, C, 8, 9); + ROUND3(C, D, A, B, 4, 11); + ROUND3(B, C, D, A, 12, 15); + ROUND3(A, B, C, D, 2, 3); + ROUND3(D, A, B, C, 10, 9); + ROUND3(C, D, A, B, 6, 11); + ROUND3(B, C, D, A, 14, 15); + ROUND3(A, B, C, D, 1, 3); + ROUND3(D, A, B, C, 9, 9); + ROUND3(C, D, A, B, 5, 11); + ROUND3(B, C, D, A, 13, 15); + ROUND3(A, B, C, D, 3, 3); + ROUND3(D, A, B, C, 11, 9); + ROUND3(C, D, A, B, 7, 11); + ROUND3(B, C, D, A, 15, 15); + + A += AA; + B += BB; + C += CC; + D += DD; + + A &= 0xFFFFFFFF; + B &= 0xFFFFFFFF; + C &= 0xFFFFFFFF; + D &= 0xFFFFFFFF; + + for (j = 0; j < 16; j++) + X[j] = 0; +} + +static void +copy64(uint32 * M, unsigned char *in) +{ + int i; + + for (i = 0; i < 16; i++) + M[i] = (in[i * 4 + 3] << 24) | (in[i * 4 + 2] << 16) | + (in[i * 4 + 1] << 8) | (in[i * 4 + 0] << 0); +} + +static void +copy4(unsigned char *out, uint32 x) +{ + out[0] = x & 0xFF; + out[1] = (x >> 8) & 0xFF; + out[2] = (x >> 16) & 0xFF; + out[3] = (x >> 24) & 0xFF; } /* produce a md4 message digest from data of length n bytes */ -void mdfour(unsigned char *out, unsigned char *in, int n) +void +mdfour(unsigned char *out, unsigned char *in, int n) { - unsigned char buf[128]; - uint32 M[16]; - uint32 b = n * 8; - int i; - - A = 0x67452301; - B = 0xefcdab89; - C = 0x98badcfe; - D = 0x10325476; - - while (n > 64) { - copy64(M, in); - mdfour64(M); - in += 64; - n -= 64; - } - - for (i=0;i<128;i++) - buf[i] = 0; - memcpy(buf, in, n); - buf[n] = 0x80; - - if (n <= 55) { - copy4(buf+56, b); - copy64(M, buf); - mdfour64(M); - } else { - copy4(buf+120, b); - copy64(M, buf); - mdfour64(M); - copy64(M, buf+64); - mdfour64(M); - } + unsigned char buf[128]; + uint32 M[16]; + uint32 b = n * 8; + int i; + + A = 0x67452301; + B = 0xefcdab89; + C = 0x98badcfe; + D = 0x10325476; + + while (n > 64) { + copy64(M, in); + mdfour64(M); + in += 64; + n -= 64; + } + + for (i = 0; i < 128; i++) + buf[i] = 0; + memcpy(buf, in, n); + buf[n] = 0x80; - for (i=0;i<128;i++) - buf[i] = 0; + if (n <= 55) { + copy4(buf + 56, b); copy64(M, buf); + mdfour64(M); + } else { + copy4(buf + 120, b); + copy64(M, buf); + mdfour64(M); + copy64(M, buf + 64); + mdfour64(M); + } + + for (i = 0; i < 128; i++) + buf[i] = 0; + copy64(M, buf); + + copy4(out, A); + copy4(out + 4, B); + copy4(out + 8, C); + copy4(out + 12, D); - copy4(out, A); - copy4(out+4, B); - copy4(out+8, C); - copy4(out+12, D); - - A = B = C = D = 0; + A = B = C = D = 0; } - - Index: squid/auth_modules/MSNT/msntauth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/msntauth.c,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.1.2.1 diff -u -r1.1.4.1 -r1.1.4.1.2.1 --- squid/auth_modules/MSNT/msntauth.c 5 Nov 2000 13:42:35 -0000 1.1.4.1 +++ squid/auth_modules/MSNT/msntauth.c 7 Jan 2001 09:48:27 -0000 1.1.4.1.2.1 @@ -1,121 +1,114 @@ /* - MSNT - Microsoft Windows NT domain squid authenticator module - Version 1.2 by Stellar-X Pty Ltd, Antonino Iannella - Fri Sep 22 00:56:05 CST 2000 - - Modified to act as a Squid authenticator module. - Removed all Pike stuff. - Returns OK for a successful authentication, or ERR upon error. - - Uses code from - - Andrew Tridgell 1997 - Richard Sharpe 1996 - Bill Welliver 1999 - Duane Wessels 2000 - - Released under GNU Public License - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * MSNT - Microsoft Windows NT domain squid authenticator module + * Version 1.2 by Stellar-X Pty Ltd, Antonino Iannella + * Fri Sep 22 00:56:05 CST 2000 + * + * Modified to act as a Squid authenticator module. + * Removed all Pike stuff. + * Returns OK for a successful authentication, or ERR upon error. + * + * Uses code from - + * Andrew Tridgell 1997 + * Richard Sharpe 1996 + * Bill Welliver 1999 + * Duane Wessels 2000 + * + * Released under GNU Public License + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include #include #include #include -extern int OpenConfigFile(); -extern int QueryServers(char *, char *); +extern int OpenConfigFile(); +extern int QueryServers(char *, char *); extern void Checktimer(); extern void Check_forchange(); -extern int Read_denyusers(void); -extern int Read_allowusers(void); -extern int Check_user(char *); +extern int Read_denyusers(void); +extern int Read_allowusers(void); +extern int Check_user(char *); /* Main program for simple authentication. - Reads the denied user file. Sets alarm timer. - Scans and checks for Squid input, and attempts to validate the user. -*/ + * Reads the denied user file. Sets alarm timer. + * Scans and checks for Squid input, and attempts to validate the user. + */ -int main() +int +main() { - char username[256]; - char password[256]; - char wstr[256]; - - /* Read configuration file. Abort wildly if error. */ - if (OpenConfigFile() == 1) - return 1; - - /* Read denied and allowed user files. - If they fails, there is a serious problem. - Check syslog messages. Deny all users while in this state. - The msntauth process should then be killed. */ - - if ((Read_denyusers() == 1) || (Read_allowusers() == 1)) - { - while (1) - { - fgets(wstr, 255, stdin); - puts("ERR"); - fflush(stdout); - } - } - - /* Make Check_forchange() the handle for HUP signals. - Don't use alarms any more. I don't think it was very - portable between systems. */ - signal(SIGHUP, Check_forchange); - - while (1) - { - /* Read whole line from standard input. Terminate on break. */ - if (fgets(wstr, 255, stdin) == NULL) - break; - - /* Clear any current settings */ - username[0] = '\0'; - password[0] = '\0'; - sscanf(wstr, "%s %s", username, password); /* Extract parameters */ - - /* Check for invalid or blank entries */ - if ((username[0] == '\0') || (password[0] == '\0')) - { - puts("ERR"); - fflush(stdout); - continue; + char username[256]; + char password[256]; + char wstr[256]; + + /* Read configuration file. Abort wildly if error. */ + if (OpenConfigFile() == 1) + return 1; + + /* Read denied and allowed user files. + * If they fails, there is a serious problem. + * Check syslog messages. Deny all users while in this state. + * The msntauth process should then be killed. */ + + if ((Read_denyusers() == 1) || (Read_allowusers() == 1)) { + while (1) { + fgets(wstr, 255, stdin); + puts("ERR"); + fflush(stdout); + } } + /* Make Check_forchange() the handle for HUP signals. + * Don't use alarms any more. I don't think it was very + * portable between systems. */ + signal(SIGHUP, Check_forchange); + + while (1) { + /* Read whole line from standard input. Terminate on break. */ + if (fgets(wstr, 255, stdin) == NULL) + break; + + /* Clear any current settings */ + username[0] = '\0'; + password[0] = '\0'; + sscanf(wstr, "%s %s", username, password); /* Extract parameters */ + + /* Check for invalid or blank entries */ + if ((username[0] == '\0') || (password[0] == '\0')) { + puts("ERR"); + fflush(stdout); + continue; + } + Checktimer(); /* Check if the user lists have changed */ + + /* Check if user is explicitly denied or allowed. + * If user passes both checks, they can be authenticated. */ + + if (Check_user(username) == 1) + puts("ERR"); + else { + if (QueryServers(username, password) == 0) + puts("OK"); + else + puts("ERR"); + } - Checktimer(); /* Check if the user lists have changed */ - - /* Check if user is explicitly denied or allowed. - If user passes both checks, they can be authenticated. */ - - if (Check_user(username) == 1) - puts("ERR"); - else - { - if (QueryServers(username, password) == 0) - puts("OK"); - else - puts("ERR"); + fflush(stdout); } - fflush(stdout); - } - - return 0; + return 0; } - Index: squid/auth_modules/MSNT/rfcnb-common.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-common.h,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-common.h 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-common.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Common Structures etc Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Common Structures etc Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #ifndef _RFCNB_COMMON_H_ #define _RFCNB_COMMON_H_ @@ -30,9 +30,9 @@ typedef struct RFCNB_Pkt { - char * data; /* The data in this portion */ - int len; - struct RFCNB_Pkt *next; + char *data; /* The data in this portion */ + int len; + struct RFCNB_Pkt *next; } RFCNB_Pkt; Index: squid/auth_modules/MSNT/rfcnb-error.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-error.h,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-error.h 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-error.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,54 +1,54 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Error Response Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Error Response Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #ifndef _RFCNB_ERROR_H_ #define _RFCNB_ERROR_H_ /* Error responses */ -#define RFCNBE_Bad -1 /* Bad response */ +#define RFCNBE_Bad -1 /* Bad response */ #define RFCNBE_OK 0 -/* these should follow the spec ... is there one ?*/ +/* these should follow the spec ... is there one ? */ -#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */ -#define RFCNBE_BadName 2 /* Could not translate a name */ -#define RFCNBE_BadRead 3 /* Read sys call failed */ -#define RFCNBE_BadWrite 4 /* Write Sys call failed */ -#define RFCNBE_ProtErr 5 /* Protocol Error */ -#define RFCNBE_ConGone 6 /* Connection dropped */ -#define RFCNBE_BadHandle 7 /* Handle passed was bad */ -#define RFCNBE_BadSocket 8 /* Problems creating socket */ -#define RFCNBE_ConnectFailed 9 /* Connect failed */ -#define RFCNBE_CallRejNLOCN 10 /* Call rejected, not listening on CN */ -#define RFCNBE_CallRejNLFCN 11 /* Call rejected, not listening for CN */ -#define RFCNBE_CallRejCNNP 12 /* Call rejected, called name not present */ -#define RFCNBE_CallRejInfRes 13/* Call rejetced, name ok, no resources */ -#define RFCNBE_CallRejUnSpec 14/* Call rejected, unspecified error */ -#define RFCNBE_BadParam 15/* Bad parameters passed ... */ -#define RFCNBE_Timeout 16/* IO Timed out */ +#define RFCNBE_NoSpace 1 /* Could not allocate space for a struct */ +#define RFCNBE_BadName 2 /* Could not translate a name */ +#define RFCNBE_BadRead 3 /* Read sys call failed */ +#define RFCNBE_BadWrite 4 /* Write Sys call failed */ +#define RFCNBE_ProtErr 5 /* Protocol Error */ +#define RFCNBE_ConGone 6 /* Connection dropped */ +#define RFCNBE_BadHandle 7 /* Handle passed was bad */ +#define RFCNBE_BadSocket 8 /* Problems creating socket */ +#define RFCNBE_ConnectFailed 9 /* Connect failed */ +#define RFCNBE_CallRejNLOCN 10 /* Call rejected, not listening on CN */ +#define RFCNBE_CallRejNLFCN 11 /* Call rejected, not listening for CN */ +#define RFCNBE_CallRejCNNP 12 /* Call rejected, called name not present */ +#define RFCNBE_CallRejInfRes 13 /* Call rejetced, name ok, no resources */ +#define RFCNBE_CallRejUnSpec 14 /* Call rejected, unspecified error */ +#define RFCNBE_BadParam 15 /* Bad parameters passed ... */ +#define RFCNBE_Timeout 16 /* IO Timed out */ /* Text strings for the error responses */ Index: squid/auth_modules/MSNT/rfcnb-io.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-io.c,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-io.c 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-io.c 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NEtBIOS implementation - - Version 1.0 - RFCNB IO Routines ... - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB IO Routines ... + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /* #include */ #include "std-includes.h" #include "rfcnb-priv.h" @@ -30,394 +30,386 @@ #include #include -int RFCNB_Timeout = 0; /* Timeout in seconds ... */ - -void rfcnb_alarm(int sig) +int RFCNB_Timeout = 0; /* Timeout in seconds ... */ +void +rfcnb_alarm(int sig) { - fprintf(stderr, "IO Timed out ...\n"); + fprintf(stderr, "IO Timed out ...\n"); } /* Set timeout value and setup signal handling */ -int RFCNB_Set_Timeout(int seconds) - +int +RFCNB_Set_Timeout(int seconds) { #ifdef __GLIBC__ - int temp; + int temp; #endif - /* If we are on a Bezerkeley system, use sigvec, else sigaction */ + /* If we are on a Bezerkeley system, use sigvec, else sigaction */ #ifndef SA_RESTART - struct sigvec invec, outvec; + struct sigvec invec, outvec; #else - struct sigaction inact, outact; + struct sigaction inact, outact; #endif - RFCNB_Timeout = seconds; + RFCNB_Timeout = seconds; - if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */ + if (RFCNB_Timeout > 0) { /* Set up handler to ignore but not restart */ #ifndef SA_RESTART - invec.sv_handler = (void (*)())rfcnb_alarm; - invec.sv_mask = 0; - invec.sv_flags = SV_INTERRUPT; + invec.sv_handler = (void (*)()) rfcnb_alarm; + invec.sv_mask = 0; + invec.sv_flags = SV_INTERRUPT; - if (sigvec(SIGALRM, &invec, &outvec) < 0) - return(-1); + if (sigvec(SIGALRM, &invec, &outvec) < 0) + return (-1); #else - inact.sa_handler = (void (*)())rfcnb_alarm; + inact.sa_handler = (void (*)()) rfcnb_alarm; #ifdef SOLARIS - /* Solaris seems to have an array of vectors ... */ - inact.sa_mask.__sigbits[0] = 0; - inact.sa_mask.__sigbits[1] = 0; - inact.sa_mask.__sigbits[2] = 0; - inact.sa_mask.__sigbits[3] = 0; + /* Solaris seems to have an array of vectors ... */ + inact.sa_mask.__sigbits[0] = 0; + inact.sa_mask.__sigbits[1] = 0; + inact.sa_mask.__sigbits[2] = 0; + inact.sa_mask.__sigbits[3] = 0; #else #ifdef __GLIBC__ - for (temp = 0 ; temp < 32 ; temp ++) - inact.sa_mask.__val[temp]=0; + for (temp = 0; temp < 32; temp++) + inact.sa_mask.__val[temp] = 0; #else - inact.sa_mask = 0; + inact.sa_mask = 0; #endif #endif - inact.sa_flags = 0; /* Don't restart */ + inact.sa_flags = 0; /* Don't restart */ - if (sigaction(SIGALRM, &inact, &outact) < 0) - return(-1); + if (sigaction(SIGALRM, &inact, &outact) < 0) + return (-1); #endif - } - - return(0); + } + return (0); } /* Discard the rest of an incoming packet as we do not have space for it - in the buffer we allocated or were passed ... */ + * in the buffer we allocated or were passed ... */ -int RFCNB_Discard_Rest(struct RFCNB_Con *con, int len) - -{ char temp[100]; /* Read into here */ - int rest, this_read, bytes_read; +int +RFCNB_Discard_Rest(struct RFCNB_Con *con, int len) +{ + char temp[100]; /* Read into here */ + int rest, this_read, bytes_read; - /* len is the amount we should read */ + /* len is the amount we should read */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Discard_Rest called to discard: %i\n", len); + fprintf(stderr, "Discard_Rest called to discard: %i\n", len); #endif - rest = len; + rest = len; - while (rest > 0) { + while (rest > 0) { - this_read = (rest > sizeof(temp)?sizeof(temp):rest); + this_read = (rest > sizeof(temp) ? sizeof(temp) : rest); - bytes_read = read(con -> fd, temp, this_read); + bytes_read = read(con->fd, temp, this_read); - if (bytes_read <= 0) { /* Error so return */ + if (bytes_read <= 0) { /* Error so return */ - if (bytes_read < 0) - RFCNB_errno = RFCNBE_BadRead; - else - RFCNB_errno = RFCNBE_ConGone; + if (bytes_read < 0) + RFCNB_errno = RFCNBE_BadRead; + else + RFCNB_errno = RFCNBE_ConGone; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); - } - - rest = rest - bytes_read; + } + rest = rest - bytes_read; - } + } - return(0); + return (0); } /* Send an RFCNB packet to the connection. + * + * We just send each of the blocks linked together ... + * + * If we can, try to send it as one iovec ... + * + */ - We just send each of the blocks linked together ... - - If we can, try to send it as one iovec ... - -*/ - -int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) - -{ int len_sent, tot_sent, this_len; - struct RFCNB_Pkt *pkt_ptr; - char *this_data; - int i; - struct iovec io_list[10]; /* We should never have more */ - /* If we do, this will blow up ...*/ +int +RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) +{ + int len_sent, tot_sent, this_len; + struct RFCNB_Pkt *pkt_ptr; + char *this_data; + int i; + struct iovec io_list[10]; /* We should never have more */ + /* If we do, this will blow up ... */ - /* Try to send the data ... We only send as many bytes as len claims */ - /* We should try to stuff it into an IOVEC and send as one write */ + /* Try to send the data ... We only send as many bytes as len claims */ + /* We should try to stuff it into an IOVEC and send as one write */ - pkt_ptr = pkt; - len_sent = tot_sent = 0; /* Nothing sent so far */ - i = 0; + pkt_ptr = pkt; + len_sent = tot_sent = 0; /* Nothing sent so far */ + i = 0; - while ((pkt_ptr != NULL) & (i < 10)) { /* Watch that magic number! */ + while ((pkt_ptr != NULL) & (i < 10)) { /* Watch that magic number! */ - this_len = pkt_ptr -> len; - this_data = pkt_ptr -> data; - if ((tot_sent + this_len) > len) - this_len = len - tot_sent; /* Adjust so we don't send too much */ + this_len = pkt_ptr->len; + this_data = pkt_ptr->data; + if ((tot_sent + this_len) > len) + this_len = len - tot_sent; /* Adjust so we don't send too much */ - /* Now plug into the iovec ... */ + /* Now plug into the iovec ... */ - io_list[i].iov_len = this_len; - io_list[i].iov_base = this_data; - i++; + io_list[i].iov_len = this_len; + io_list[i].iov_base = this_data; + i++; - tot_sent += this_len; + tot_sent += this_len; - if (tot_sent == len) break; /* Let's not send too much */ + if (tot_sent == len) + break; /* Let's not send too much */ - pkt_ptr = pkt_ptr -> next; + pkt_ptr = pkt_ptr->next; - } + } #ifdef RFCNB_DEBUG - fprintf(stderr, "Frags = %i, tot_sent = %i\n", i, tot_sent); + fprintf(stderr, "Frags = %i, tot_sent = %i\n", i, tot_sent); #endif - /* Set up an alarm if timeouts are set ... */ + /* Set up an alarm if timeouts are set ... */ - if (RFCNB_Timeout > 0) - alarm(RFCNB_Timeout); + if (RFCNB_Timeout > 0) + alarm(RFCNB_Timeout); - if ((len_sent = writev(con -> fd, io_list, i)) < 0) { /* An error */ + if ((len_sent = writev(con->fd, io_list, i)) < 0) { /* An error */ - con -> rfc_errno = errno; - if (errno == EINTR) /* We were interrupted ... */ - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadWrite; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); - - } - - if (len_sent < tot_sent) { /* Less than we wanted */ - if (errno == EINTR) /* We were interrupted */ - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadWrite; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); - } + con->rfc_errno = errno; + if (errno == EINTR) /* We were interrupted ... */ + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadWrite; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); - if (RFCNB_Timeout > 0) - alarm(0); /* Reset that sucker */ + } + if (len_sent < tot_sent) { /* Less than we wanted */ + if (errno == EINTR) /* We were interrupted */ + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadWrite; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); + } + if (RFCNB_Timeout > 0) + alarm(0); /* Reset that sucker */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Len sent = %i ...\n", len_sent); - RFCNB_Print_Pkt(stderr, "sent", pkt, len_sent); /* Print what send ... */ + fprintf(stderr, "Len sent = %i ...\n", len_sent); + RFCNB_Print_Pkt(stderr, "sent", pkt, len_sent); /* Print what send ... */ #endif - return(len_sent); + return (len_sent); } /* Read an RFCNB packet off the connection. - - We read the first 4 bytes, that tells us the length, then read the - rest. We should implement a timeout, but we don't just yet - -*/ + * + * We read the first 4 bytes, that tells us the length, then read the + * rest. We should implement a timeout, but we don't just yet + * + */ -int RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) - -{ int read_len, pkt_len; - char hdr[RFCNB_Pkt_Hdr_Len]; /* Local space for the header */ - struct RFCNB_Pkt *pkt_frag; - int more, this_time, offset, frag_len, this_len; - BOOL seen_keep_alive = TRUE; +int +RFCNB_Get_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len) +{ + int read_len, pkt_len; + char hdr[RFCNB_Pkt_Hdr_Len]; /* Local space for the header */ + struct RFCNB_Pkt *pkt_frag; + int more, this_time, offset, frag_len, this_len; + BOOL seen_keep_alive = TRUE; - /* Read that header straight into the buffer */ + /* Read that header straight into the buffer */ - if (len < RFCNB_Pkt_Hdr_Len) { /* What a bozo */ + if (len < RFCNB_Pkt_Hdr_Len) { /* What a bozo */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Trying to read less than a packet:"); - perror(""); + fprintf(stderr, "Trying to read less than a packet:"); + perror(""); #endif - RFCNB_errno = RFCNBE_BadParam; - return(RFCNBE_Bad); - - } + RFCNB_errno = RFCNBE_BadParam; + return (RFCNBE_Bad); - /* We discard keep alives here ... */ + } + /* We discard keep alives here ... */ - if (RFCNB_Timeout > 0) - alarm(RFCNB_Timeout); + if (RFCNB_Timeout > 0) + alarm(RFCNB_Timeout); - while (seen_keep_alive) { + while (seen_keep_alive) { - if ((read_len = read(con -> fd, hdr, sizeof(hdr))) < 0) { /* Problems */ + if ((read_len = read(con->fd, hdr, sizeof(hdr))) < 0) { /* Problems */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Reading the packet, we got:"); - perror(""); + fprintf(stderr, "Reading the packet, we got:"); + perror(""); #endif - if (errno == EINTR) - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_BadRead; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); - - } + if (errno == EINTR) + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_BadRead; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); - /* Now we check out what we got */ + } + /* Now we check out what we got */ - if (read_len == 0) { /* Connection closed, send back eof? */ + if (read_len == 0) { /* Connection closed, send back eof? */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Connection closed reading\n"); -#endif - - if (errno == EINTR) - RFCNB_errno = RFCNBE_Timeout; - else - RFCNB_errno = RFCNBE_ConGone; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); + fprintf(stderr, "Connection closed reading\n"); +#endif - } + if (errno == EINTR) + RFCNB_errno = RFCNBE_Timeout; + else + RFCNB_errno = RFCNBE_ConGone; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); - if (RFCNB_Pkt_Type(hdr) == RFCNB_SESSION_KEEP_ALIVE) { + } + if (RFCNB_Pkt_Type(hdr) == RFCNB_SESSION_KEEP_ALIVE) { #ifdef RFCNB_DEBUG - fprintf(stderr, "RFCNB KEEP ALIVE received\n"); + fprintf(stderr, "RFCNB KEEP ALIVE received\n"); #endif - - } - else { - seen_keep_alive = FALSE; + + } else { + seen_keep_alive = FALSE; + } + } - } - - /* What if we got less than or equal to a hdr size in bytes? */ + /* What if we got less than or equal to a hdr size in bytes? */ - if (read_len < sizeof(hdr)) { /* We got a small packet */ + if (read_len < sizeof(hdr)) { /* We got a small packet */ - /* Now we need to copy the hdr portion we got into the supplied packet */ + /* Now we need to copy the hdr portion we got into the supplied packet */ - memcpy(pkt -> data, hdr, read_len); /*Copy data */ + memcpy(pkt->data, hdr, read_len); /*Copy data */ #ifdef RFCNB_DEBUG - RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len); + RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len); #endif - return(read_len); + return (read_len); - } - - /* Now, if we got at least a hdr size, alloc space for rest, if we need it */ + } + /* Now, if we got at least a hdr size, alloc space for rest, if we need it */ - pkt_len = RFCNB_Pkt_Len(hdr); + pkt_len = RFCNB_Pkt_Len(hdr); #ifdef RFCNB_DEBUG - fprintf(stderr, "Reading Pkt: Length = %i\n", pkt_len); -#endif - - /* Now copy in the hdr */ + fprintf(stderr, "Reading Pkt: Length = %i\n", pkt_len); +#endif - memcpy(pkt -> data, hdr, sizeof(hdr)); + /* Now copy in the hdr */ - /* Get the rest of the packet ... first figure out how big our buf is? */ - /* And make sure that we handle the fragments properly ... Sure should */ - /* use an iovec ... */ + memcpy(pkt->data, hdr, sizeof(hdr)); - if (len < pkt_len) /* Only get as much as we have space for */ - more = len - RFCNB_Pkt_Hdr_Len; - else - more = pkt_len; + /* Get the rest of the packet ... first figure out how big our buf is? */ + /* And make sure that we handle the fragments properly ... Sure should */ + /* use an iovec ... */ - this_time = 0; + if (len < pkt_len) /* Only get as much as we have space for */ + more = len - RFCNB_Pkt_Hdr_Len; + else + more = pkt_len; - /* We read for each fragment ... */ + this_time = 0; - if (pkt -> len == read_len){ /* If this frag was exact size */ - pkt_frag = pkt -> next; /* Stick next lot in next frag */ - offset = 0; /* then we start at 0 in next */ - } - else { - pkt_frag = pkt; /* Otherwise use rest of this frag */ - offset = RFCNB_Pkt_Hdr_Len; /* Otherwise skip the header */ - } + /* We read for each fragment ... */ - frag_len = pkt_frag -> len; + if (pkt->len == read_len) { /* If this frag was exact size */ + pkt_frag = pkt->next; /* Stick next lot in next frag */ + offset = 0; /* then we start at 0 in next */ + } else { + pkt_frag = pkt; /* Otherwise use rest of this frag */ + offset = RFCNB_Pkt_Hdr_Len; /* Otherwise skip the header */ + } - if (more <= frag_len) /* If len left to get less than frag space */ - this_len = more; /* Get the rest ... */ - else - this_len = frag_len - offset; + frag_len = pkt_frag->len; - while (more > 0) { + if (more <= frag_len) /* If len left to get less than frag space */ + this_len = more; /* Get the rest ... */ + else + this_len = frag_len - offset; - if ((this_time = read(con -> fd, (pkt_frag -> data) + offset, this_len)) <= 0) { /* Problems */ + while (more > 0) { - if (errno == EINTR) { + if ((this_time = read(con->fd, (pkt_frag->data) + offset, this_len)) <= 0) { /* Problems */ - RFCNB_errno = RFCNB_Timeout; + if (errno == EINTR) { - } - else { - if (this_time < 0) - RFCNB_errno = RFCNBE_BadRead; - else - RFCNB_errno = RFCNBE_ConGone; - } + RFCNB_errno = RFCNB_Timeout; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); + } else { + if (this_time < 0) + RFCNB_errno = RFCNBE_BadRead; + else + RFCNB_errno = RFCNBE_ConGone; + } - } + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); + } #ifdef RFCNB_DEBUG - fprintf(stderr, "Frag_Len = %i, this_time = %i, this_len = %i, more = %i\n", frag_len, - this_time, this_len, more); + fprintf(stderr, "Frag_Len = %i, this_time = %i, this_len = %i, more = %i\n", frag_len, + this_time, this_len, more); #endif - read_len = read_len + this_time; /* How much have we read ... */ + read_len = read_len + this_time; /* How much have we read ... */ - /* Now set up the next part */ + /* Now set up the next part */ - if (pkt_frag -> next == NULL) break; /* That's it here */ + if (pkt_frag->next == NULL) + break; /* That's it here */ - pkt_frag = pkt_frag -> next; - this_len = pkt_frag -> len; - offset = 0; + pkt_frag = pkt_frag->next; + this_len = pkt_frag->len; + offset = 0; - more = more - this_time; + more = more - this_time; - } + } #ifdef RFCNB_DEBUG - fprintf(stderr,"Pkt Len = %i, read_len = %i\n", pkt_len, read_len); - RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len + sizeof(hdr)); + fprintf(stderr, "Pkt Len = %i, read_len = %i\n", pkt_len, read_len); + RFCNB_Print_Pkt(stderr, "rcvd", pkt, read_len + sizeof(hdr)); #endif - if (read_len < (pkt_len + sizeof(hdr))) { /* Discard the rest */ - - return(RFCNB_Discard_Rest(con, (pkt_len + sizeof(hdr)) - read_len)); + if (read_len < (pkt_len + sizeof(hdr))) { /* Discard the rest */ - } + return (RFCNB_Discard_Rest(con, (pkt_len + sizeof(hdr)) - read_len)); - if (RFCNB_Timeout > 0) - alarm(0); /* Reset that sucker */ + } + if (RFCNB_Timeout > 0) + alarm(0); /* Reset that sucker */ - return(read_len + sizeof(RFCNB_Hdr)); + return (read_len + sizeof(RFCNB_Hdr)); } Index: squid/auth_modules/MSNT/rfcnb-io.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-io.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.26.1 diff -u -r1.1.1.1 -r1.1.1.1.26.1 --- squid/auth_modules/MSNT/rfcnb-io.h 26 Jan 2000 03:25:00 -0000 1.1.1.1 +++ squid/auth_modules/MSNT/rfcnb-io.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.26.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB IO Routines Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB IO Routines Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ int RFCNB_Put_Pkt(struct RFCNB_Con *con, struct RFCNB_Pkt *pkt, int len); Index: squid/auth_modules/MSNT/rfcnb-priv.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-priv.h,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-priv.h 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-priv.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /* Defines we need */ @@ -51,33 +51,33 @@ /* Structures */ -typedef struct redirect_addr * redirect_ptr; +typedef struct redirect_addr *redirect_ptr; struct redirect_addr { - struct in_addr ip_addr; - int port; - redirect_ptr next; + struct in_addr ip_addr; + int port; + redirect_ptr next; }; typedef struct RFCNB_Con { - int fd; /* File descripter for TCP/IP connection */ - int rfc_errno; /* last error */ - int timeout; /* How many milli-secs before IO times out */ - int redirects; /* How many times we were redirected */ - struct redirect_addr *redirect_list; /* First is first address */ - struct redirect_addr *last_addr; + int fd; /* File descripter for TCP/IP connection */ + int rfc_errno; /* last error */ + int timeout; /* How many milli-secs before IO times out */ + int redirects; /* How many times we were redirected */ + struct redirect_addr *redirect_list; /* First is first address */ + struct redirect_addr *last_addr; } RFCNB_Con; -typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */ - /* char[0] as the type, char[1] the */ - /* flags, and char[2..3] the length */ +typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */ + /* char[0] as the type, char[1] the */ + /* flags, and char[2..3] the length */ /* Macros to extract things from the header. These are for portability - between architecture types where we are worried about byte order */ + * between architecture types where we are worried about byte order */ #define RFCNB_Pkt_Hdr_Len 4 #define RFCNB_Pkt_Sess_Len 72 @@ -85,7 +85,7 @@ #define RFCNB_Pkt_Nack_Len 5 #define RFCNB_Pkt_Type_Offset 0 #define RFCNB_Pkt_Flags_Offset 1 -#define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */ +#define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */ #define RFCNB_Pkt_N1Len_Offset 4 #define RFCNB_Pkt_Called_Offset 5 #define RFCNB_Pkt_N2Len_Offset 38 @@ -95,7 +95,7 @@ #define RFCNB_Pkt_Port_Offset 8 /* The next macro isolates the length of a packet, including the bit in the - flags */ + * flags */ #define RFCNB_Pkt_Len(p) (PVAL(p, 3) | (PVAL(p, 2) << 8) | \ ((PVAL(p, RFCNB_Pkt_Flags_Offset) & 0x01) << 16)) @@ -107,38 +107,38 @@ #define RFCNB_Pkt_Type(p) (CVAL(p, RFCNB_Pkt_Type_Offset)) /*typedef struct RFCNB_Hdr { - - unsigned char type; - unsigned char flags; - int16 len; - - } RFCNB_Hdr; - -typedef struct RFCNB_Sess_Pkt { - unsigned char type; - unsigned char flags; - int16 length; - unsigned char n1_len; - char called_name[33]; - unsigned char n2_len; - char calling_name[33]; - } RFCNB_Sess_Pkt; - - -typedef struct RFCNB_Nack_Pkt { - - struct RFCNB_Hdr hdr; - unsigned char error; - - } RFCNB_Nack_Pkt; - -typedef struct RFCNB_Retarget_Pkt { - - struct RFCNB_Hdr hdr; - int dest_ip; - unsigned char port; - - } RFCNB_Redir_Pkt; */ + * + * unsigned char type; + * unsigned char flags; + * int16 len; + * + * } RFCNB_Hdr; + * + * typedef struct RFCNB_Sess_Pkt { + * unsigned char type; + * unsigned char flags; + * int16 length; + * unsigned char n1_len; + * char called_name[33]; + * unsigned char n2_len; + * char calling_name[33]; + * } RFCNB_Sess_Pkt; + * + * + * typedef struct RFCNB_Nack_Pkt { + * + * struct RFCNB_Hdr hdr; + * unsigned char error; + * + * } RFCNB_Nack_Pkt; + * + * typedef struct RFCNB_Retarget_Pkt { + * + * struct RFCNB_Hdr hdr; + * int dest_ip; + * unsigned char port; + * + * } RFCNB_Redir_Pkt; */ /* Static variables */ @@ -146,5 +146,5 @@ #ifndef RFCNB_ERRNO extern int RFCNB_errno; -extern int RFCNB_saved_errno; /* Save this from point of error */ +extern int RFCNB_saved_errno; /* Save this from point of error */ #endif Index: squid/auth_modules/MSNT/rfcnb-util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-util.c,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-util.c 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-util.c 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Utility Routines ... - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Utility Routines ... + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ #include "std-includes.h" #include "rfcnb-priv.h" @@ -36,527 +36,520 @@ #include #include -char *RFCNB_Error_Strings[] = { +char *RFCNB_Error_Strings[] = +{ - "RFCNBE_OK: Routine completed successfully.", - "RFCNBE_NoSpace: No space available for a malloc call.", - "RFCNBE_BadName: NetBIOS name could not be translated to IP address.", - "RFCNBE_BadRead: Read system call returned an error. Check errno.", - "RFCNBE_BadWrite: Write system call returned an error. Check errno.", - "RFCNBE_ProtErr: A protocol error has occurred.", - "RFCNBE_ConGone: Connection dropped during a read or write system call.", - "RFCNBE_BadHandle: Bad connection handle passed.", - "RFCNBE_BadSocket: Problems creating socket.", - "RFCNBE_ConnectFailed: Connection failed. See errno.", - "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.", - "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.", - "RFCNBE_CallRejCNNP: Call rejected. Called name not present.", - "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.", - "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.", - "RFCNBE_BadParam: Bad parameters passed to a routine.", - "RFCNBE_Timeout: IO Operation timed out ..." + "RFCNBE_OK: Routine completed successfully.", + "RFCNBE_NoSpace: No space available for a malloc call.", + "RFCNBE_BadName: NetBIOS name could not be translated to IP address.", + "RFCNBE_BadRead: Read system call returned an error. Check errno.", + "RFCNBE_BadWrite: Write system call returned an error. Check errno.", + "RFCNBE_ProtErr: A protocol error has occurred.", + "RFCNBE_ConGone: Connection dropped during a read or write system call.", + "RFCNBE_BadHandle: Bad connection handle passed.", + "RFCNBE_BadSocket: Problems creating socket.", + "RFCNBE_ConnectFailed: Connection failed. See errno.", + "RFCNBE_CallRejNLOCN: Call rejected. Not listening on called name.", + "RFCNBE_CallRejNLFCN: Call rejected. Not listening for called name.", + "RFCNBE_CallRejCNNP: Call rejected. Called name not present.", + "RFCNBE_CallRejInfRes: Call rejected. Name present, but insufficient resources.", + "RFCNBE_CallRejUnSpec: Call rejected. Unspecified error.", + "RFCNBE_BadParam: Bad parameters passed to a routine.", + "RFCNBE_Timeout: IO Operation timed out ..." }; -extern void (*Prot_Print_Routine)(); /* Pointer to protocol print routine */ +extern void (*Prot_Print_Routine) (); /* Pointer to protocol print routine */ /* Convert name and pad to 16 chars as needed */ /* Name 1 is a C string with null termination, name 2 may not be */ /* If SysName is true, then put a <00> on end, else space> */ -void RFCNB_CvtPad_Name(char *name1, char *name2) +void +RFCNB_CvtPad_Name(char *name1, char *name2) +{ + char c, c1, c2; + int i, len; -{ char c, c1, c2; - int i, len; + len = strlen(name1); - len = strlen(name1); + for (i = 0; i < 16; i++) { - for (i = 0; i < 16; i++) { + if (i >= len) { - if (i >= len) { + c1 = 'C'; + c2 = 'A'; /* CA is a space */ - c1 = 'C'; c2 = 'A'; /* CA is a space */ - - } else { + } else { - c = name1[i]; - c1 = (char)((int)c/16 + (int)'A'); - c2 = (char)((int)c%16 + (int)'A'); - } + c = name1[i]; + c1 = (char) ((int) c / 16 + (int) 'A'); + c2 = (char) ((int) c % 16 + (int) 'A'); + } - name2[i*2] = c1; - name2[i*2+1] = c2; + name2[i * 2] = c1; + name2[i * 2 + 1] = c2; - } + } - name2[32] = 0; /* Put in the nll ...*/ + name2[32] = 0; /* Put in the nll ... */ } /* Converts an Ascii NB Name (16 chars) to an RFCNB Name (32 chars) - Uses the encoding in RFC1001. Each nibble of byte is added to 'A' - to produce the next byte in the name. - - This routine assumes that AName is 16 bytes long and that NBName has - space for 32 chars, so be careful ... - -*/ + * Uses the encoding in RFC1001. Each nibble of byte is added to 'A' + * to produce the next byte in the name. + * + * This routine assumes that AName is 16 bytes long and that NBName has + * space for 32 chars, so be careful ... + * + */ -void RFCNB_AName_To_NBName(char *AName, char *NBName) - -{ char c, c1, c2; - int i; +void +RFCNB_AName_To_NBName(char *AName, char *NBName) +{ + char c, c1, c2; + int i; - for (i=0; i < 16; i++) { + for (i = 0; i < 16; i++) { - c = AName[i]; + c = AName[i]; - c1 = (char)((c >> 4) + 'A'); - c2 = (char)((c & 0xF) + 'A'); + c1 = (char) ((c >> 4) + 'A'); + c2 = (char) ((c & 0xF) + 'A'); - NBName[i*2] = c1; - NBName[i*2+1] = c2; - } + NBName[i * 2] = c1; + NBName[i * 2 + 1] = c2; + } - NBName[32] = 0; /* Put in a null */ + NBName[32] = 0; /* Put in a null */ } /* Do the reverse of the above ... */ -void RFCNB_NBName_To_AName(char *NBName, char *AName) - -{ char c, c1, c2; - int i; +void +RFCNB_NBName_To_AName(char *NBName, char *AName) +{ + char c, c1, c2; + int i; - for (i=0; i < 16; i++) { + for (i = 0; i < 16; i++) { - c1 = NBName[i*2]; - c2 = NBName[i*2+1]; + c1 = NBName[i * 2]; + c2 = NBName[i * 2 + 1]; - c = (char)(((int)c1 - (int)'A') * 16 + ((int)c2 - (int)'A')); + c = (char) (((int) c1 - (int) 'A') * 16 + ((int) c2 - (int) 'A')); - AName[i] = c; + AName[i] = c; - } + } - AName[i] = 0; /* Put a null on the end ... */ + AName[i] = 0; /* Put a null on the end ... */ } /* Print a string of bytes in HEX etc */ -void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len) - -{ char c1, c2, outbuf1[33]; - unsigned char c; - int i, j; - struct RFCNB_Pkt *pkt_ptr = pkt; - static char Hex_List[17] = "0123456789ABCDEF"; - - j = 0; - - /* We only want to print as much as sepcified in Len */ - - while (pkt_ptr != NULL) { +void +RFCNB_Print_Hex(FILE * fd, struct RFCNB_Pkt *pkt, int Offset, int Len) +{ + char c1, c2, outbuf1[33]; + unsigned char c; + int i, j; + struct RFCNB_Pkt *pkt_ptr = pkt; + static char Hex_List[17] = "0123456789ABCDEF"; + + j = 0; + + /* We only want to print as much as sepcified in Len */ + + while (pkt_ptr != NULL) { + + for (i = 0; + i < ((Len > (pkt_ptr->len) ? pkt_ptr->len : Len) - Offset); + i++) { + + c = pkt_ptr->data[i + Offset]; + c1 = Hex_List[c >> 4]; + c2 = Hex_List[c & 0xF]; + + outbuf1[j++] = c1; + outbuf1[j++] = c2; + + if (j == 32) { /* Print and reset */ + outbuf1[j] = 0; + fprintf(fd, " %s\n", outbuf1); + j = 0; + } + } + + Offset = 0; + Len = Len - pkt_ptr->len; /* Reduce amount by this much */ + pkt_ptr = pkt_ptr->next; - for (i = 0; - i < ((Len > (pkt_ptr -> len)?pkt_ptr -> len:Len) - Offset); - i++) { + } - c = pkt_ptr -> data[i + Offset]; - c1 = Hex_List[c >> 4]; - c2 = Hex_List[c & 0xF]; + /* Print last lot in the buffer ... */ - outbuf1[j++] = c1; outbuf1[j++] = c2; + if (j > 0) { - if (j == 32){ /* Print and reset */ outbuf1[j] = 0; fprintf(fd, " %s\n", outbuf1); - j = 0; - } } - - Offset = 0; - Len = Len - pkt_ptr -> len; /* Reduce amount by this much */ - pkt_ptr = pkt_ptr -> next; - - } - - /* Print last lot in the buffer ... */ - - if (j > 0) { - - outbuf1[j] = 0; - fprintf(fd, " %s\n", outbuf1); - - } - - fprintf(fd, "\n"); + fprintf(fd, "\n"); } /* Get a packet of size n */ -struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n) - -{ RFCNB_Pkt *pkt; - - if ((pkt = (struct RFCNB_Pkt *)malloc(sizeof(struct RFCNB_Pkt))) == NULL) { - - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return(NULL); +struct RFCNB_Pkt * +RFCNB_Alloc_Pkt(int n) +{ + RFCNB_Pkt *pkt; - } + if ((pkt = (struct RFCNB_Pkt *) malloc(sizeof(struct RFCNB_Pkt))) == NULL) { - pkt -> next = NULL; - pkt -> len = n; + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return (NULL); - if (n == 0) return(pkt); + } + pkt->next = NULL; + pkt->len = n; - if ((pkt -> data = (char *)malloc(n)) == NULL) { + if (n == 0) + return (pkt); - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - free(pkt); - return(NULL); + if ((pkt->data = (char *) malloc(n)) == NULL) { - } + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + free(pkt); + return (NULL); - return(pkt); + } + return (pkt); } /* Free up a packet */ -void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt) - -{ struct RFCNB_Pkt *pkt_next; char *data_ptr; +void +RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt) +{ + struct RFCNB_Pkt *pkt_next; + char *data_ptr; - while (pkt != NULL) { + while (pkt != NULL) { - pkt_next = pkt -> next; + pkt_next = pkt->next; - data_ptr = pkt -> data; + data_ptr = pkt->data; - if (data_ptr != NULL) - free(data_ptr); + if (data_ptr != NULL) + free(data_ptr); - free(pkt); + free(pkt); - pkt = pkt_next; + pkt = pkt_next; - } + } } /* Print an RFCNB packet */ -void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len) - -{ char lname[17]; +void +RFCNB_Print_Pkt(FILE * fd, char *dirn, struct RFCNB_Pkt *pkt, int len) +{ + char lname[17]; - /* We assume that the first fragment is the RFCNB Header */ - /* We should loop through the fragments printing them out */ + /* We assume that the first fragment is the RFCNB Header */ + /* We should loop through the fragments printing them out */ - fprintf(fd, "RFCNB Pkt %s:", dirn); + fprintf(fd, "RFCNB Pkt %s:", dirn); - switch (RFCNB_Pkt_Type(pkt -> data)) { + switch (RFCNB_Pkt_Type(pkt->data)) { - case RFCNB_SESSION_MESSAGE: + case RFCNB_SESSION_MESSAGE: - fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt -> data)); - RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len, + fprintf(fd, "SESSION MESSAGE: Length = %i\n", RFCNB_Pkt_Len(pkt->data)); + RFCNB_Print_Hex(fd, pkt, RFCNB_Pkt_Hdr_Len, #ifdef RFCNB_PRINT_DATA - RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len); + RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len); #else - 40); + 40); #endif - if (Prot_Print_Routine != 0) { /* Print the rest of the packet */ - - Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len, - RFCNB_Pkt_Len(pkt -> data) - RFCNB_Pkt_Hdr_Len); + if (Prot_Print_Routine != 0) { /* Print the rest of the packet */ - } + Prot_Print_Routine(fd, strcmp(dirn, "sent"), pkt, RFCNB_Pkt_Hdr_Len, + RFCNB_Pkt_Len(pkt->data) - RFCNB_Pkt_Hdr_Len); - break; - - case RFCNB_SESSION_REQUEST: + } + break; - fprintf(fd, "SESSION REQUEST: Length = %i\n", - RFCNB_Pkt_Len(pkt -> data)); - RFCNB_NBName_To_AName((char *)(pkt -> data + RFCNB_Pkt_Called_Offset), lname); - fprintf(fd, " Called Name: %s\n", lname); - RFCNB_NBName_To_AName((char *)(pkt -> data + RFCNB_Pkt_Calling_Offset), lname); - fprintf(fd, " Calling Name: %s\n", lname); + case RFCNB_SESSION_REQUEST: - break; + fprintf(fd, "SESSION REQUEST: Length = %i\n", + RFCNB_Pkt_Len(pkt->data)); + RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Called_Offset), lname); + fprintf(fd, " Called Name: %s\n", lname); + RFCNB_NBName_To_AName((char *) (pkt->data + RFCNB_Pkt_Calling_Offset), lname); + fprintf(fd, " Calling Name: %s\n", lname); - case RFCNB_SESSION_ACK: + break; - fprintf(fd, "RFCNB SESSION ACK: Length = %i\n", - RFCNB_Pkt_Len(pkt -> data)); + case RFCNB_SESSION_ACK: - break; + fprintf(fd, "RFCNB SESSION ACK: Length = %i\n", + RFCNB_Pkt_Len(pkt->data)); - case RFCNB_SESSION_REJ: - fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n", - RFCNB_Pkt_Len(pkt -> data)); + break; - if (RFCNB_Pkt_Len(pkt -> data) < 1) { - fprintf(fd, " Protocol Error, short Reject packet!\n"); - } - else { - fprintf(fd, " Error = %x\n", CVAL(pkt -> data, RFCNB_Pkt_Error_Offset)); - } + case RFCNB_SESSION_REJ: + fprintf(fd, "RFCNB SESSION REJECT: Length = %i\n", + RFCNB_Pkt_Len(pkt->data)); + + if (RFCNB_Pkt_Len(pkt->data) < 1) { + fprintf(fd, " Protocol Error, short Reject packet!\n"); + } else { + fprintf(fd, " Error = %x\n", CVAL(pkt->data, RFCNB_Pkt_Error_Offset)); + } - break; + break; - case RFCNB_SESSION_RETARGET: + case RFCNB_SESSION_RETARGET: - fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n", - RFCNB_Pkt_Len(pkt -> data)); + fprintf(fd, "RFCNB SESSION RETARGET: Length = %i\n", + RFCNB_Pkt_Len(pkt->data)); - /* Print out the IP address etc and the port? */ + /* Print out the IP address etc and the port? */ - break; + break; - case RFCNB_SESSION_KEEP_ALIVE: + case RFCNB_SESSION_KEEP_ALIVE: - fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n", - RFCNB_Pkt_Len(pkt -> data)); - break; + fprintf(fd, "RFCNB SESSION KEEP ALIVE: Length = %i\n", + RFCNB_Pkt_Len(pkt->data)); + break; default: - break; - } + break; + } } /* Resolve a name into an address */ -int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP) +int +RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP) +{ + int addr; /* Assumes IP4, 32 bit network addresses */ + struct hostent *hp; -{ int addr; /* Assumes IP4, 32 bit network addresses */ - struct hostent *hp; + /* Use inet_addr to try to convert the address */ - /* Use inet_addr to try to convert the address */ + if ((addr = inet_addr(host)) == INADDR_NONE) { /* Oh well, a good try :-) */ - if ((addr = inet_addr(host)) == INADDR_NONE) { /* Oh well, a good try :-) */ + /* Now try a name look up with gethostbyname */ - /* Now try a name look up with gethostbyname */ + if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */ - if ((hp = gethostbyname(host)) == NULL) { /* Not in DNS */ + /* Try NetBIOS name lookup, how the hell do we do that? */ - /* Try NetBIOS name lookup, how the hell do we do that? */ + RFCNB_errno = RFCNBE_BadName; /* Is this right? */ + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); - RFCNB_errno = RFCNBE_BadName; /* Is this right? */ - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); + } else { /* We got a name */ - } - else { /* We got a name */ + memcpy((void *) Dest_IP, (void *) hp->h_addr_list[0], sizeof(struct in_addr)); - memcpy((void *)Dest_IP, (void *)hp -> h_addr_list[0], sizeof(struct in_addr)); + } + } else { /* It was an IP address */ - } - } - else { /* It was an IP address */ - - memcpy((void *)Dest_IP, (void *)&addr, sizeof(struct in_addr)); + memcpy((void *) Dest_IP, (void *) &addr, sizeof(struct in_addr)); - } + } - return 0; + return 0; } /* Disconnect the TCP connection to the server */ -int RFCNB_Close(int socket) - +int +RFCNB_Close(int socket) { - close(socket); + close(socket); - /* If we want to do error recovery, here is where we put it */ + /* If we want to do error recovery, here is where we put it */ - return 0; + return 0; } /* Connect to the server specified in the IP address. - Not sure how to handle socket options etc. */ - -int RFCNB_IP_Connect(struct in_addr Dest_IP, int port) + * Not sure how to handle socket options etc. */ -{ struct sockaddr_in Socket; - int fd; - - /* Create a socket */ +int +RFCNB_IP_Connect(struct in_addr Dest_IP, int port) +{ + struct sockaddr_in Socket; + int fd; - if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { /* Handle the error */ + /* Create a socket */ - RFCNB_errno = RFCNBE_BadSocket; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); - } + if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) { /* Handle the error */ - bzero((char *)&Socket, sizeof(Socket)); - memcpy((char *)&Socket.sin_addr, (char *)&Dest_IP, sizeof(Dest_IP)); + RFCNB_errno = RFCNBE_BadSocket; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); + } + bzero((char *) &Socket, sizeof(Socket)); + memcpy((char *) &Socket.sin_addr, (char *) &Dest_IP, sizeof(Dest_IP)); - Socket.sin_port = htons(port); - Socket.sin_family = PF_INET; + Socket.sin_port = htons(port); + Socket.sin_family = PF_INET; - /* Now connect to the destination */ + /* Now connect to the destination */ - if (connect(fd, (struct sockaddr *)&Socket, sizeof(Socket)) < 0) { /* Error */ + if (connect(fd, (struct sockaddr *) &Socket, sizeof(Socket)) < 0) { /* Error */ - close(fd); - RFCNB_errno = RFCNBE_ConnectFailed; - RFCNB_saved_errno = errno; - return(RFCNBE_Bad); + close(fd); + RFCNB_errno = RFCNBE_ConnectFailed; + RFCNB_saved_errno = errno; + return (RFCNBE_Bad); } - - return(fd); + return (fd); } /* handle the details of establishing the RFCNB session with remote - end - -*/ - -int RFCNB_Session_Req(struct RFCNB_Con *con, - char *Called_Name, - char *Calling_Name, - BOOL *redirect, - struct in_addr *Dest_IP, - int * port) - -{ char *sess_pkt; - - /* Response packet should be no more than 9 bytes, make 16 jic */ + * end + * + */ + +int +RFCNB_Session_Req(struct RFCNB_Con *con, + char *Called_Name, + char *Calling_Name, + BOOL * redirect, + struct in_addr *Dest_IP, + int *port) +{ + char *sess_pkt; - char resp[16]; - int len; - struct RFCNB_Pkt *pkt, res_pkt; + /* Response packet should be no more than 9 bytes, make 16 jic */ - /* We build and send the session request, then read the response */ + char resp[16]; + int len; + struct RFCNB_Pkt *pkt, res_pkt; - pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Sess_Len); + /* We build and send the session request, then read the response */ - if (pkt == NULL) { + pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Sess_Len); - return(RFCNBE_Bad); /* Leave the error that RFCNB_Alloc_Pkt gives) */ + if (pkt == NULL) { - } + return (RFCNBE_Bad); /* Leave the error that RFCNB_Alloc_Pkt gives) */ - sess_pkt = pkt -> data; /* Get pointer to packet proper */ + } + sess_pkt = pkt->data; /* Get pointer to packet proper */ - sess_pkt[RFCNB_Pkt_Type_Offset] = RFCNB_SESSION_REQUEST; - RFCNB_Put_Pkt_Len(sess_pkt, (RFCNB_Pkt_Sess_Len-RFCNB_Pkt_Hdr_Len)); - sess_pkt[RFCNB_Pkt_N1Len_Offset] = 32; - sess_pkt[RFCNB_Pkt_N2Len_Offset] = 32; + sess_pkt[RFCNB_Pkt_Type_Offset] = RFCNB_SESSION_REQUEST; + RFCNB_Put_Pkt_Len(sess_pkt, (RFCNB_Pkt_Sess_Len - RFCNB_Pkt_Hdr_Len)); + sess_pkt[RFCNB_Pkt_N1Len_Offset] = 32; + sess_pkt[RFCNB_Pkt_N2Len_Offset] = 32; - RFCNB_CvtPad_Name(Called_Name, (sess_pkt + RFCNB_Pkt_Called_Offset)); - RFCNB_CvtPad_Name(Calling_Name, (sess_pkt + RFCNB_Pkt_Calling_Offset)); + RFCNB_CvtPad_Name(Called_Name, (sess_pkt + RFCNB_Pkt_Called_Offset)); + RFCNB_CvtPad_Name(Calling_Name, (sess_pkt + RFCNB_Pkt_Calling_Offset)); - /* Now send the packet */ + /* Now send the packet */ #ifdef RFCNB_DEBUG - fprintf(stderr, "Sending packet: "); - + fprintf(stderr, "Sending packet: "); + #endif - if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) { + if ((len = RFCNB_Put_Pkt(con, pkt, RFCNB_Pkt_Sess_Len)) < 0) { - return(RFCNBE_Bad); /* Should be able to write that lot ... */ + return (RFCNBE_Bad); /* Should be able to write that lot ... */ } - #ifdef RFCNB_DEBUG - fprintf(stderr, "Getting packet.\n"); + fprintf(stderr, "Getting packet.\n"); #endif - res_pkt.data = resp; - res_pkt.len = sizeof(resp); - res_pkt.next = NULL; + res_pkt.data = resp; + res_pkt.len = sizeof(resp); + res_pkt.next = NULL; - if ((len = RFCNB_Get_Pkt(con, &res_pkt, sizeof(resp))) < 0) { + if ((len = RFCNB_Get_Pkt(con, &res_pkt, sizeof(resp))) < 0) { - return(RFCNBE_Bad); + return (RFCNBE_Bad); - } + } + /* Now analyze the packet ... */ - /* Now analyze the packet ... */ + switch (RFCNB_Pkt_Type(resp)) { - switch (RFCNB_Pkt_Type(resp)) { + case RFCNB_SESSION_REJ: /* Didnt like us ... too bad */ - case RFCNB_SESSION_REJ: /* Didnt like us ... too bad */ + /* Why did we get rejected ? */ - /* Why did we get rejected ? */ - - switch (CVAL(resp,RFCNB_Pkt_Error_Offset)) { + switch (CVAL(resp, RFCNB_Pkt_Error_Offset)) { + + case 0x80: + RFCNB_errno = RFCNBE_CallRejNLOCN; + break; + case 0x81: + RFCNB_errno = RFCNBE_CallRejNLFCN; + break; + case 0x82: + RFCNB_errno = RFCNBE_CallRejCNNP; + break; + case 0x83: + RFCNB_errno = RFCNBE_CallRejInfRes; + break; + case 0x8F: + RFCNB_errno = RFCNBE_CallRejUnSpec; + break; + default: + RFCNB_errno = RFCNBE_ProtErr; + break; + } - case 0x80: - RFCNB_errno = RFCNBE_CallRejNLOCN; - break; - case 0x81: - RFCNB_errno = RFCNBE_CallRejNLFCN; - break; - case 0x82: - RFCNB_errno = RFCNBE_CallRejCNNP; - break; - case 0x83: - RFCNB_errno = RFCNBE_CallRejInfRes; - break; - case 0x8F: - RFCNB_errno = RFCNBE_CallRejUnSpec; + return (RFCNBE_Bad); break; - default: - RFCNB_errno = RFCNBE_ProtErr; - break; - } - - return(RFCNBE_Bad); - break; - case RFCNB_SESSION_ACK: /* Got what we wanted ... */ + case RFCNB_SESSION_ACK: /* Got what we wanted ... */ - return(0); - break; + return (0); + break; - case RFCNB_SESSION_RETARGET: /* Go elsewhere */ + case RFCNB_SESSION_RETARGET: /* Go elsewhere */ - *redirect = TRUE; /* Copy port and ip addr */ + *redirect = TRUE; /* Copy port and ip addr */ - memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr)); - *port = SVAL(resp, RFCNB_Pkt_Port_Offset); + memcpy(Dest_IP, (resp + RFCNB_Pkt_IP_Offset), sizeof(struct in_addr)); + *port = SVAL(resp, RFCNB_Pkt_Port_Offset); - return(0); - break; + return (0); + break; - default: /* A protocol error */ + default: /* A protocol error */ - RFCNB_errno = RFCNBE_ProtErr; - return(RFCNBE_Bad); - break; + RFCNB_errno = RFCNBE_ProtErr; + return (RFCNBE_Bad); + break; } } - - - - - - - - - Index: squid/auth_modules/MSNT/rfcnb-util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb-util.h,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/rfcnb-util.h 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/rfcnb-util.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Utility Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Utility Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ void RFCNB_CvtPad_Name(char *name1, char *name2); @@ -29,11 +29,11 @@ void RFCNB_NBName_To_AName(char *NBName, char *AName); -void RFCNB_Print_Hex(FILE *fd, struct RFCNB_Pkt *pkt, int Offset, int Len); +void RFCNB_Print_Hex(FILE * fd, struct RFCNB_Pkt *pkt, int Offset, int Len); struct RFCNB_Pkt *RFCNB_Alloc_Pkt(int n); -void RFCNB_Print_Pkt(FILE *fd, char *dirn, struct RFCNB_Pkt *pkt, int len); +void RFCNB_Print_Pkt(FILE * fd, char *dirn, struct RFCNB_Pkt *pkt, int len); int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP); @@ -41,11 +41,11 @@ int RFCNB_IP_Connect(struct in_addr Dest_IP, int port); -int RFCNB_Session_Req(RFCNB_Con *con, - char *Called_Name, - char *Calling_Name, - BOOL *redirect, - struct in_addr *Dest_IP, - int * port); +int RFCNB_Session_Req(RFCNB_Con * con, + char *Called_Name, + char *Calling_Name, + BOOL * redirect, + struct in_addr *Dest_IP, + int *port); void RFCNB_Free_Pkt(struct RFCNB_Pkt *pkt); Index: squid/auth_modules/MSNT/rfcnb.h =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/rfcnb.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.26.1 diff -u -r1.1.1.1 -r1.1.1.1.26.1 --- squid/auth_modules/MSNT/rfcnb.h 26 Jan 2000 03:25:00 -0000 1.1.1.1 +++ squid/auth_modules/MSNT/rfcnb.h 7 Jan 2001 09:48:27 -0000 1.1.1.1.26.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - RFCNB Defines - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * RFCNB Defines + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /* Error responses */ @@ -35,7 +35,7 @@ /* Definition of routines we define */ void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, - int port); + int port); int RFCNB_Send(void *Con_Handle, struct RFCNB_Pkt *Data, int Length); Index: squid/auth_modules/MSNT/session.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/MSNT/Attic/session.c,v retrieving revision 1.1.1.1.10.1 retrieving revision 1.1.1.1.10.1.2.1 diff -u -r1.1.1.1.10.1 -r1.1.1.1.10.1.2.1 --- squid/auth_modules/MSNT/session.c 12 Jul 2000 22:46:39 -0000 1.1.1.1.10.1 +++ squid/auth_modules/MSNT/session.c 7 Jan 2001 09:48:27 -0000 1.1.1.1.10.1.2.1 @@ -1,27 +1,27 @@ /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation - - Version 1.0 - Session Routines ... - - Copyright (C) Richard Sharpe 1996 - -*/ + * + * Version 1.0 + * Session Routines ... + * + * Copyright (C) Richard Sharpe 1996 + * + */ /* - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ int RFCNB_errno = 0; int RFCNB_saved_errno = 0; @@ -39,266 +39,260 @@ int RFCNB_Stats[RFCNB_MAX_STATS]; -void (*Prot_Print_Routine)() = NULL; /* Pointer to print routine */ +void (*Prot_Print_Routine) () = NULL; /* Pointer to print routine */ /* Set up a session with a remote name. We are passed Called_Name as a - string which we convert to a NetBIOS name, ie space terminated, up to - 16 characters only if we need to. If Called_Address is not empty, then - we use it to connect to the remote end, but put in Called_Name ... Called - Address can be a DNS based name, or a TCP/IP address ... -*/ - -void *RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, - int port) - -{ struct RFCNB_Con *con; - struct in_addr Dest_IP; - int Client; - BOOL redirect; struct redirect_addr *redir_addr; - char *Service_Address; + * string which we convert to a NetBIOS name, ie space terminated, up to + * 16 characters only if we need to. If Called_Address is not empty, then + * we use it to connect to the remote end, but put in Called_Name ... Called + * Address can be a DNS based name, or a TCP/IP address ... + */ + +void * +RFCNB_Call(char *Called_Name, char *Calling_Name, char *Called_Address, + int port) +{ + struct RFCNB_Con *con; + struct in_addr Dest_IP; + int Client; + BOOL redirect; + struct redirect_addr *redir_addr; + char *Service_Address; - /* Now, we really should look up the port in /etc/services ... */ + /* Now, we really should look up the port in /etc/services ... */ - if (port == 0) port = RFCNB_Default_Port; + if (port == 0) + port = RFCNB_Default_Port; - /* Create a connection structure first */ + /* Create a connection structure first */ - if ((con = (struct RFCNB_Con *)malloc(sizeof(struct RFCNB_Con))) == NULL) { /* Error in size */ + if ((con = (struct RFCNB_Con *) malloc(sizeof(struct RFCNB_Con))) == NULL) { /* Error in size */ - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return(NULL); + RFCNB_errno = RFCNBE_NoSpace; + RFCNB_saved_errno = errno; + return (NULL); } - - con -> fd = -0; /* no descriptor yet */ - con -> rfc_errno = 0; /* no error yet */ - con -> timeout = 0; /* no timeout */ - con -> redirects = 0; - con -> redirect_list = NULL; /* Fix bug still in version 0.50 */ - - /* Resolve that name into an IP address */ - - Service_Address = Called_Name; - if (strcmp(Called_Address, "") != 0) { /* If the Called Address = "" */ - Service_Address = Called_Address; - } - - if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ - - /* No need to modify RFCNB_errno as it was done by RFCNB_Name_To_IP */ - - return(NULL); - + con->fd = -0; /* no descriptor yet */ + con->rfc_errno = 0; /* no error yet */ + con->timeout = 0; /* no timeout */ + con->redirects = 0; + con->redirect_list = NULL; /* Fix bug still in version 0.50 */ + + /* Resolve that name into an IP address */ + + Service_Address = Called_Name; + if (strcmp(Called_Address, "") != 0) { /* If the Called Address = "" */ + Service_Address = Called_Address; } + if ((errno = RFCNB_Name_To_IP(Service_Address, &Dest_IP)) < 0) { /* Error */ - /* Now connect to the remote end */ + /* No need to modify RFCNB_errno as it was done by RFCNB_Name_To_IP */ - redirect = TRUE; /* Fudge this one so we go once through */ + return (NULL); - while (redirect) { /* Connect and get session info etc */ + } + /* Now connect to the remote end */ - redirect = FALSE; /* Assume all OK */ + redirect = TRUE; /* Fudge this one so we go once through */ - /* Build the redirect info. First one is first addr called */ - /* And tack it onto the list of addresses we called */ + while (redirect) { /* Connect and get session info etc */ - if ((redir_addr = (struct redirect_addr *)malloc(sizeof(struct redirect_addr))) == NULL) { /* Could not get space */ - - RFCNB_errno = RFCNBE_NoSpace; - RFCNB_saved_errno = errno; - return(NULL); + redirect = FALSE; /* Assume all OK */ - } + /* Build the redirect info. First one is first addr called */ + /* And tack it onto the list of addresses we called */ - memcpy((char *)&(redir_addr -> ip_addr), (char *)&Dest_IP, sizeof(Dest_IP)); - redir_addr -> port = port;