1 /*======================================================================*
2 * Copyright (C) 2008 Light Weight Event System *
3 * All rights reserved. *
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. *
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. *
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 *======================================================================*/
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 * uint16_t Size of message body.
32 * uint64_t Receive time in msec.
33 * uint32_t Sender IP address.
34 * uint16_t Sender port number.
35 * uint16_t Site ID number
36 * uint32_t 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.
44 #define RECEIPT_TIME_OFFSET (2)
45 #define SENDER_IP_OFFSET (RECEIPT_TIME_OFFSET+8)
46 #define SENDER_PORT_OFFSET (SENDER_IP_OFFSET+4)
47 #define SITE_ID_OFFSET (SENDER_PORT_OFFSET+2)
48 #define EXTENSION_OFFSET (SITE_ID_OFFSET+2)
49 #define EVENT_TYPE_OFFSET (EXTENSION_OFFSET+4)
50 #define HEADER_LENGTH (EVENT_TYPE_OFFSET)
57 extern void header_add(void* buf
, int count
, unsigned long addr
, unsigned short port
);
58 extern int header_is_rotate(void* buf
);
59 extern void header_fingerprint(void* buf
, struct packet_check
* pc
);
60 extern int toknam_eq(const unsigned char* toknam
, const unsigned char* nam
) ;
62 extern void header_print(const char* buf
);
64 uint16_t header_payload_length(const char* header
); /* Size of message body. */
65 uint64_t header_receipt_time(const char* header
); /* Now in msec. */
66 const char* header_sender_ip_formatted(const char* header
); /* Sender IP address, formatted. do not free(). */
67 uint16_t header_sender_port(const char* header
); /* Sender port number. */
68 uint16_t header_site_id(const char* header
); /* Site ID number */
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 #endif /* HEADER_DOT_H */