2 * msgcode-test.c: check that the new message encoding is correct
5 * This file is Free Software. It was originally written for secnet.
7 * Copyright 2017 Mark Wooding
9 * You may redistribute secnet as a whole and/or modify it under the
10 * terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 3, or (at your option) any
14 * You may redistribute this file and/or modify it under the terms of
15 * the GNU General Public License as published by the Free Software
16 * Foundation; either version 2, or (at your option) any later
19 * This software is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this software; if not, see
26 * https://www.gnu.org/licenses/gpl.html.
36 #define OLD_LABEL_NAK 0x00000000
37 #define OLD_LABEL_MSG0 0x00020200
38 #define OLD_LABEL_MSG1 0x01010101
39 #define OLD_LABEL_MSG2 0x02020202
40 #define OLD_LABEL_MSG3 0x03030303
41 #define OLD_LABEL_MSG3BIS 0x13030313
42 #define OLD_LABEL_MSG4 0x04040404
43 #define OLD_LABEL_MSG5 0x05050505
44 #define OLD_LABEL_MSG6 0x06060606
45 #define OLD_LABEL_MSG7 0x07070707
46 #define OLD_LABEL_MSG8 0x08080808
47 #define OLD_LABEL_MSG9 0x09090909
48 #define OLD_LABEL_PROD 0x0a0a0a0a
50 static void check_labels(const char *what, uint32_t new, uint32_t old)
53 printf("mismatch for %s: %08"PRIx32" (new) /= %08"PRIx32" (old)\n",
64 #define CHECK(label) check_labels(#label, LABEL_##label, OLD_LABEL_##label)
79 for (i = 0; i < 65536; i++) {
80 for (j = 0; j < 65536; j++) {
82 r = MSGMAJOR(m); s = MSGMINOR(m);
83 if (r != i || s != j) {
84 printf("roundtrip fail: %04x %04x -> %08"PRIx32" "
85 "-> %08"PRIx32" %08"PRIx32"\n",