1 /*
2  * Copyright (c) 2001 Mark Fullmer and The Ohio State University
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  *      $Id: ftswap.c,v 1.14 2003/02/13 02:38:42 maf Exp $
27  */
28 
29 #include "ftconfig.h"
30 #include "ftlib.h"
31 
32 /*
33  * function: ftpdu_swap
34  *
35  * Swap bytes in any PDU structure.  cur is the current
36  * byte order of the PDU
37  *
38 */
ftpdu_swap(void * pdu,int cur)39 void ftpdu_swap(void *pdu, int cur)
40 {
41   struct ftpdu_header *ph;
42   int16_t i;
43   char agg_method, agg_version;
44 
45   ph = pdu;
46   i = ph->version;
47 
48 #if BYTE_ORDER == LITTLE_ENDIAN
49   if (cur == BIG_ENDIAN)
50     SWAPINT16(i);
51 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
52 
53 #if BYTE_ORDER == BIG_ENDIAN
54   if (cur == LITTLE_ENDIAN)
55     SWAPINT16(i);
56 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
57 
58   switch (i) {
59 
60     case 1:
61       ftpdu_v1_swap(pdu, cur);
62       break;
63 
64     case 5:
65       ftpdu_v5_swap(pdu, cur);
66       break;
67 
68     case 6:
69       ftpdu_v6_swap(pdu, cur);
70       break;
71 
72     case 7:
73       ftpdu_v7_swap(pdu, cur);
74       break;
75 
76     case 8:
77       agg_method = *((char*)pdu+22);
78       agg_version = *((char*)pdu+23);
79 
80       switch (agg_method) {
81 
82         case 1:
83           ftpdu_v8_1_swap(pdu, cur);
84           break;
85 
86         case 2:
87           ftpdu_v8_2_swap(pdu, cur);
88           break;
89 
90         case 3:
91           ftpdu_v8_3_swap(pdu, cur);
92           break;
93 
94         case 4:
95           ftpdu_v8_4_swap(pdu, cur);
96           break;
97 
98         case 5:
99           ftpdu_v8_5_swap(pdu, cur);
100           break;
101 
102         case 6:
103           ftpdu_v8_6_swap(pdu, cur);
104           break;
105 
106         case 7:
107           ftpdu_v8_7_swap(pdu, cur);
108           break;
109 
110         case 8:
111           ftpdu_v8_8_swap(pdu, cur);
112           break;
113 
114         case 9:
115           ftpdu_v8_9_swap(pdu, cur);
116           break;
117 
118         case 10:
119           ftpdu_v8_10_swap(pdu, cur);
120           break;
121 
122         case 11:
123           ftpdu_v8_11_swap(pdu, cur);
124           break;
125 
126         case 12:
127           ftpdu_v8_12_swap(pdu, cur);
128           break;
129 
130         case 13:
131           ftpdu_v8_13_swap(pdu, cur);
132           break;
133 
134         case 14:
135           ftpdu_v8_14_swap(pdu, cur);
136           break;
137 
138         default:
139           fterr_warnx("Internal error agg_method=%d", (int)agg_method);
140           break;
141 
142       } /* switch */
143       break;
144 
145     default:
146       fterr_warnx("Internal error i=%d", (int)i);
147       break;
148 
149   } /* switch */
150 
151 } /* ftpdu_swap */
152 
153 /*
154  * function: ftpdu_v1_swap
155  *
156  * Swap bytes in a V1 PDU.  cur is the current
157  * byte order of the PDU
158  *
159 */
ftpdu_v1_swap(struct ftpdu_v1 * pdu,int cur)160 void ftpdu_v1_swap(struct ftpdu_v1 *pdu, int cur)
161 {
162   int16_t i;
163 
164   i = pdu->count;
165 
166 #if BYTE_ORDER == LITTLE_ENDIAN
167   if (cur == BIG_ENDIAN)
168     SWAPINT16(i);
169 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
170 
171 #if BYTE_ORDER == BIG_ENDIAN
172   if (cur == LITTLE_ENDIAN)
173     SWAPINT16(i);
174 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
175 
176   SWAPINT16(pdu->version);
177   SWAPINT16(pdu->count);
178   SWAPINT32(pdu->sysUpTime);
179   SWAPINT32(pdu->unix_secs);
180   SWAPINT32(pdu->unix_nsecs);
181 
182   for (--i; i >= 0; --i) {
183     SWAPINT32(pdu->records[i].srcaddr);
184     SWAPINT32(pdu->records[i].dstaddr);
185     SWAPINT32(pdu->records[i].nexthop);
186     SWAPINT16(pdu->records[i].input);
187     SWAPINT16(pdu->records[i].output);
188     SWAPINT32(pdu->records[i].dPkts);
189     SWAPINT32(pdu->records[i].dOctets);
190     SWAPINT32(pdu->records[i].First);
191     SWAPINT32(pdu->records[i].Last);
192     SWAPINT16(pdu->records[i].dstport);
193     SWAPINT16(pdu->records[i].srcport);
194   }
195 } /* ftpdu_v1_swap */
196 
ftpdu_v5_swap(struct ftpdu_v5 * pdu,int cur)197 void ftpdu_v5_swap(struct ftpdu_v5 *pdu, int cur)
198 {
199   int16_t i;
200 
201   i = pdu->count;
202 
203 #if BYTE_ORDER == LITTLE_ENDIAN
204   if (cur == BIG_ENDIAN)
205     SWAPINT16(i);
206 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
207 
208 #if BYTE_ORDER == BIG_ENDIAN
209   if (cur == LITTLE_ENDIAN)
210     SWAPINT16(i);
211 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
212 
213   SWAPINT16(pdu->version);
214   SWAPINT16(pdu->count);
215   SWAPINT32(pdu->sysUpTime);
216   SWAPINT32(pdu->unix_secs);
217   SWAPINT32(pdu->unix_nsecs);
218   SWAPINT32(pdu->flow_sequence);
219 
220   for (--i; i >= 0; --i) {
221     SWAPINT32(pdu->records[i].srcaddr);
222     SWAPINT32(pdu->records[i].dstaddr);
223     SWAPINT32(pdu->records[i].nexthop);
224     SWAPINT16(pdu->records[i].input)   ;
225     SWAPINT16(pdu->records[i].output);
226     SWAPINT32(pdu->records[i].dPkts);
227     SWAPINT32(pdu->records[i].dOctets);
228     SWAPINT32(pdu->records[i].First);
229     SWAPINT32(pdu->records[i].Last);
230     SWAPINT16(pdu->records[i].dstport);
231     SWAPINT16(pdu->records[i].srcport);
232     SWAPINT16(pdu->records[i].src_as);
233     SWAPINT16(pdu->records[i].dst_as);
234     SWAPINT16(pdu->records[i].drops);
235   }
236 
237 } /* ftpdu_v5_swap */
238 
239 /*
240  * function: ftpdu_v6_swap
241  *
242  * Swap bytes in a V6 PDU.  cur is the current
243  * byte order of the PDU
244  *
245 */
ftpdu_v6_swap(struct ftpdu_v6 * pdu,int cur)246 void ftpdu_v6_swap(struct ftpdu_v6 *pdu, int cur)
247 {
248   int16_t i;
249 
250   i = pdu->count;
251 
252 #if BYTE_ORDER == LITTLE_ENDIAN
253   if (cur == BIG_ENDIAN)
254     SWAPINT16(i);
255 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
256 
257 #if BYTE_ORDER == BIG_ENDIAN
258   if (cur == LITTLE_ENDIAN)
259     SWAPINT16(i);
260 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
261 
262   SWAPINT16(pdu->version);
263   SWAPINT16(pdu->count);
264   SWAPINT32(pdu->sysUpTime);
265   SWAPINT32(pdu->unix_secs);
266   SWAPINT32(pdu->unix_nsecs);
267   SWAPINT32(pdu->flow_sequence);
268 
269   for (--i; i >= 0; --i) {
270     SWAPINT32(pdu->records[i].srcaddr);
271     SWAPINT32(pdu->records[i].dstaddr);
272     SWAPINT32(pdu->records[i].nexthop);
273     SWAPINT16(pdu->records[i].input);
274     SWAPINT16(pdu->records[i].output);
275     SWAPINT32(pdu->records[i].dPkts);
276     SWAPINT32(pdu->records[i].dOctets);
277     SWAPINT32(pdu->records[i].First);
278     SWAPINT32(pdu->records[i].Last);
279     SWAPINT16(pdu->records[i].dstport);
280     SWAPINT16(pdu->records[i].srcport);
281     SWAPINT16(pdu->records[i].src_as);
282     SWAPINT16(pdu->records[i].dst_as);
283     SWAPINT32(pdu->records[i].peer_nexthop);
284   }
285 } /* ftpdu_v6_swap */
286 
287 /*
288  * function: ftpdu_v7_swap
289  *
290  * Swap bytes in a V7 PDU.  cur is the current
291  * byte order of the PDU
292  *
293 */
ftpdu_v7_swap(struct ftpdu_v7 * pdu,int cur)294 void ftpdu_v7_swap(struct ftpdu_v7 *pdu, int cur)
295 {
296   int16_t i;
297 
298   i = pdu->count;
299 
300 #if BYTE_ORDER == LITTLE_ENDIAN
301   if (cur == BIG_ENDIAN)
302     SWAPINT16(i);
303 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
304 
305 #if BYTE_ORDER == BIG_ENDIAN
306   if (cur == LITTLE_ENDIAN)
307     SWAPINT16(i);
308 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
309 
310   SWAPINT16(pdu->version);
311   SWAPINT16(pdu->count);
312   SWAPINT32(pdu->sysUpTime);
313   SWAPINT32(pdu->unix_secs);
314   SWAPINT32(pdu->unix_nsecs);
315   SWAPINT32(pdu->flow_sequence);
316 
317   for (--i; i >= 0; --i) {
318     SWAPINT32(pdu->records[i].srcaddr);
319     SWAPINT32(pdu->records[i].dstaddr);
320     SWAPINT32(pdu->records[i].nexthop);
321     SWAPINT16(pdu->records[i].input)   ;
322     SWAPINT16(pdu->records[i].output);
323     SWAPINT32(pdu->records[i].dPkts);
324     SWAPINT32(pdu->records[i].dOctets);
325     SWAPINT32(pdu->records[i].First);
326     SWAPINT32(pdu->records[i].Last);
327     SWAPINT16(pdu->records[i].dstport);
328     SWAPINT16(pdu->records[i].srcport);
329     SWAPINT16(pdu->records[i].src_as);
330     SWAPINT16(pdu->records[i].dst_as);
331     SWAPINT16(pdu->records[i].drops);
332     SWAPINT32(pdu->records[i].router_sc);
333   }
334 } /* ftpdu_v7_swap */
335 
336 /*
337  * function: ftpdu_v8_1_swap
338  *
339  * Swap bytes in a V8 agg method 1 PDU.  cur is the current
340  * byte order of the PDU
341  *
342 */
ftpdu_v8_1_swap(struct ftpdu_v8_1 * pdu,int cur)343 void ftpdu_v8_1_swap(struct ftpdu_v8_1 *pdu, int cur)
344 {
345   int16_t i;
346 
347   i = pdu->count;
348 
349 #if BYTE_ORDER == LITTLE_ENDIAN
350   if (cur == BIG_ENDIAN)
351     SWAPINT16(i);
352 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
353 
354 #if BYTE_ORDER == BIG_ENDIAN
355   if (cur == LITTLE_ENDIAN)
356     SWAPINT16(i);
357 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
358 
359   SWAPINT16(pdu->version);
360   SWAPINT16(pdu->count);
361   SWAPINT32(pdu->sysUpTime);
362   SWAPINT32(pdu->unix_secs);
363   SWAPINT32(pdu->unix_nsecs);
364   SWAPINT32(pdu->flow_sequence);
365 
366   for (--i; i >= 0; --i) {
367     SWAPINT32(pdu->records[i].dFlows);
368     SWAPINT32(pdu->records[i].dPkts);
369     SWAPINT32(pdu->records[i].dOctets);
370     SWAPINT32(pdu->records[i].First);
371     SWAPINT32(pdu->records[i].Last);
372     SWAPINT16(pdu->records[i].src_as);
373     SWAPINT16(pdu->records[i].dst_as);
374     SWAPINT16(pdu->records[i].input);
375     SWAPINT16(pdu->records[i].output);
376   }
377 
378 } /* ftpdu_v8_1_swap */
379 
380 /*
381  * function: ftpdu_v8_2_swap
382  *
383  * Swap bytes in a V8 agg method 2 PDU.  cur is the current
384  * byte order of the PDU
385  *
386 */
ftpdu_v8_2_swap(struct ftpdu_v8_2 * pdu,int cur)387 void ftpdu_v8_2_swap(struct ftpdu_v8_2 *pdu, int cur)
388 {
389   int16_t i;
390 
391   i = pdu->count;
392 
393 #if BYTE_ORDER == LITTLE_ENDIAN
394   if (cur == BIG_ENDIAN)
395     SWAPINT16(i);
396 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
397 
398 #if BYTE_ORDER == BIG_ENDIAN
399   if (cur == LITTLE_ENDIAN)
400     SWAPINT16(i);
401 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
402 
403   SWAPINT16(pdu->version);
404   SWAPINT16(pdu->count);
405   SWAPINT32(pdu->sysUpTime);
406   SWAPINT32(pdu->unix_secs);
407   SWAPINT32(pdu->unix_nsecs);
408   SWAPINT32(pdu->flow_sequence);
409 
410   for (--i; i >= 0; --i) {
411     SWAPINT32(pdu->records[i].dFlows);
412     SWAPINT32(pdu->records[i].dPkts);
413     SWAPINT32(pdu->records[i].dOctets);
414     SWAPINT32(pdu->records[i].First);
415     SWAPINT32(pdu->records[i].Last);
416     SWAPINT16(pdu->records[i].srcport);
417     SWAPINT16(pdu->records[i].dstport);
418   }
419 
420 } /* ftpdu_v8_2_swap */
421 
422 /*
423  * function: ftpdu_v8_3_swap
424  *
425  * Swap bytes in a V8 agg method 3 PDU.  cur is the current
426  * byte order of the PDU
427  *
428 */
ftpdu_v8_3_swap(struct ftpdu_v8_3 * pdu,int cur)429 void ftpdu_v8_3_swap(struct ftpdu_v8_3 *pdu, int cur)
430 {
431   int16_t i;
432 
433   i = pdu->count;
434 
435 #if BYTE_ORDER == LITTLE_ENDIAN
436   if (cur == BIG_ENDIAN)
437     SWAPINT16(i);
438 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
439 
440 #if BYTE_ORDER == BIG_ENDIAN
441   if (cur == LITTLE_ENDIAN)
442     SWAPINT16(i);
443 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
444 
445   SWAPINT16(pdu->version);
446   SWAPINT16(pdu->count);
447   SWAPINT32(pdu->sysUpTime);
448   SWAPINT32(pdu->unix_secs);
449   SWAPINT32(pdu->unix_nsecs);
450   SWAPINT32(pdu->flow_sequence);
451 
452   for (--i; i >= 0; --i) {
453     SWAPINT32(pdu->records[i].dFlows);
454     SWAPINT32(pdu->records[i].dPkts);
455     SWAPINT32(pdu->records[i].dOctets);
456     SWAPINT32(pdu->records[i].First);
457     SWAPINT32(pdu->records[i].Last);
458     SWAPINT32(pdu->records[i].src_prefix);
459     SWAPINT16(pdu->records[i].src_as);
460     SWAPINT16(pdu->records[i].input);
461   }
462 
463 } /* ftpdu_v8_3_swap */
464 
465 /*
466  * function: ftpdu_v8_4_swap
467  *
468  * Swap bytes in a V8 agg method 4 PDU.  cur is the current
469  * byte order of the PDU
470  *
471 */
ftpdu_v8_4_swap(struct ftpdu_v8_4 * pdu,int cur)472 void ftpdu_v8_4_swap(struct ftpdu_v8_4 *pdu, int cur)
473 {
474   int16_t i;
475 
476   i = pdu->count;
477 
478 #if BYTE_ORDER == LITTLE_ENDIAN
479   if (cur == BIG_ENDIAN)
480     SWAPINT16(i);
481 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
482 
483 #if BYTE_ORDER == BIG_ENDIAN
484   if (cur == LITTLE_ENDIAN)
485     SWAPINT16(i);
486 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
487 
488   SWAPINT16(pdu->version);
489   SWAPINT16(pdu->count);
490   SWAPINT32(pdu->sysUpTime);
491   SWAPINT32(pdu->unix_secs);
492   SWAPINT32(pdu->unix_nsecs);
493   SWAPINT32(pdu->flow_sequence);
494 
495   for (--i; i >= 0; --i) {
496     SWAPINT32(pdu->records[i].dFlows);
497     SWAPINT32(pdu->records[i].dPkts);
498     SWAPINT32(pdu->records[i].dOctets);
499     SWAPINT32(pdu->records[i].First);
500     SWAPINT32(pdu->records[i].Last);
501     SWAPINT32(pdu->records[i].dst_prefix);
502     SWAPINT16(pdu->records[i].dst_as);
503     SWAPINT16(pdu->records[i].output);
504   }
505 
506 } /* ftpdu_v8_4_swap */
507 
508 /*
509  * function: ftpdu_v8_5_swap
510  *
511  * Swap bytes in a V8 agg method 5 PDU.  cur is the current
512  * byte order of the PDU
513  *
514 */
ftpdu_v8_5_swap(struct ftpdu_v8_5 * pdu,int cur)515 void ftpdu_v8_5_swap(struct ftpdu_v8_5 *pdu, int cur)
516 {
517   int16_t i;
518 
519   i = pdu->count;
520 
521 #if BYTE_ORDER == LITTLE_ENDIAN
522   if (cur == BIG_ENDIAN)
523     SWAPINT16(i);
524 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
525 
526 #if BYTE_ORDER == BIG_ENDIAN
527   if (cur == LITTLE_ENDIAN)
528     SWAPINT16(i);
529 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
530 
531   SWAPINT16(pdu->version);
532   SWAPINT16(pdu->count);
533   SWAPINT32(pdu->sysUpTime);
534   SWAPINT32(pdu->unix_secs);
535   SWAPINT32(pdu->unix_nsecs);
536   SWAPINT32(pdu->flow_sequence);
537 
538   for (--i; i >= 0; --i) {
539     SWAPINT32(pdu->records[i].dFlows);
540     SWAPINT32(pdu->records[i].dPkts);
541     SWAPINT32(pdu->records[i].dOctets);
542     SWAPINT32(pdu->records[i].First);
543     SWAPINT32(pdu->records[i].Last);
544     SWAPINT32(pdu->records[i].src_prefix);
545     SWAPINT32(pdu->records[i].dst_prefix);
546     SWAPINT16(pdu->records[i].src_as);
547     SWAPINT16(pdu->records[i].dst_as);
548     SWAPINT16(pdu->records[i].input);
549     SWAPINT16(pdu->records[i].output);
550   }
551 
552 } /* ftpdu_v8_5_swap */
553 
554 /*
555  * function: ftpdu_v8_6_swap
556  *
557  * Swap bytes in a V8 agg method 6 PDU.  cur is the current
558  * byte order of the PDU
559  *
560 */
ftpdu_v8_6_swap(struct ftpdu_v8_6 * pdu,int cur)561 void ftpdu_v8_6_swap(struct ftpdu_v8_6 *pdu, int cur)
562 {
563   int16_t i;
564 
565   i = pdu->count;
566 
567 #if BYTE_ORDER == LITTLE_ENDIAN
568   if (cur == BIG_ENDIAN)
569     SWAPINT16(i);
570 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
571 
572 #if BYTE_ORDER == BIG_ENDIAN
573   if (cur == LITTLE_ENDIAN)
574     SWAPINT16(i);
575 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
576 
577   SWAPINT16(pdu->version);
578   SWAPINT16(pdu->count);
579   SWAPINT32(pdu->sysUpTime);
580   SWAPINT32(pdu->unix_secs);
581   SWAPINT32(pdu->unix_nsecs);
582   SWAPINT32(pdu->flow_sequence);
583 
584   for (--i; i >= 0; --i) {
585     SWAPINT32(pdu->records[i].dstaddr);
586     SWAPINT32(pdu->records[i].dPkts);
587     SWAPINT32(pdu->records[i].dOctets);
588     SWAPINT32(pdu->records[i].First);
589     SWAPINT32(pdu->records[i].Last);
590     SWAPINT16(pdu->records[i].output);
591     SWAPINT32(pdu->records[i].extra_pkts);
592     SWAPINT32(pdu->records[i].router_sc);
593   }
594 
595 } /* ftpdu_v8_6_swap */
596 
597 
598 /*
599  * function: ftpdu_v8_7_swap
600  *
601  * Swap bytes in a V8 agg method 7 PDU.  cur is the current
602  * byte order of the PDU
603  *
604 */
ftpdu_v8_7_swap(struct ftpdu_v8_7 * pdu,int cur)605 void ftpdu_v8_7_swap(struct ftpdu_v8_7 *pdu, int cur)
606 {
607   int16_t i;
608 
609   i = pdu->count;
610 
611 #if BYTE_ORDER == LITTLE_ENDIAN
612   if (cur == BIG_ENDIAN)
613     SWAPINT16(i);
614 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
615 
616 #if BYTE_ORDER == BIG_ENDIAN
617   if (cur == LITTLE_ENDIAN)
618     SWAPINT16(i);
619 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
620 
621   SWAPINT16(pdu->version);
622   SWAPINT16(pdu->count);
623   SWAPINT32(pdu->sysUpTime);
624   SWAPINT32(pdu->unix_secs);
625   SWAPINT32(pdu->unix_nsecs);
626   SWAPINT32(pdu->flow_sequence);
627 
628   for (--i; i >= 0; --i) {
629     SWAPINT32(pdu->records[i].dstaddr);
630     SWAPINT32(pdu->records[i].srcaddr);
631     SWAPINT32(pdu->records[i].dPkts);
632     SWAPINT32(pdu->records[i].dOctets);
633     SWAPINT32(pdu->records[i].First);
634     SWAPINT32(pdu->records[i].Last);
635     SWAPINT16(pdu->records[i].input);
636     SWAPINT16(pdu->records[i].output);
637     SWAPINT32(pdu->records[i].extra_pkts);
638     SWAPINT32(pdu->records[i].router_sc);
639   }
640 
641 } /* ftpdu_v8_7_swap */
642 
643 /*
644  * function: ftpdu_v8_8_swap
645  *
646  * Swap bytes in a V8 agg method 7 PDU.  cur is the current
647  * byte order of the PDU
648  *
649 */
ftpdu_v8_8_swap(struct ftpdu_v8_8 * pdu,int cur)650 void ftpdu_v8_8_swap(struct ftpdu_v8_8 *pdu, int cur)
651 {
652   int16_t i;
653 
654   i = pdu->count;
655 
656 #if BYTE_ORDER == LITTLE_ENDIAN
657   if (cur == BIG_ENDIAN)
658     SWAPINT16(i);
659 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
660 
661 #if BYTE_ORDER == BIG_ENDIAN
662   if (cur == LITTLE_ENDIAN)
663     SWAPINT16(i);
664 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
665 
666   SWAPINT16(pdu->version);
667   SWAPINT16(pdu->count);
668   SWAPINT32(pdu->sysUpTime);
669   SWAPINT32(pdu->unix_secs);
670   SWAPINT32(pdu->unix_nsecs);
671   SWAPINT32(pdu->flow_sequence);
672 
673   for (--i; i >= 0; --i) {
674     SWAPINT32(pdu->records[i].dstaddr);
675     SWAPINT32(pdu->records[i].srcaddr);
676     SWAPINT16(pdu->records[i].dstport);
677     SWAPINT16(pdu->records[i].srcport);
678     SWAPINT32(pdu->records[i].dPkts);
679     SWAPINT32(pdu->records[i].dOctets);
680     SWAPINT32(pdu->records[i].First);
681     SWAPINT32(pdu->records[i].Last);
682     SWAPINT16(pdu->records[i].input);
683     SWAPINT16(pdu->records[i].output);
684     SWAPINT32(pdu->records[i].extra_pkts);
685     SWAPINT32(pdu->records[i].router_sc);
686   }
687 
688 } /* ftpdu_v8_8_swap */
689 
690 /*
691  * function: ftpdu_v8_9_swap
692  *
693  * Swap bytes in a V8 agg method 9 PDU.  cur is the current
694  * byte order of the PDU
695  *
696 */
ftpdu_v8_9_swap(struct ftpdu_v8_9 * pdu,int cur)697 void ftpdu_v8_9_swap(struct ftpdu_v8_9 *pdu, int cur)
698 {
699   int16_t i;
700 
701   i = pdu->count;
702 
703 #if BYTE_ORDER == LITTLE_ENDIAN
704   if (cur == BIG_ENDIAN)
705     SWAPINT16(i);
706 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
707 
708 #if BYTE_ORDER == BIG_ENDIAN
709   if (cur == LITTLE_ENDIAN)
710     SWAPINT16(i);
711 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
712 
713   SWAPINT16(pdu->version);
714   SWAPINT16(pdu->count);
715   SWAPINT32(pdu->sysUpTime);
716   SWAPINT32(pdu->unix_secs);
717   SWAPINT32(pdu->unix_nsecs);
718   SWAPINT32(pdu->flow_sequence);
719 
720   for (--i; i >= 0; --i) {
721     SWAPINT32(pdu->records[i].dFlows);
722     SWAPINT32(pdu->records[i].dPkts);
723     SWAPINT32(pdu->records[i].dOctets);
724     SWAPINT32(pdu->records[i].First);
725     SWAPINT32(pdu->records[i].Last);
726     SWAPINT16(pdu->records[i].src_as);
727     SWAPINT16(pdu->records[i].dst_as);
728     SWAPINT16(pdu->records[i].input);
729     SWAPINT16(pdu->records[i].output);
730   }
731 
732 } /* ftpdu_v8_9_swap */
733 
734 /*
735  * function: ftpdu_v8_10_swap
736  *
737  * Swap bytes in a V8 agg method 10 PDU.  cur is the current
738  * byte order of the PDU
739  *
740 */
ftpdu_v8_10_swap(struct ftpdu_v8_10 * pdu,int cur)741 void ftpdu_v8_10_swap(struct ftpdu_v8_10 *pdu, int cur)
742 {
743   int16_t i;
744 
745   i = pdu->count;
746 
747 #if BYTE_ORDER == LITTLE_ENDIAN
748   if (cur == BIG_ENDIAN)
749     SWAPINT16(i);
750 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
751 
752 #if BYTE_ORDER == BIG_ENDIAN
753   if (cur == LITTLE_ENDIAN)
754     SWAPINT16(i);
755 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
756 
757   SWAPINT16(pdu->version);
758   SWAPINT16(pdu->count);
759   SWAPINT32(pdu->sysUpTime);
760   SWAPINT32(pdu->unix_secs);
761   SWAPINT32(pdu->unix_nsecs);
762   SWAPINT32(pdu->flow_sequence);
763 
764   for (--i; i >= 0; --i) {
765     SWAPINT32(pdu->records[i].dFlows);
766     SWAPINT32(pdu->records[i].dPkts);
767     SWAPINT32(pdu->records[i].dOctets);
768     SWAPINT32(pdu->records[i].First);
769     SWAPINT32(pdu->records[i].Last);
770     SWAPINT32(pdu->records[i].srcport);
771     SWAPINT32(pdu->records[i].dstport);
772     SWAPINT16(pdu->records[i].input);
773     SWAPINT16(pdu->records[i].output);
774   }
775 
776 } /* ftpdu_v8_10_swap */
777 
778 /*
779  * function: ftpdu_v8_11_swap
780  *
781  * Swap bytes in a V8 agg method 11 PDU.  cur is the current
782  * byte order of the PDU
783  *
784 */
ftpdu_v8_11_swap(struct ftpdu_v8_11 * pdu,int cur)785 void ftpdu_v8_11_swap(struct ftpdu_v8_11 *pdu, int cur)
786 {
787   int16_t i;
788 
789   i = pdu->count;
790 
791 #if BYTE_ORDER == LITTLE_ENDIAN
792   if (cur == BIG_ENDIAN)
793     SWAPINT16(i);
794 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
795 
796 #if BYTE_ORDER == BIG_ENDIAN
797   if (cur == LITTLE_ENDIAN)
798     SWAPINT16(i);
799 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
800 
801   SWAPINT16(pdu->version);
802   SWAPINT16(pdu->count);
803   SWAPINT32(pdu->sysUpTime);
804   SWAPINT32(pdu->unix_secs);
805   SWAPINT32(pdu->unix_nsecs);
806   SWAPINT32(pdu->flow_sequence);
807 
808   for (--i; i >= 0; --i) {
809     SWAPINT32(pdu->records[i].dFlows);
810     SWAPINT32(pdu->records[i].dPkts);
811     SWAPINT32(pdu->records[i].dOctets);
812     SWAPINT32(pdu->records[i].First);
813     SWAPINT32(pdu->records[i].Last);
814     SWAPINT32(pdu->records[i].src_prefix);
815     SWAPINT16(pdu->records[i].src_as);
816     SWAPINT16(pdu->records[i].input);
817   }
818 
819 } /* ftpdu_v8_11_swap */
820 
821 /*
822  * function: ftpdu_v8_12_swap
823  *
824  * Swap bytes in a V8 agg method 12 PDU.  cur is the current
825  * byte order of the PDU
826  *
827 */
ftpdu_v8_12_swap(struct ftpdu_v8_12 * pdu,int cur)828 void ftpdu_v8_12_swap(struct ftpdu_v8_12 *pdu, int cur)
829 {
830   int16_t i;
831 
832   i = pdu->count;
833 
834 #if BYTE_ORDER == LITTLE_ENDIAN
835   if (cur == BIG_ENDIAN)
836     SWAPINT16(i);
837 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
838 
839 #if BYTE_ORDER == BIG_ENDIAN
840   if (cur == LITTLE_ENDIAN)
841     SWAPINT16(i);
842 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
843 
844   SWAPINT16(pdu->version);
845   SWAPINT16(pdu->count);
846   SWAPINT32(pdu->sysUpTime);
847   SWAPINT32(pdu->unix_secs);
848   SWAPINT32(pdu->unix_nsecs);
849   SWAPINT32(pdu->flow_sequence);
850 
851   for (--i; i >= 0; --i) {
852     SWAPINT32(pdu->records[i].dFlows);
853     SWAPINT32(pdu->records[i].dPkts);
854     SWAPINT32(pdu->records[i].dOctets);
855     SWAPINT32(pdu->records[i].First);
856     SWAPINT32(pdu->records[i].Last);
857     SWAPINT32(pdu->records[i].dst_prefix);
858     SWAPINT16(pdu->records[i].dst_as);
859     SWAPINT16(pdu->records[i].output);
860   }
861 
862 } /* ftpdu_v8_12_swap */
863 
864 /*
865  * function: ftpdu_v8_13_swap
866  *
867  * Swap bytes in a V8 agg method 13 PDU.  cur is the current
868  * byte order of the PDU
869  *
870 */
ftpdu_v8_13_swap(struct ftpdu_v8_13 * pdu,int cur)871 void ftpdu_v8_13_swap(struct ftpdu_v8_13 *pdu, int cur)
872 {
873   int16_t i;
874 
875   i = pdu->count;
876 
877 #if BYTE_ORDER == LITTLE_ENDIAN
878   if (cur == BIG_ENDIAN)
879     SWAPINT16(i);
880 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
881 
882 #if BYTE_ORDER == BIG_ENDIAN
883   if (cur == LITTLE_ENDIAN)
884     SWAPINT16(i);
885 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
886 
887   SWAPINT16(pdu->version);
888   SWAPINT16(pdu->count);
889   SWAPINT32(pdu->sysUpTime);
890   SWAPINT32(pdu->unix_secs);
891   SWAPINT32(pdu->unix_nsecs);
892   SWAPINT32(pdu->flow_sequence);
893 
894   for (--i; i >= 0; --i) {
895     SWAPINT32(pdu->records[i].dFlows);
896     SWAPINT32(pdu->records[i].dPkts);
897     SWAPINT32(pdu->records[i].dOctets);
898     SWAPINT32(pdu->records[i].First);
899     SWAPINT32(pdu->records[i].Last);
900     SWAPINT32(pdu->records[i].src_prefix);
901     SWAPINT32(pdu->records[i].dst_prefix);
902     SWAPINT16(pdu->records[i].src_as);
903     SWAPINT16(pdu->records[i].dst_as);
904     SWAPINT16(pdu->records[i].input);
905     SWAPINT16(pdu->records[i].output);
906   }
907 
908 } /* ftpdu_v8_13_swap */
909 
910 /*
911  * function: ftpdu_v8_14_swap
912  *
913  * Swap bytes in a V8 agg method 14 PDU.  cur is the current
914  * byte order of the PDU
915  *
916 */
ftpdu_v8_14_swap(struct ftpdu_v8_14 * pdu,int cur)917 void ftpdu_v8_14_swap(struct ftpdu_v8_14 *pdu, int cur)
918 {
919   int16_t i;
920 
921   i = pdu->count;
922 
923 #if BYTE_ORDER == LITTLE_ENDIAN
924   if (cur == BIG_ENDIAN)
925     SWAPINT16(i);
926 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
927 
928 #if BYTE_ORDER == BIG_ENDIAN
929   if (cur == LITTLE_ENDIAN)
930     SWAPINT16(i);
931 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
932 
933   SWAPINT16(pdu->version);
934   SWAPINT16(pdu->count);
935   SWAPINT32(pdu->sysUpTime);
936   SWAPINT32(pdu->unix_secs);
937   SWAPINT32(pdu->unix_nsecs);
938   SWAPINT32(pdu->flow_sequence);
939 
940   for (--i; i >= 0; --i) {
941     SWAPINT32(pdu->records[i].dFlows);
942     SWAPINT32(pdu->records[i].dPkts);
943     SWAPINT32(pdu->records[i].dOctets);
944     SWAPINT32(pdu->records[i].First);
945     SWAPINT32(pdu->records[i].Last);
946     SWAPINT32(pdu->records[i].src_prefix);
947     SWAPINT32(pdu->records[i].dst_prefix);
948     SWAPINT16(pdu->records[i].srcport);
949     SWAPINT16(pdu->records[i].dstport);
950     SWAPINT16(pdu->records[i].input);
951     SWAPINT16(pdu->records[i].output);
952   }
953 
954 } /* ftpdu_v8_14_swap */
955 
956 
957 /*
958  * function: fts3rec_swap_v1
959  *
960  * Swap bytes in a fts3rec_v1 struct
961  *
962 */
fts3rec_swap_v1(struct fts3rec_v1 * rec)963 void fts3rec_swap_v1(struct fts3rec_v1 *rec)
964 {
965   SWAPINT32(rec->unix_secs);
966   SWAPINT32(rec->unix_nsecs);
967   SWAPINT32(rec->sysUpTime);
968   SWAPINT32(rec->exaddr);
969   SWAPINT32(rec->srcaddr);
970   SWAPINT32(rec->dstaddr);
971   SWAPINT32(rec->nexthop);
972   SWAPINT16(rec->input);
973   SWAPINT16(rec->output);
974 
975   SWAPINT32(rec->dPkts);
976   SWAPINT32(rec->dOctets);
977   SWAPINT32(rec->First);
978   SWAPINT32(rec->Last);
979 
980   SWAPINT16(rec->srcport);
981   SWAPINT16(rec->dstport);
982 }
983 
984 /*
985  * function: fts3rec_swap_v5
986  *
987  * Swap bytes in a fts3rec_v5 struct
988  *
989 */
fts3rec_swap_v5(struct fts3rec_v5 * rec)990 void fts3rec_swap_v5(struct fts3rec_v5 *rec)
991 {
992   SWAPINT32(rec->unix_secs);
993   SWAPINT32(rec->unix_nsecs);
994   SWAPINT32(rec->sysUpTime);
995   SWAPINT32(rec->exaddr);
996   SWAPINT32(rec->srcaddr);
997   SWAPINT32(rec->dstaddr);
998   SWAPINT32(rec->nexthop);
999   SWAPINT16(rec->input);
1000   SWAPINT16(rec->output);
1001 
1002   SWAPINT32(rec->dPkts);
1003   SWAPINT32(rec->dOctets);
1004   SWAPINT32(rec->First);
1005   SWAPINT32(rec->Last);
1006 
1007   SWAPINT16(rec->srcport);
1008   SWAPINT16(rec->dstport);
1009 
1010   SWAPINT16(rec->src_as);
1011   SWAPINT16(rec->dst_as);
1012 }
1013 
1014 /*
1015  * function: fts3rec_swap_v6
1016  *
1017  * Swap bytes in a fts3rec_v6 struct
1018  *
1019 */
fts3rec_swap_v6(struct fts3rec_v6 * rec)1020 void fts3rec_swap_v6(struct fts3rec_v6 *rec)
1021 {
1022   SWAPINT32(rec->unix_secs);
1023   SWAPINT32(rec->unix_nsecs);
1024   SWAPINT32(rec->sysUpTime);
1025   SWAPINT32(rec->exaddr);
1026   SWAPINT32(rec->srcaddr);
1027   SWAPINT32(rec->dstaddr);
1028   SWAPINT32(rec->nexthop);
1029   SWAPINT16(rec->input);
1030   SWAPINT16(rec->output);
1031 
1032   SWAPINT32(rec->dPkts);
1033   SWAPINT32(rec->dOctets);
1034   SWAPINT32(rec->First);
1035   SWAPINT32(rec->Last);
1036 
1037   SWAPINT16(rec->srcport);
1038   SWAPINT16(rec->dstport);
1039 
1040   SWAPINT16(rec->src_as);
1041   SWAPINT16(rec->dst_as);
1042 
1043   SWAPINT32(rec->peer_nexthop);
1044 }
1045 
1046 /*
1047  * function: fts3rec_swap_v7
1048  *
1049  * Swap bytes in a fts3rec_v7 struct
1050  *
1051 */
fts3rec_swap_v7(struct fts3rec_v7 * rec)1052 void fts3rec_swap_v7(struct fts3rec_v7 *rec)
1053 {
1054   SWAPINT32(rec->unix_secs);
1055   SWAPINT32(rec->unix_nsecs);
1056   SWAPINT32(rec->sysUpTime);
1057   SWAPINT32(rec->exaddr);
1058   SWAPINT32(rec->srcaddr);
1059   SWAPINT32(rec->dstaddr);
1060   SWAPINT32(rec->nexthop);
1061   SWAPINT16(rec->input);
1062   SWAPINT16(rec->output);
1063 
1064   SWAPINT32(rec->dPkts);
1065   SWAPINT32(rec->dOctets);
1066   SWAPINT32(rec->First);
1067   SWAPINT32(rec->Last);
1068 
1069   SWAPINT16(rec->srcport);
1070   SWAPINT16(rec->dstport);
1071 
1072   SWAPINT16(rec->src_as);
1073   SWAPINT16(rec->dst_as);
1074 
1075   SWAPINT32(rec->router_sc);
1076 }
1077 
1078 /*
1079  * function: fts3rec_swap_v8_1
1080  *
1081  * Swap bytes in a fts3rec_v8_1 struct
1082  *
1083 */
fts3rec_swap_v8_1(struct fts3rec_v8_1 * rec)1084 void fts3rec_swap_v8_1(struct fts3rec_v8_1 *rec)
1085 {
1086   SWAPINT32(rec->unix_secs);
1087   SWAPINT32(rec->unix_nsecs);
1088   SWAPINT32(rec->sysUpTime);
1089   SWAPINT32(rec->exaddr);
1090   SWAPINT32(rec->dFlows);
1091   SWAPINT32(rec->dPkts);
1092   SWAPINT32(rec->dOctets);
1093   SWAPINT32(rec->First);
1094   SWAPINT32(rec->Last);
1095   SWAPINT16(rec->src_as);
1096   SWAPINT16(rec->dst_as);
1097   SWAPINT16(rec->input);
1098   SWAPINT16(rec->output);
1099 }
1100 
1101 /*
1102  * function: fts3rec_swap_v8_2
1103  *
1104  * Swap bytes in a fts3rec_v8_2 struct
1105  *
1106 */
fts3rec_swap_v8_2(struct fts3rec_v8_2 * rec)1107 void fts3rec_swap_v8_2(struct fts3rec_v8_2 *rec)
1108 {
1109   SWAPINT32(rec->unix_secs);
1110   SWAPINT32(rec->unix_nsecs);
1111   SWAPINT32(rec->sysUpTime);
1112   SWAPINT32(rec->exaddr);
1113   SWAPINT32(rec->dFlows);
1114   SWAPINT32(rec->dPkts);
1115   SWAPINT32(rec->dOctets);
1116   SWAPINT32(rec->First);
1117   SWAPINT32(rec->Last);
1118   SWAPINT16(rec->srcport);
1119   SWAPINT16(rec->dstport);
1120 }
1121 
1122 /*
1123  * function: fts3rec_swap_v8_3
1124  *
1125  * Swap bytes in a fts3rec_v8_3 struct
1126  *
1127 */
fts3rec_swap_v8_3(struct fts3rec_v8_3 * rec)1128 void fts3rec_swap_v8_3(struct fts3rec_v8_3 *rec)
1129 {
1130   SWAPINT32(rec->unix_secs);
1131   SWAPINT32(rec->unix_nsecs);
1132   SWAPINT32(rec->sysUpTime);
1133   SWAPINT32(rec->exaddr);
1134   SWAPINT32(rec->dFlows);
1135   SWAPINT32(rec->dPkts);
1136   SWAPINT32(rec->dOctets);
1137   SWAPINT32(rec->First);
1138   SWAPINT32(rec->Last);
1139   SWAPINT32(rec->srcaddr);
1140   SWAPINT16(rec->src_as);
1141   SWAPINT16(rec->input);
1142 }
1143 
1144 /*
1145  * function: fts3rec_swap_v8_4
1146  *
1147  * Swap bytes in a fts3rec_v8_4 struct
1148  *
1149 */
fts3rec_swap_v8_4(struct fts3rec_v8_4 * rec)1150 void fts3rec_swap_v8_4(struct fts3rec_v8_4 *rec)
1151 {
1152   SWAPINT32(rec->unix_secs);
1153   SWAPINT32(rec->unix_nsecs);
1154   SWAPINT32(rec->sysUpTime);
1155   SWAPINT32(rec->exaddr);
1156   SWAPINT32(rec->dFlows);
1157   SWAPINT32(rec->dPkts);
1158   SWAPINT32(rec->dOctets);
1159   SWAPINT32(rec->First);
1160   SWAPINT32(rec->Last);
1161   SWAPINT32(rec->dstaddr);
1162   SWAPINT16(rec->dst_as);
1163   SWAPINT16(rec->output);
1164 }
1165 
1166 /*
1167  * function: fts3rec_swap_v8_5
1168  *
1169  * Swap bytes in a fts3rec_v8_5 struct
1170  *
1171 */
fts3rec_swap_v8_5(struct fts3rec_v8_5 * rec)1172 void fts3rec_swap_v8_5(struct fts3rec_v8_5 *rec)
1173 {
1174   SWAPINT32(rec->unix_secs);
1175   SWAPINT32(rec->unix_nsecs);
1176   SWAPINT32(rec->sysUpTime);
1177   SWAPINT32(rec->exaddr);
1178   SWAPINT32(rec->dFlows);
1179   SWAPINT32(rec->dPkts);
1180   SWAPINT32(rec->dOctets);
1181   SWAPINT32(rec->First);
1182   SWAPINT32(rec->Last);
1183   SWAPINT32(rec->srcaddr);
1184   SWAPINT32(rec->dstaddr);
1185   SWAPINT16(rec->src_as);
1186   SWAPINT16(rec->dst_as);
1187   SWAPINT16(rec->input);
1188   SWAPINT16(rec->output);
1189 }
1190 
1191 /*
1192  * function: fts3rec_swap_v8_6
1193  *
1194  * Swap bytes in a fts3rec_v8_6 struct
1195  *
1196 */
fts3rec_swap_v8_6(struct fts3rec_v8_6 * rec)1197 void fts3rec_swap_v8_6(struct fts3rec_v8_6 *rec)
1198 {
1199   SWAPINT32(rec->unix_secs);
1200   SWAPINT32(rec->unix_nsecs);
1201   SWAPINT32(rec->sysUpTime);
1202   SWAPINT32(rec->exaddr);
1203   SWAPINT32(rec->dPkts);
1204   SWAPINT32(rec->dOctets);
1205   SWAPINT32(rec->First);
1206   SWAPINT32(rec->Last);
1207   SWAPINT32(rec->dstaddr);
1208   SWAPINT32(rec->extra_pkts);
1209   SWAPINT32(rec->router_sc);
1210   SWAPINT16(rec->output);
1211 }
1212 
1213 /*
1214  * function: fts3rec_swap_v8_7
1215  *
1216  * Swap bytes in a fts3rec_v8_7 struct
1217  *
1218 */
fts3rec_swap_v8_7(struct fts3rec_v8_7 * rec)1219 void fts3rec_swap_v8_7(struct fts3rec_v8_7 *rec)
1220 {
1221   SWAPINT32(rec->unix_secs);
1222   SWAPINT32(rec->unix_nsecs);
1223   SWAPINT32(rec->sysUpTime);
1224   SWAPINT32(rec->exaddr);
1225   SWAPINT32(rec->dPkts);
1226   SWAPINT32(rec->dOctets);
1227   SWAPINT32(rec->First);
1228   SWAPINT32(rec->Last);
1229   SWAPINT32(rec->dstaddr);
1230   SWAPINT32(rec->srcaddr);
1231   SWAPINT32(rec->extra_pkts);
1232   SWAPINT32(rec->router_sc);
1233   SWAPINT16(rec->input);
1234   SWAPINT16(rec->output);
1235 }
1236 
1237 /*
1238  * function: fts3rec_swap_v8_8
1239  *
1240  * Swap bytes in a fts3rec_v8_8 struct
1241  *
1242 */
fts3rec_swap_v8_8(struct fts3rec_v8_8 * rec)1243 void fts3rec_swap_v8_8(struct fts3rec_v8_8 *rec)
1244 {
1245   SWAPINT32(rec->unix_secs);
1246   SWAPINT32(rec->unix_nsecs);
1247   SWAPINT32(rec->sysUpTime);
1248   SWAPINT32(rec->exaddr);
1249   SWAPINT32(rec->dPkts);
1250   SWAPINT32(rec->dOctets);
1251   SWAPINT32(rec->First);
1252   SWAPINT32(rec->Last);
1253   SWAPINT32(rec->dstaddr);
1254   SWAPINT32(rec->srcaddr);
1255   SWAPINT32(rec->extra_pkts);
1256   SWAPINT32(rec->router_sc);
1257   SWAPINT16(rec->srcport);
1258   SWAPINT16(rec->dstport);
1259   SWAPINT16(rec->input);
1260   SWAPINT16(rec->output);
1261 }
1262 
1263 /*
1264  * function: fts3rec_swap_v8_9
1265  *
1266  * Swap bytes in a fts3rec_v8_9 struct
1267  *
1268 */
fts3rec_swap_v8_9(struct fts3rec_v8_9 * rec)1269 void fts3rec_swap_v8_9(struct fts3rec_v8_9 *rec)
1270 {
1271   SWAPINT32(rec->unix_secs);
1272   SWAPINT32(rec->unix_nsecs);
1273   SWAPINT32(rec->sysUpTime);
1274   SWAPINT32(rec->exaddr);
1275   SWAPINT32(rec->dFlows);
1276   SWAPINT32(rec->dPkts);
1277   SWAPINT32(rec->dOctets);
1278   SWAPINT32(rec->First);
1279   SWAPINT32(rec->Last);
1280   SWAPINT16(rec->src_as);
1281   SWAPINT16(rec->dst_as);
1282   SWAPINT16(rec->input);
1283   SWAPINT16(rec->output);
1284 }
1285 
1286 /*
1287  * function: fts3rec_swap_v8_10
1288  *
1289  * Swap bytes in a fts3rec_v8_10 struct
1290  *
1291 */
fts3rec_swap_v8_10(struct fts3rec_v8_10 * rec)1292 void fts3rec_swap_v8_10(struct fts3rec_v8_10 *rec)
1293 {
1294   SWAPINT32(rec->unix_secs);
1295   SWAPINT32(rec->unix_nsecs);
1296   SWAPINT32(rec->sysUpTime);
1297   SWAPINT32(rec->exaddr);
1298   SWAPINT32(rec->dFlows);
1299   SWAPINT32(rec->dPkts);
1300   SWAPINT32(rec->dOctets);
1301   SWAPINT32(rec->First);
1302   SWAPINT32(rec->Last);
1303   SWAPINT16(rec->srcport);
1304   SWAPINT16(rec->dstport);
1305   SWAPINT16(rec->input);
1306   SWAPINT16(rec->output);
1307 }
1308 
1309 /*
1310  * function: fts3rec_swap_v8_11
1311  *
1312  * Swap bytes in a fts3rec_v8_11 struct
1313  *
1314 */
fts3rec_swap_v8_11(struct fts3rec_v8_11 * rec)1315 void fts3rec_swap_v8_11(struct fts3rec_v8_11 *rec)
1316 {
1317   SWAPINT32(rec->unix_secs);
1318   SWAPINT32(rec->unix_nsecs);
1319   SWAPINT32(rec->sysUpTime);
1320   SWAPINT32(rec->exaddr);
1321   SWAPINT32(rec->dFlows);
1322   SWAPINT32(rec->dPkts);
1323   SWAPINT32(rec->dOctets);
1324   SWAPINT32(rec->First);
1325   SWAPINT32(rec->Last);
1326   SWAPINT32(rec->srcaddr);
1327   SWAPINT16(rec->src_as);
1328   SWAPINT16(rec->input);
1329 }
1330 
1331 /*
1332  * function: fts3rec_swap_v8_12
1333  *
1334  * Swap bytes in a fts3rec_v8_12 struct
1335  *
1336 */
fts3rec_swap_v8_12(struct fts3rec_v8_12 * rec)1337 void fts3rec_swap_v8_12(struct fts3rec_v8_12 *rec)
1338 {
1339   SWAPINT32(rec->unix_secs);
1340   SWAPINT32(rec->unix_nsecs);
1341   SWAPINT32(rec->sysUpTime);
1342   SWAPINT32(rec->exaddr);
1343   SWAPINT32(rec->dFlows);
1344   SWAPINT32(rec->dPkts);
1345   SWAPINT32(rec->dOctets);
1346   SWAPINT32(rec->First);
1347   SWAPINT32(rec->Last);
1348   SWAPINT32(rec->dstaddr);
1349   SWAPINT16(rec->output);
1350 }
1351 
1352 /*
1353  * function: fts3rec_swap_v8_13
1354  *
1355  * Swap bytes in a fts3rec_v8_13 struct
1356  *
1357 */
fts3rec_swap_v8_13(struct fts3rec_v8_13 * rec)1358 void fts3rec_swap_v8_13(struct fts3rec_v8_13 *rec)
1359 {
1360   SWAPINT32(rec->unix_secs);
1361   SWAPINT32(rec->unix_nsecs);
1362   SWAPINT32(rec->sysUpTime);
1363   SWAPINT32(rec->exaddr);
1364   SWAPINT32(rec->dFlows);
1365   SWAPINT32(rec->dPkts);
1366   SWAPINT32(rec->dOctets);
1367   SWAPINT32(rec->First);
1368   SWAPINT32(rec->Last);
1369   SWAPINT32(rec->srcaddr);
1370   SWAPINT32(rec->dstaddr);
1371   SWAPINT16(rec->src_as);
1372   SWAPINT16(rec->dst_as);
1373   SWAPINT16(rec->input);
1374   SWAPINT16(rec->output);
1375 }
1376 
1377 /*
1378  * function: fts3rec_swap_v8_14
1379  *
1380  * Swap bytes in a fts3rec_v8_14 struct
1381  *
1382 */
fts3rec_swap_v8_14(struct fts3rec_v8_14 * rec)1383 void fts3rec_swap_v8_14(struct fts3rec_v8_14 *rec)
1384 {
1385   SWAPINT32(rec->unix_secs);
1386   SWAPINT32(rec->unix_nsecs);
1387   SWAPINT32(rec->sysUpTime);
1388   SWAPINT32(rec->exaddr);
1389   SWAPINT32(rec->dFlows);
1390   SWAPINT32(rec->dPkts);
1391   SWAPINT32(rec->dOctets);
1392   SWAPINT32(rec->First);
1393   SWAPINT32(rec->Last);
1394   SWAPINT32(rec->srcaddr);
1395   SWAPINT32(rec->dstaddr);
1396   SWAPINT16(rec->srcport);
1397   SWAPINT16(rec->dstport);
1398   SWAPINT16(rec->input);
1399   SWAPINT16(rec->output);
1400 }
1401 
1402 
1403 /*
1404  * function: fts3rec_swap_v1005
1405  *
1406  * Swap bytes in a fts3rec_v1005 struct
1407  *
1408 */
fts3rec_swap_v1005(struct fts3rec_v1005 * rec)1409 void fts3rec_swap_v1005(struct fts3rec_v1005 *rec)
1410 {
1411   SWAPINT32(rec->unix_secs);
1412   SWAPINT32(rec->unix_nsecs);
1413   SWAPINT32(rec->sysUpTime);
1414   SWAPINT32(rec->srcaddr);
1415   SWAPINT32(rec->dstaddr);
1416   SWAPINT32(rec->nexthop);
1417   SWAPINT16(rec->input);
1418   SWAPINT16(rec->output);
1419 
1420   SWAPINT32(rec->dPkts);
1421   SWAPINT32(rec->dOctets);
1422   SWAPINT32(rec->First);
1423   SWAPINT32(rec->Last);
1424 
1425   SWAPINT16(rec->srcport);
1426   SWAPINT16(rec->dstport);
1427 
1428   SWAPINT16(rec->src_as);
1429   SWAPINT16(rec->dst_as);
1430 
1431   SWAPINT16(rec->src_tag);
1432   SWAPINT16(rec->dst_tag);
1433 
1434 }
1435 
1436 /*
1437  * function: fts3rec_swap_compat
1438  *
1439  * Swap bytes in a fts3rec_compat struct
1440  *
1441 */
fts1rec_swap_compat(struct fts1rec_compat * rec)1442 void fts1rec_swap_compat(struct fts1rec_compat *rec)
1443 {
1444   SWAPINT32(rec->unix_secs);
1445   SWAPINT32(rec->unix_msecs);
1446   SWAPINT32(rec->srcaddr);
1447   SWAPINT32(rec->dstaddr);
1448   SWAPINT32(rec->nexthop);
1449   SWAPINT16(rec->input);
1450   SWAPINT16(rec->output);
1451 
1452   SWAPINT32(rec->dPkts);
1453   SWAPINT32(rec->dOctets);
1454   SWAPINT32(rec->First);
1455   SWAPINT32(rec->Last);
1456 
1457   SWAPINT16(rec->srcport);
1458   SWAPINT16(rec->dstport);
1459   SWAPINT16(rec->pad);
1460 
1461   SWAPINT16(rec->src_as);
1462   SWAPINT16(rec->dst_as);
1463   SWAPINT16(rec->drops);
1464 }
1465 
1466