1 /*
2  * Copyright 2004-2009 Rob Beverly
3  * Copyright 2015-2021 The Regents of the University of California
4  * All rights reserved.
5  *
6  * This file is part of Spoofer.
7  *
8  * Spoofer is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Spoofer is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Spoofer.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 /****************************************************************************
23    Program:     $Id: messages.h,v 1.16 2021/04/28 17:39:07 kkeys Exp $
24    Author:      Rob Beverly <rbeverly at csail.mit.edu>
25                 Ken Keys, CAIDA
26    Date:        $Date: 2021/04/28 17:39:07 $
27    Description: Define control message types
28 ****************************************************************************/
29 
30 /* Test probe format */
31 #pragma pack(push,2)
32 #define PAYLOAD_VERSION 8
33 #define IPV4ADDRLEN 4
34 #define IPV6ADDRLEN 16
35 #define SEQNOSIZE 14
36 #define HMACSIZE  16
37 typedef struct test {
38     uint32_t ts;
39     unsigned char src_addr[IPV6ADDRLEN];
40     unsigned char dst_addr[IPV6ADDRLEN];
41     unsigned char seqno[SEQNOSIZE];
42     unsigned char hmac[HMACSIZE];
43 } test_t;
44 
45 typedef struct probe_hdr {
46     uint16_t ver; // PAYLOAD_VERSION
47     uint16_t spoofed; // 0=spoofed, 1=unspoofed [sic]
48 } probe_hdr_t;
49 
50 typedef struct probe {
51     probe_hdr_t hdr;
52     test_t tst;
53 } probe_t;
54 #define PROBESIZE sizeof(probe_t)
55 #define PAYLOADSIZE (sizeof(probe_t) - HMACSIZE)
56 
57 STATIC_ASSERT(sizeof(probe_t) ==
58     (sizeof(uint16_t) + sizeof(uint16_t)) +
59     (sizeof(uint32_t) + IPV6ADDRLEN + IPV6ADDRLEN + SEQNOSIZE + HMACSIZE),
60     probe_t_is_not_correctly_packed);
61 
62 #pragma pack(pop)
63