Annotation of embedaddon/hping2/sendhcmp.c, revision 1.1

1.1     ! misho       1: /* 
        !             2:  * $smu-mark$ 
        !             3:  * $name: sendhcmp.c$ 
        !             4:  * $author: Salvatore Sanfilippo <antirez@invece.org>$ 
        !             5:  * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$ 
        !             6:  * $license: This software is under GPL version 2 of license$ 
        !             7:  * $date: Fri Nov  5 11:55:49 MET 1999$ 
        !             8:  * $rev: 4$ 
        !             9:  */ 
        !            10: 
        !            11: #include <string.h>
        !            12: #include <assert.h>
        !            13: #include <unistd.h>
        !            14: #include <signal.h> /* SIGALARM macro */
        !            15: 
        !            16: #include "hping2.h"
        !            17: #include "globals.h"
        !            18: 
        !            19: #define MUST_BE_UNREACHED 0
        !            20: 
        !            21: void    send_hcmp(__u8 type, __u32 arg)
        !            22: {
        !            23:        static struct hcmphdr hcmph; /* static because we export this */
        !            24:                                     /* to data_handler() */
        !            25: 
        !            26:        data_size = signlen + sizeof(struct hcmphdr);
        !            27: 
        !            28:        /* build hcmp header */
        !            29:        memset(&hcmph, 0, sizeof(hcmph));
        !            30:        hcmph.type = type;
        !            31:        switch (type)
        !            32:        {
        !            33:        case HCMP_RESTART:
        !            34:                hcmph.typedep.seqnum = htons((__u16) arg);
        !            35:                break;
        !            36:        case HCMP_SOURCE_QUENCH:
        !            37:        case HCMP_SOURCE_STIRUP:
        !            38:                hcmph.typedep.usec = htonl(arg);
        !            39:                break;
        !            40:        default:
        !            41:                assert(MUST_BE_UNREACHED);
        !            42:        }
        !            43: 
        !            44:        /* use hcmphdr_p to transmit hcmph to data_handler() */
        !            45:        hcmphdr_p = &hcmph;
        !            46:        kill(getpid(), SIGALRM); /* send hcmp */
        !            47: 
        !            48:        return;
        !            49: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>