root/nebula/trunk/include/nebula.h

Revision 1920, 2.0 KB (checked in by till, 7 months ago)

nebula
- hmac code moved into /lib/hmac.{c,h}
- brief README with build instructions for the snort nebula plugin
- snort stream reassembly and submission works in general, hmac computation with pre-shared secrets still causes errors

Line 
1/* nebula.h
2 *
3 * Copyright (C) 2009 Tillmann Werner <tillmann.werner@gmx.de>
4 *
5 * This file is free software; as a special exception the author gives
6 * unlimited permission to copy and/or distribute it, with or without
7 * modifications, as long as this notice is preserved.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 *
14 * $Id$
15 */
16
17#ifndef __NEBULA_H
18#define __NEBULA_H
19
20#define _GNU_SOURCE 1
21
22#include <netinet/in.h>
23
24#define HMAC_BLOCK_SIZE 256
25
26
27typedef enum nebula_errno {
28        NERR_SUCCESS = 0,
29        NERR_HMACINIT,
30        NERR_HMACHASH,
31        NERR_HMAC,
32        NERR_ZMEM,
33        NERR_ZBUF,
34        NERR_ZUNKNOWN,
35        NERR_TIMEOUT,
36        NERR_INVALID,
37        NERR_RECV,
38        NERR_INVALIDFLAGS,
39        NERR_PROXYERRNO,
40        unknown
41} nebula_errno;
42
43
44const char *nebula_errstr[] = {
45        "Success",
46        "HMAC initialization failed",
47        "Hash calculation failed",
48        "HMAC computation failed",
49        "Memory error during compression",
50        "Compression output buffer too small",
51        "Unknown error during data compression",
52        "Operation timed out",
53        "Server returned an invalid response",
54        "Server did not return a response",
55        "Invalid flags provided",
56        "Unknown"
57};
58
59
60typedef struct nebula {
61        nebula_errno            nerrno;
62        int                     sockfd;
63        struct sockaddr_in      server;
64        char                    *secret;
65        struct {
66                u_char  k[HMAC_BLOCK_SIZE];
67                u_char  k_ipad[HMAC_BLOCK_SIZE];
68                u_char  k_opad[HMAC_BLOCK_SIZE];
69                char    *key;
70        } hmac;
71} nebula;
72
73
74// flags for controlling the type of a nebula connection
75#define NSCK_PERSIST    0x0001
76#define NSCK_NONBLCK    0x0002
77
78nebula *nebula_new(void);
79int nebula_init(nebula *n);
80void nebula_cleanup(nebula *);
81int nebula_connect(nebula *n, struct in_addr host, u_int16_t port, int flags);
82int nebula_send(nebula *n, u_char protocol, u_int16_t port, u_char *data, size_t len);
83int nebula_disconnect(nebula *);
84int nebula_socket(nebula *);
85int nebula_error(nebula *);
86const char *nebula_strerr(nebula *);
87
88#endif
Note: See TracBrowser for help on using the browser.