home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / kerberosIV / krb / create_death_packet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-25  |  1.6 KB  |  67 lines

  1. /*
  2.  * $Source: /usr/src/kerberosIV/krb/RCS/create_death_packet.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_cr_death_packet_c =
  14. "$Header: /usr/src/kerberosIV/krb/RCS/create_death_packet.c,v 4.10 90/06/25 20:55:28 kfall Exp $";
  15. #endif /* lint */
  16.  
  17. #include <mit-copyright.h>
  18. #include <des.h>
  19. #include <krb.h>
  20. #include <prot.h>
  21. #include <strings.h>
  22.  
  23. /*
  24.  * This routine creates a packet to type AUTH_MSG_DIE which is sent to
  25.  * the Kerberos server to make it shut down.  It is used only in the
  26.  * development environment.
  27.  *
  28.  * It takes a string "a_name" which is sent in the packet.  A pointer
  29.  * to the packet is returned.
  30.  *
  31.  * The format of the killer packet is:
  32.  *
  33.  * type            variable        data
  34.  *            or constant
  35.  * ----            -----------        ----
  36.  *
  37.  * unsigned char    KRB_PROT_VERSION    protocol version number
  38.  * 
  39.  * unsigned char    AUTH_MSG_DIE        message type
  40.  * 
  41.  * [least significant    HOST_BYTE_ORDER        byte order of sender
  42.  *  bit of above field]
  43.  * 
  44.  * string        a_name            presumably, name of
  45.  *                         principal sending killer
  46.  *                         packet
  47.  */
  48.  
  49. #ifdef DEBUG
  50. KTEXT
  51. krb_create_death_packet(a_name)
  52.     char *a_name;
  53. {
  54.     static KTEXT_ST pkt_st;
  55.     KTEXT pkt = &pkt_st;
  56.  
  57.     unsigned char *v =  pkt->dat;
  58.     unsigned char *t =  (pkt->dat+1);
  59.     *v = (unsigned char) KRB_PROT_VERSION;
  60.     *t = (unsigned char) AUTH_MSG_DIE;
  61.     *t |= HOST_BYTE_ORDER;
  62.     (void) strcpy((char *) (pkt->dat+2),a_name);
  63.     pkt->length = 3 + strlen(a_name);
  64.     return pkt;
  65. }
  66. #endif /* DEBUG */
  67.