Annotation of 43BSDReno/kerberosIV/krb/mk_err.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * $Source: /usr/src/kerberosIV/krb/RCS/mk_err.c,v $
        !             3:  * $Author: kfall $
        !             4:  *
        !             5:  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
        !             6:  * of Technology.
        !             7:  *
        !             8:  * For copying and distribution information, please see the file
        !             9:  * <mit-copyright.h>.
        !            10:  */
        !            11: 
        !            12: #ifndef lint
        !            13: static char *rcsid_mk_err_c =
        !            14: "$Header: /usr/src/kerberosIV/krb/RCS/mk_err.c,v 4.5 90/06/25 20:56:53 kfall Exp $";
        !            15: #endif /* lint */
        !            16: 
        !            17: #include <mit-copyright.h>
        !            18: #include <sys/types.h>
        !            19: #include <des.h>
        !            20: #include <krb.h>
        !            21: #include <prot.h>
        !            22: #include <strings.h>
        !            23: 
        !            24: /*
        !            25:  * This routine creates a general purpose error reply message.  It
        !            26:  * doesn't use KTEXT because application protocol may have long
        !            27:  * messages, and may want this part of buffer contiguous to other
        !            28:  * stuff.
        !            29:  *
        !            30:  * The error reply is built in "p", using the error code "e" and
        !            31:  * error text "e_string" given.  The length of the error reply is
        !            32:  * returned.
        !            33:  *
        !            34:  * The error reply is in the following format:
        !            35:  *
        !            36:  * unsigned char       KRB_PROT_VERSION        protocol version no.
        !            37:  * unsigned char       AUTH_MSG_APPL_ERR       message type
        !            38:  * (least significant
        !            39:  * bit of above)       HOST_BYTE_ORDER         local byte order
        !            40:  * 4 bytes             e                       given error code
        !            41:  * string              e_string                given error text
        !            42:  */
        !            43: 
        !            44: long krb_mk_err(p,e,e_string)
        !            45:     u_char *p;                 /* Where to build error packet */
        !            46:     long e;                    /* Error code */
        !            47:     char *e_string;            /* Text of error */
        !            48: {
        !            49:     u_char      *start;
        !            50: 
        !            51:     start = p;
        !            52: 
        !            53:     /* Create fixed part of packet */
        !            54:     *p++ = (unsigned char) KRB_PROT_VERSION;
        !            55:     *p = (unsigned char) AUTH_MSG_APPL_ERR;
        !            56:     *p++ |= HOST_BYTE_ORDER;
        !            57: 
        !            58:     /* Add the basic info */
        !            59:     bcopy((char *)&e,(char *)p,4); /* err code */
        !            60:     p += sizeof(e);
        !            61:     (void) strcpy((char *)p,e_string); /* err text */
        !            62:     p += strlen(e_string);
        !            63: 
        !            64:     /* And return the length */
        !            65:     return p-start;
        !            66: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.