-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxdr_endian.h
289 lines (254 loc) · 6.48 KB
/
xdr_endian.h
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#ifndef __XDR_ENDIAN_H_049defbc41a4441e855ee0479dad96eb__
#define __XDR_ENDIAN_H_049defbc41a4441e855ee0479dad96eb__
/******************************************************************************/
#ifndef XDR_BIGENDIAN
#define XDR_BIGENDIAN 0
#endif
#define XDR_NTOH64(_v) do{ (_v) = ntonll(_v); }while(0)
#define XDR_NTOH32(_v) do{ (_v) = ntonl(_v); }while(0)
#define XDR_NTOH16(_v) do{ (_v) = ntons(_v); }while(0)
#define XDR_HTON64(_v) XDR_NTOH64(_v)
#define XDR_HTON32(_v) XDR_NTOH32(_v)
#define XDR_HTON16(_v) XDR_NTOH16(_v)
#if XDR_BIGENDIAN
static inline void
xdr_string_ntoh(xdr_string_t *p)
{
XDR_NTOH32(p->len);
XDR_NTOH32(p->offset);
}
#else
#define xdr_string_ntoh(_p) os_do_nothing()
#endif
#define xdr_string_hton(_p) xdr_string_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_array_ntoh(xdr_array_t *p)
{
XDR_NTOH32(p->offset);
XDR_NTOH32(p->size);
XDR_NTOH16(p->count);
XDR_NTOH16(p->type);
}
#else
#define xdr_array_ntoh(_p) os_do_nothing()
#endif
#define xdr_array_hton(_p) xdr_array_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_session_ntoh(xdr_session_st_t *p)
{
XDR_NTOH32(p->bytes);
XDR_NTOH32(p->ip_packet);
XDR_NTOH32(p->ip_frag);
XDR_NTOH32(p->tcp_disorder);
XDR_NTOH32(p->duration);
}
#else
#define xdr_session_ntoh(_p) os_do_nothing()
#endif
#define xdr_session_hton(_p) xdr_session_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_service_st_ntoh(xdr_service_st_t *p)
{
XDR_NTOH32(p->bytes);
XDR_NTOH32(p->ip_packet);
XDR_NTOH32(p->ip_frag);
XDR_NTOH32(p->tcp_disorder);
XDR_NTOH32(p->tcp_retransmit);
XDR_NTOH32(p->duration);
}
#else
#define xdr_service_st_ntoh(_p) os_do_nothing()
#endif
#define xdr_service_st_hton(_p) xdr_service_st_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_tcp_ntoh(xdr_tcp_t *p)
{
XDR_NTOH32(p->first_request_delay);
XDR_NTOH32(p->first_response_delay);
XDR_NTOH32(p->window);
XDR_NTOH16(p->synack_to_syn_time);
XDR_NTOH16(p->ack_to_syn_time);
XDR_NTOH16(p->mss);
XDR_NTOH16(p->flag);
}
#else
#define xdr_tcp_ntoh(_p) os_do_nothing()
#endif
#define xdr_tcp_hton(_p) xdr_tcp_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_tcp_ntoh(xdr_http_t *p)
{
XDR_NTOH64(p->time_request);
XDR_NTOH64(p->time_first_response);
XDR_NTOH64(p->time_last_content);
XDR_NTOH16(p->status_code);
XDR_NTOH16(p->u.v);
xdr_string_ntoh(&p->host);
xdr_string_ntoh(&p->url);
xdr_string_ntoh(&p->host_xonline);
xdr_string_ntoh(&p->user_agent);
xdr_string_ntoh(&p->content);
xdr_string_ntoh(&p->refer);
xdr_string_ntoh(&p->cookie);
xdr_string_ntoh(&p->location);
xdr_string_ntoh(&p->request);
xdr_string_ntoh(&p->response);
}
#else
#define xdr_tcp_ntoh(_p) os_do_nothing()
#endif
#define xdr_tcp_hton(_p) xdr_tcp_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_sip_ntoh(xdr_sip_t *p)
{
XDR_NTOH16(p->dataflow_count);
XDR_NTOH16(p->u.v);
xdr_string_ntoh(&p->calling_number);
xdr_string_ntoh(&p->called_number);
xdr_string_ntoh(&p->session_id);
}
#else
#define xdr_sip_ntoh(_p) os_do_nothing()
#endif
#define xdr_sip_hton(_p) xdr_sip_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_rtsp_ntoh(xdr_rtsp_t *p)
{
XDR_NTOH16(p->dataflow_count);
XDR_NTOH16(p->port_client_end);
XDR_NTOH16(p->port_server_start);
XDR_NTOH16(p->port_client_end);
XDR_NTOH16(p->count_video);
XDR_NTOH16(p->count_audio);
XDR_NTOH32(p->describe_delay);
xdr_string_ntoh(&p->url);
xdr_string_ntoh(&p->user_agent);
xdr_string_ntoh(&p->server_ip);
}
#else
#define xdr_rtsp_ntoh(_p) os_do_nothing()
#endif
#define xdr_rtsp_hton(_p) xdr_rtsp_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_ftp_ntoh(xdr_ftp_t *p)
{
XDR_NTOH32(p->filesize);
XDR_NTOH64(p->response_delay);
XDR_NTOH64(p->trans_duration);
xdr_string_ntoh(&p->status);
xdr_string_ntoh(&p->user);
xdr_string_ntoh(&p->pwd);
xdr_string_ntoh(&p->filename);
}
#else
#define xdr_ftp_ntoh(_p) os_do_nothing()
#endif
#define xdr_ftp_hton(_p) xdr_ftp_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_mail_ntoh(xdr_mail_t *p)
{
XDR_NTOH16(p->msg_type);
XDR_NTOH16(p->status_code);
XDR_NTOH32(p->length);
xdr_string_ntoh(&p->user);
xdr_string_ntoh(&p->domain);
xdr_string_ntoh(&p->sender);
xdr_string_ntoh(&p->recver);
xdr_string_ntoh(&p->hdr);
}
#else
#define xdr_mail_ntoh(_p) os_do_nothing()
#endif
#define xdr_mail_hton(_p) xdr_mail_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_dns_ntoh(xdr_dns_t *p)
{
XDR_NTOH32(p->delay);
xdr_array_ntoh(&p->ip);
xdr_string_ntoh(&p->domain);
}
#else
#define xdr_dns_ntoh(_p) os_do_nothing()
#endif
#define xdr_dns_hton(_p) xdr_dns_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_cert_ntoh(xdr_cert_t *p)
{
xdr_string_ntoh(&p->cert);
xdr_string_ntoh(&p->domain);
}
#else
#define xdr_cert_ntoh(_p) os_do_nothing()
#endif
#define xdr_cert_hton(_p) xdr_cert_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_ssl_ntoh(xdr_ssl_t *p)
{
xdr_array_ntoh(&p->cert_server);
xdr_array_ntoh(&p->cert_client);
}
#else
#define xdr_ssl_ntoh(_p) os_do_nothing()
#endif
#define xdr_ssl_hton(_p) xdr_ssl_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_alert_ntoh(xdr_alert_t *p)
{
}
#else
#define xdr_alert_ntoh(_p) os_do_nothing()
#endif
#define xdr_alert_hton(_p) xdr_alert_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_session_time_ntoh(xdr_session_time_t *p)
{
XDR_NTOH64(p->create);
XDR_NTOH64(p->start);
XDR_NTOH64(p->stop);
}
#else
#define xdr_session_time_ntoh(_p) os_do_nothing()
#endif
#define xdr_session_time_hton(_p) xdr_session_time_ntoh(_p)
#if XDR_BIGENDIAN
static inline void
xdr_proto_ntoh(xdr_proto_t *p)
{
XDR_NTOH32(p->offsetof_session);
XDR_NTOH32(p->offsetof_session_st);
XDR_NTOH32(p->offsetof_service_st);
XDR_NTOH32(p->offsetof_alert);
XDR_NTOH32(p->offsetof_file);
XDR_NTOH32(p->offsetof_L4);
XDR_NTOH32(p->offsetof_L5);
XDR_NTOH32(p->offsetof_L6);
XDR_NTOH16(p->L7.protocol);
XDR_NTOH32(p->bkdr);
XDR_NTOH32(p->total);
XDR_NTOH32(p->flag);
XDR_NTOH32(p->first_response_delay);
XDR_NTOH32(p->ip_src);
XDR_NTOH32(p->ip_dst);
XDR_NTOH16(p->port_src);
XDR_NTOH16(p->port_dst);
}
#else
#define xdr_proto_ntoh(_p) os_do_nothing()
#endif
#define xdr_proto_hton(_p) xdr_proto_ntoh(_p)
/******************************************************************************/
#endif /* __XDR_ENDIAN_H_049defbc41a4441e855ee0479dad96eb__ */