]> sjero.net Git - dccp2tcp/blob - encap.h
Add GNU GPL headers to all files
[dccp2tcp] / encap.h
1 /******************************************************************************
2 Utility to convert a DCCP flow to a TCP flow for DCCP analysis via
3                 tcptrace. Header file for Encapsulation Functions for DCCP to TCP conversion.
4
5 Copyright (C) 2012  Samuel Jero <sj323707@ohio.edu>
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 Author: Samuel Jero <sj323707@ohio.edu>
21 Date: 11/2012
22
23 Notes:
24         1)CCID2 ONLY
25         2)DCCP MUST use 48 bit sequence numbers
26         3)Checksums are not computed (they are zeroed)
27         4)DCCP DATA packets are not implemented (Linux doesn't use them)
28         5)DCCP Ack packets show up as TCP packets containing one byte
29 ******************************************************************************/
30 #ifndef ENCAP_H_
31 #define ENCAP_H_
32
33 /*
34  * All Conversion functions use these standard arguments:
35  * struct packet *new:          The New packet. It contains the following fields.
36  *
37  *      struct pcap_pkthdr *h: This is a copy of the libpcap packet structure.
38  *                                                         You are free to modify and use the fields.
39  *
40  *      u_char *data:           This is a pointer to a buffer for the new packet.
41  *                                                      Each encapsulation has the responsibility to call
42  *                                                      When a function is called, this will point at the
43  *                                                      location for that protocol's header to start.
44  *
45  *      int length:                     The length of the new packet. Each encapsulation
46  *                                              can rely on this to contain the remaining buffer
47  *                                              space AND must return with this parameter containing
48  *                                              the length of the new packet at that layer.
49  *
50  *      int id_len:                     Length of the source and destination ID.
51  *
52  *      u_char *src_id:         This is an ID for the source host. If you are going to
53  *                                              demultiplex DCCP on anything but Port Numbers, you
54  *                                              need to set this field. Typically this would be an
55  *                                              IP address.
56  *
57  *      u_char *dest_id:        This is an ID for the destination host. If you are going to
58  *                                              demultiplex DCCP on anything but Port Numbers, you
59  *                                              need to set this field. Typically this would be an
60  *                                              IP address.
61  *
62  *      struct const_packet *old:       The Old packet. It contains the following fields.
63  *
64  *      u_char* data:           This is a pointer to the buffer containing the
65  *                                              old packet. When a function is called, this will
66  *                                              point at the location of that protocol's header.
67  *
68  *      int length:                     The length of the old packet. Each encapsulation
69  *                                              layer MUST decrement this by the amount of it's
70  *                                              headers. An encapsulation layer MUST never read
71  *                                              beyond this into old->data.
72  */
73
74 /*
75  * Last Level Conversion Function
76  * Converts DCCP to TCP for analysis by TCPTRACE
77  */
78 int convert_packet(struct packet *new, const struct const_packet *old);
79
80 /*Standard Encapsulation Functions*/
81 int ethernet_encap(struct packet *new, const struct const_packet *old);
82 int linux_cooked_encap(struct packet *new, const struct const_packet *old);
83 int ipv4_encap(struct packet *new, const struct const_packet *old);
84 int ipv6_encap(struct packet *new, const struct const_packet *old);
85
86 #endif /* ENCAP_H_ */