aboutsummaryrefslogtreecommitdiffstats
path: root/packet-pgm.h
blob: c06140d676656bcb649cb042891962b28097298e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* packet-pgm.h
 * Declarations for pgm packet disassembly
 *
 * $Id: packet-pgm.h,v 1.5 2001/08/02 17:05:00 guy Exp $
 * 
 * Copyright (c) 2000 by Talarian Corp
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@ethereal.com>
 * Copyright 1999 Gerald Combs
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#ifndef _PACKET_PGM_H
#define _PACKET_PGM_H
typedef guint8 nchar_t;
typedef guint16 nshort_t;
typedef guint32 nlong_t;

/* The PGM main header */
typedef struct {
	nshort_t sport;            /* source port */
	nshort_t dport;            /* destination port */
	nchar_t type;              /* PGM type */
	nchar_t opts;              /* options */
	nshort_t cksum;            /* checksum */
	nchar_t gsi[6];            /* Global Source ID */
	nshort_t tsdulen;          /* TSDU length */
} pgm_type;
#define pgmhdr_ntoh(_p) \
	(_p)->sport = ntohs((_p)->sport); \
	(_p)->dport = ntohs((_p)->dport); \
	(_p)->type = ntohs((_p)->type); \
	(_p)->opts = ntohs((_p)->opts); \
	(_p)->cksum = ntohs((_p)->cksum); \
	(_p)->tsdulen = ntohs((_p)->tsdulen)

/* The PGM SPM header */
typedef struct {
	nlong_t sqn;              /* SPM's sequence number */
	nlong_t trail;            /* Trailing edge sequence number */
	nlong_t lead;             /* Leading edge sequence number */
	nshort_t path_afi;        /* NLA AFI */
	nshort_t res;             /* reserved */
	nlong_t path;             /* Path NLA */
} pgm_spm_t;
const size_t PGM_SPM_SZ = sizeof(pgm_type)+sizeof(pgm_spm_t);
#define spm_ntoh(_p) \
	(_p)->sqn = ntohl((_p)->sqn); \
	(_p)->trail = ntohl((_p)->trail); \
	(_p)->lead = ntohl((_p)->lead); \
	(_p)->path_afi = ntohs((_p)->path_afi); \
	(_p)->res = ntohs((_p)->res);

/* The PGM Data (ODATA/RDATA) header */
typedef struct {
	nlong_t sqn;              /* Data Packet sequence number */
	nlong_t trail;            /* Trailing edge sequence number */
} pgm_data_t;
#define data_ntoh(_p) \
	(_p)->sqn = ntohl((_p)->sqn); \
	(_p)->trail = ntohl((_p)->trail)
const size_t PGM_DATA_HDR_SZ = sizeof(pgm_type)+sizeof(pgm_data_t);

/* The PGM NAK (NAK/N-NAK/NCF) header */
typedef struct {
	nlong_t sqn;             /* Requested sequence number */
	nshort_t src_afi;        /* NLA AFI for source (IPv4 is set to 1) */
	nshort_t src_res;        /* reserved */
	nlong_t src;             /* Source NLA  */
	nshort_t grp_afi;        /* Multicast group AFI (IPv4 is set to 1) */
	nshort_t grp_res;        /* reserved */
	nlong_t grp;             /* Multicast group NLA */
} pgm_nak_t;
const size_t PGM_NAK_SZ = sizeof(pgm_type)+sizeof(pgm_nak_t);
#define nak_ntoh(_p) \
	(_p)->sqn = ntohl((_p)->sqn); \
	(_p)->src_afi = ntohs((_p)->src_afi); \
	(_p)->src_res = ntohs((_p)->src_res); \
	(_p)->grp_afi = ntohs((_p)->grp_afi); \
	(_p)->grp_res = ntohs((_p)->grp_res)

/* The PGM ACK header (PGMCC) */
typedef struct {
	nlong_t rx_max_sqn;      /* RX_MAX sequence number */
	nlong_t bitmap;          /* Received Packet Bitmap */
} pgm_ack_t;
const size_t PGM_ACK_SZ = sizeof(pgm_type)+sizeof(pgm_ack_t);
#define ack_ntoh(_p) \
	(_p)->rx_max_sqn = ntohl((_p)->rx_max_sqn); \
	(_p)->bitmap = ntohl((_p)->bitmap)

/* constants for hdr types */
#if defined(PGM_SPEC_01_PCKTS)
/* old spec-01 types */
#define PGM_SPM_PCKT  0x00
#define PGM_ODATA_PCKT  0x10
#define PGM_RDATA_PCKT  0x11
#define PGM_NAK_PCKT  0x20
#define PGM_NNAK_PCKT  0x21
#define PGM_NCF_PCKT 0x30
#else
/* spec-02 types (as well as spec-04+) */
#define PGM_SPM_PCKT  0x00
#define PGM_ODATA_PCKT  0x04
#define PGM_RDATA_PCKT  0x05
#define PGM_NAK_PCKT  0x08
#define PGM_NNAK_PCKT  0x09
#define PGM_NCF_PCKT 0x0A
#define PGM_ACK_PCKT 0x0D
#endif /* PGM_SPEC_01_PCKTS */

/* port swapping on NAK and NNAKs or not (default is to swap) */
/* PGM_NO_PORT_SWAP */

/* option flags (main PGM header) */
#define PGM_OPT 0x01
#define PGM_OPT_NETSIG 0x02
#define PGM_OPT_VAR_PKTLEN 0x40
#define PGM_OPT_PARITY 0x80

/* option types */
#define PGM_OPT_LENGTH 0x00
#define PGM_OPT_END 0x80
#define PGM_OPT_FRAGMENT 0x01
#define PGM_OPT_NAK_LIST 0x02
#define PGM_OPT_JOIN 0x03
#define PGM_OPT_REDIRECT 0x07
#define PGM_OPT_SYN 0x0D
#define PGM_OPT_FIN 0x0E
#define PGM_OPT_RST 0x0F
#define PGM_OPT_PARITY_PRM 0x08
#define PGM_OPT_PARITY_GRP 0x09
#define PGM_OPT_CURR_TGSIZE 0x0A
#define PGM_OPT_PGMCC_DATA  0x12
#define PGM_OPT_PGMCC_FEEDBACK  0x13

const nchar_t PGM_OPT_INVALID = 0x7F;

/* OPX bit values */
#define PGM_OPX_IGNORE	0x00
#define PGM_OPX_INVAL	0x01
#define PGM_OPX_DISCARD	0x10

/* option formats */
typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
} pgm_opt_generic_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nshort_t total_len;
} pgm_opt_length_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
} pgm_opt_nak_list_t;

/* 
 * To squeeze the whole option into 255 bytes, we
 * can only have 62 in the list
 */
#define PGM_MAX_NAK_LIST_SZ (62)

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
	nlong_t opt_join_min;
} pgm_opt_join_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t po;
	nlong_t prm_tgsz;
} pgm_opt_parity_prm_t;

/* OPT_PARITY_PRM P and O bits */
const nchar_t PGM_OPT_PARITY_PRM_PRO = 0x2;
const nchar_t PGM_OPT_PARITY_PRM_OND = 0x1;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
	nlong_t prm_grp;
} pgm_opt_parity_grp_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
	nlong_t prm_atgsz;
} pgm_opt_curr_tgsize_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
	nlong_t tsp;
	nshort_t acker_afi;
	nshort_t res2;
	nlong_t acker;
} pgm_opt_pgmcc_data_t;

typedef struct {
	nchar_t type;
	nchar_t len;
	nchar_t opx;
	nchar_t res;
	nlong_t tsp;
	nshort_t acker_afi;
	nshort_t loss_rate;
	nlong_t acker;
} pgm_opt_pgmcc_feedback_t;

#endif /* _PACKET_PGM_H */