nmsg
1.1.2
nmsg
ipreasm.h
1
#ifndef NMSG_IPREASM_H
2
#define NMSG_IPREASM_H
3
4
#define reasm_time_t _nmsg_ipreasm_time_t
5
#define reasm_ip _nmsg_ipreasm
6
#define reasm_ip_new _nmsg_ipreasm_new
7
#define reasm_ip_free _nmsg_ipreasm_free
8
#define reasm_ip_next _nmsg_ipreasm_next
9
#define reasm_ip_set_timeout _nmsg_ipreasm_set_timeout
10
#define reasm_ip_waiting _nmsg_ipreasm_waiting
11
#define reasm_ip_max_waiting _nmsg_ipreasm_max_waiting
12
#define reasm_ip_timed_out _nmsg_ipreasm_timed_out
13
#define reasm_ip_dropped_frags _nmsg_ipreasm_dropped_frags
14
15
/*
16
* Copyright (c) 2007 Jan Andres <jandres@gmx.net>
17
*
18
* Permission to use, copy, modify, and distribute this software for any
19
* purpose with or without fee is hereby granted, provided that the above
20
* copyright notice and this permission notice appear in all copies.
21
*/
22
23
#include <stdbool.h>
24
25
/*
26
* This is an abstract time stamp. ipreasm doesn't care whether it is
27
* in seconds, milliseconds, or nanodecades. All it does it add the
28
* configured timeout value to it, and then compare it to the timstamps
29
* of subsequent packets to decide whether a fragment has expired.
30
*/
31
typedef
uint64_t reasm_time_t;
32
33
struct
reasm_ip;
34
35
/*
36
* Functions to create and destroy the reassembly environment.
37
*/
38
struct
reasm_ip *reasm_ip_new (
void
);
39
void
reasm_ip_free (
struct
reasm_ip *reasm);
40
41
/*
42
* This is the main packet processing function. It inputs one packet,
43
* and MAY output one packet in turn. If the input was not a fragment,
44
* no output is generated, and false is returned. If the input was a
45
* fragment, true is returned.
46
* The unsigned pointed to by output_len should initially be set to the
47
* size of the buffer behind out_packet. On return, it will be set to
48
* the length of the packet returned, or 0 if no packet was returned
49
* (this will happen if a fragment is recognized, but reassembly of the
50
* corresponding packet has not completed yet).
51
* If frag_hdr_offset is not zero, for IPv6 packets, it specifies the
52
* offset into the packet at which the fragment header starts.
53
*/
54
bool
reasm_ip_next (
struct
reasm_ip *reasm,
const
unsigned
char
*packet,
55
unsigned
len,
unsigned
frag_hdr_offset,
56
reasm_time_t timestamp,
unsigned
char
*out_packet,
57
unsigned
*output_len);
58
59
/*
60
* Set the timeout after which a noncompleted reassembly expires, in
61
* abstract time units (see above for the definition of reasm_time_t).
62
*/
63
bool
reasm_ip_set_timeout (
struct
reasm_ip *reasm, reasm_time_t timeout);
64
65
/*
66
* Query certain information about the current state.
67
*/
68
unsigned
reasm_ip_waiting (
const
struct
reasm_ip *reasm);
69
unsigned
reasm_ip_max_waiting (
const
struct
reasm_ip *reasm);
70
unsigned
reasm_ip_timed_out (
const
struct
reasm_ip *reasm);
71
unsigned
reasm_ip_dropped_frags (
const
struct
reasm_ip *reasm);
72
73
#endif
/* NMSG_IPREASM_H */
Generated by
1.9.8