Must use (void) instead of () for function declarations.
[lwes-journaller.git] / src / header.h
blobfdf033241a5377bae30059975eea5c0c950070dd
1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
18 * Boston, MA 02110-1301 USA. *
19 *======================================================================*/
21 #ifndef HEADER_DOT_H
22 #define HEADER_DOT_H
24 #include <sys/types.h>
25 #include <netinet/in.h>
26 #include <arpa/inet.h>
29 * The header added by the journaller is 22 bytes, defined as:
31 * short Size of message body.
32 * long long Receive time in msec.
33 * long Sender IP address.
34 * short Sender port number.
35 * short Site ID number
36 * long Reserved, set to zero.
38 * All fields are stored in "network byte order," meaning the most
39 * significant byte appears first (big endian). The header is added
40 * at the "first touch" of the data by the journaller when it receives
41 * a packet on the xport in xport_to_queue.
45 struct event_header {
46 /* note: datatypes may be wrong (should be big-endian),
47 but are of the correct sizes. */
48 uint16_t payload_length ; /* Size of message body. */
49 uint64_t receipt_time ; /* Now in msec. */
50 uint32_t sender_ip ; /* Sender IP address. */
51 uint16_t sender_port ; /* Sender port number. */
52 uint16_t site_id ; /* Site ID number */
53 uint32_t future_extention ; /* reserved */
54 unsigned char event_type[0] ; /* begin of event-type token */
55 } ;
56 #define HEADER_LENGTH (22)
57 #define RECEIPT_TIME (2)
59 struct packet_check {
60 long long received;
61 char md5[16];
64 extern void header_add(void* buf, int count, unsigned long addr, unsigned short port);
65 extern int header_is_rotate(void* buf, time_t* when);
66 extern void header_fingerprint(void* buf, struct packet_check* pc);
67 extern int toknam_eq(const unsigned char* toknam, const unsigned char* nam) ;
68 extern int non_revenue_bearing (const unsigned char* buf) ;
70 /* The character at the beginning of the string is the length byte.
71 Strings in events are Pascal style. */
72 #define ROTATE_COMMAND "\017Command::Rotate"
74 #define JOURNALLER_PING_EVENT_TYPE "\014System::Ping"
75 #define JOURNALLER_PONG_EVENT_TYPE "\014System::Pong"
76 #define JOURNALLER_PING_SENDER_IP_FIELD "SenderIP"
77 #define JOURNALLER_PING_RETURN_PORT_FIELD "ReturnPort"
79 // Induce Journaller Panic Mode
80 #define JOURNALLER_PANIC "\021Journaller::Panic"
81 #define JOURNALLER_HURRYUP "\021Journaller::Hurryup"
82 #define JOURNALLER_CM_SERVE "\011CM::Serve"
83 #define JOURNALLER_DM_SERVE "\011DM::Serve"
84 #define JOURNALLER_SS_SERVE "\011SS::Serve"
86 #endif /* HEADER_DOT_H */