1 /*
2 ** Copyright (C) 2007-2020 by Carnegie Mellon University.
3 **
4 ** @OPENSOURCE_LICENSE_START@
5 ** See license information in ../../LICENSE.txt
6 ** @OPENSOURCE_LICENSE_END@
7 */
8
9 /*
10 ** rwrec.c
11 **
12 ** Functions to get/set values on the rwRec structure.
13 **
14 ** Usually these are not used, since we prefer to use macros to get
15 ** and set values on rwRec; however some functionality is complex
16 ** enough to require a function, particular those dealing with IPv6
17 ** addresses.
18 **
19 ** In addition, these functions are used when RWREC_OPAQUE is 1.
20 **
21 */
22
23 #define RWREC_DEFINE_BODY 1
24 #include <silk/silk.h>
25
26 RCSIDENT("$SiLK: rwrec.c ef14e54179be 2020-04-14 21:57:45Z mthomas $");
27
28 #include <silk/rwrec.h>
29 #include <silk/skipaddr.h>
30 #include <silk/utils.h>
31
32
33 /* FUNCTION DEFINITIONS */
34
35
36 #if SK_ENABLE_IPV6
37 /*
38 * Helper function to compare an IP on an rwRec with an skipaddr_t.
39 */
40 static int
recCompareIPAddr(const rwRec * r,const skIPUnion_t * ip,const skipaddr_t * cmp_addr)41 recCompareIPAddr(
42 const rwRec *r,
43 const skIPUnion_t *ip,
44 const skipaddr_t *cmp_addr)
45 {
46 skIPUnion_t tmp;
47
48 if (_recIsIPv6(r)) {
49 if (cmp_addr->ip_is_v6) {
50 /* both are IPv6 */
51 return memcmp(ip->ipu_ipv6, cmp_addr->ip_ip.ipu_ipv6, 16);
52 }
53 /* must convert cmp_addr to V6 */
54 skIPUnion4to6(&(cmp_addr->ip_ip), &tmp);
55 return memcmp(ip->ipu_ipv6, tmp.ipu_ipv6, 16);
56 }
57 if (cmp_addr->ip_is_v6) {
58 /* must convert record IP to V6 */
59 skIPUnion4to6(ip, &tmp);
60 return memcmp(tmp.ipu_ipv6, cmp_addr->ip_ip.ipu_ipv6, 16);
61 }
62 /* both addresses are IPv4 */
63 if (ip->ipu_ipv4 < cmp_addr->ip_ip.ipu_ipv4) {
64 return -1;
65 }
66 if (ip->ipu_ipv4 > cmp_addr->ip_ip.ipu_ipv4) {
67 return 1;
68 }
69 return 0;
70 }
71
72
73 /*
74 * Helper function to mask an IP on an rwRec with an skipaddr_t.
75 */
76 static void
recApplyMaskIPAddr(rwRec * r,skIPUnion_t * ip,const skipaddr_t * mask_addr)77 recApplyMaskIPAddr(
78 rwRec *r,
79 skIPUnion_t *ip,
80 const skipaddr_t *mask_addr)
81 {
82 skIPUnion_t tmp;
83
84 if (_recIsIPv6(r)) {
85 if (mask_addr->ip_is_v6) {
86 /* both are IPv6 */
87 skIPUnionApplyMaskV6(ip, mask_addr->ip_ip.ipu_ipv6);
88 return;
89 }
90 /* must convert mask_addr to V6 */
91 skIPUnion4to6(&(mask_addr->ip_ip), &tmp);
92 skIPUnionApplyMaskV6(ip, tmp.ipu_ipv6);
93 return;
94 }
95 if (mask_addr->ip_is_v6) {
96 /* Record is IPv4 and 'mask_addr' is IPv6. if bytes 10 and 11
97 * of 'mask_addr' are 0xFFFF, then an IPv4 address will
98 * result; otherwise, we must convert the record to IPv6 and
99 * we'll get something strange */
100 if (memcmp(&mask_addr->ip_ip.ipu_ipv6[10], &sk_ipv6_v4inv6[10], 2)
101 == 0)
102 {
103 uint32_t mask_v4;
104 memcpy(&mask_v4, &mask_addr->ip_ip.ipu_ipv6[12], 4);
105 skIPUnionApplyMaskV4(ip, ntohl(mask_v4));
106 return;
107 }
108 _recConvertToIPv6(r);
109 skIPUnionApplyMaskV6(ip, mask_addr->ip_ip.ipu_ipv6);
110 return;
111 }
112 /* both addresses are IPv4 */
113 skIPUnionApplyMaskV4(ip, mask_addr->ip_ip.ipu_ipv4);
114 }
115 #endif /* SK_ENABLE_IPV6 */
116
117
118 uint8_t
rwrec_GetIcmpType(const rwRec * r)119 rwrec_GetIcmpType(
120 const rwRec *r)
121 {
122 return _recGetIcmpType(r);
123 }
124
125
126 void
rwrec_SetIcmpType(rwRec * r,uint8_t in_v)127 rwrec_SetIcmpType(
128 rwRec *r,
129 uint8_t in_v)
130 {
131 _recSetIcmpType(r, in_v);
132 }
133
134
135 void
rwrec_MemGetIcmpType(const rwRec * r,void * out_vp)136 rwrec_MemGetIcmpType(
137 const rwRec *r,
138 void *out_vp)
139 {
140 _recMemGetIcmpType(r, (uint8_t*)out_vp);
141 }
142
143
144 uint8_t
rwrec_GetIcmpCode(const rwRec * r)145 rwrec_GetIcmpCode(
146 const rwRec *r)
147 {
148 return _recGetIcmpCode(r);
149 }
150
151
152 void
rwrec_SetIcmpCode(rwRec * r,uint8_t in_v)153 rwrec_SetIcmpCode(
154 rwRec *r,
155 uint8_t in_v)
156 {
157 _recSetIcmpCode(r, in_v);
158 }
159
160
161 void
rwrec_MemGetIcmpCode(const rwRec * r,void * out_vp)162 rwrec_MemGetIcmpCode(
163 const rwRec *r,
164 void *out_vp)
165 {
166 _recMemGetIcmpCode(r, (uint8_t*)out_vp);
167 }
168
169
170 uint16_t
rwrec_GetIcmpTypeAndCode(const rwRec * r)171 rwrec_GetIcmpTypeAndCode(
172 const rwRec *r)
173 {
174 return _recGetIcmpTypeAndCode(r);
175 }
176
177
178 void
rwrec_SetIcmpTypeAndCode(rwRec * r,uint16_t in_v)179 rwrec_SetIcmpTypeAndCode(
180 rwRec *r,
181 uint16_t in_v)
182 {
183 _recSetIcmpTypeAndCode(r, in_v);
184 }
185
186
187 void
rwrec_MemGetIcmpTypeAndCode(const rwRec * r,void * out_vp)188 rwrec_MemGetIcmpTypeAndCode(
189 const rwRec *r,
190 void *out_vp)
191 {
192 _recMemGetIcmpTypeAndCode(r, out_vp);
193 }
194
195
196 void
rwrec_MemSetIcmpTypeAndCode(rwRec * r,const void * in_vp)197 rwrec_MemSetIcmpTypeAndCode(
198 rwRec *r,
199 const void *in_vp)
200 {
201 _recMemSetIcmpTypeAndCode(r, in_vp);
202 }
203
204
205 int
rwrec_MemCmpIcmpTypeAndCode(const rwRec * r,const void * vp)206 rwrec_MemCmpIcmpTypeAndCode(
207 const rwRec *r,
208 const void *vp)
209 {
210 return _recMemCmpIcmpTypeAndCode(r, vp);
211 }
212
213
214 uint32_t
rwrec_GetSIPv4(const rwRec * r)215 rwrec_GetSIPv4(
216 const rwRec *r)
217 {
218 return _recGetSIPv4(r);
219 }
220
221
222 void
rwrec_SetSIPv4(rwRec * r,uint32_t in_v)223 rwrec_SetSIPv4(
224 rwRec *r,
225 uint32_t in_v)
226 {
227 _recSetSIPv4(r, in_v);
228 }
229
230
231 void
rwrec_MemGetSIPv4(const rwRec * r,void * out_vp)232 rwrec_MemGetSIPv4(
233 const rwRec *r,
234 void *out_vp)
235 {
236 _recMemGetSIPv4(r, out_vp);
237 }
238
239
240 void
rwrec_MemSetSIPv4(rwRec * r,const void * in_vp)241 rwrec_MemSetSIPv4(
242 rwRec *r,
243 const void *in_vp)
244 {
245 _recMemSetSIPv4(r, in_vp);
246 }
247
248
249 int
rwrec_MemCmpSIPv4(const rwRec * r,const void * vp)250 rwrec_MemCmpSIPv4(
251 const rwRec *r,
252 const void *vp)
253 {
254 return _recMemCmpSIPv4(r, vp);
255 }
256
257
258 uint32_t
rwrec_GetMaskSIPv4(const rwRec * r,uint32_t mask)259 rwrec_GetMaskSIPv4(
260 const rwRec *r,
261 uint32_t mask)
262 {
263 return _recGetMaskSIPv4(r, mask);
264 }
265
266
267 void
rwrec_ApplyMaskSIPv4(rwRec * r,uint32_t mask)268 rwrec_ApplyMaskSIPv4(
269 rwRec *r,
270 uint32_t mask)
271 {
272 _recApplyMaskSIPv4(r, mask);
273 }
274
275
276 uint32_t
rwrec_GetDIPv4(const rwRec * r)277 rwrec_GetDIPv4(
278 const rwRec *r)
279 {
280 return _recGetDIPv4(r);
281 }
282
283
284 void
rwrec_SetDIPv4(rwRec * r,uint32_t in_v)285 rwrec_SetDIPv4(
286 rwRec *r,
287 uint32_t in_v)
288 {
289 _recSetDIPv4(r, in_v);
290 }
291
292
293 void
rwrec_MemGetDIPv4(const rwRec * r,void * out_vp)294 rwrec_MemGetDIPv4(
295 const rwRec *r,
296 void *out_vp)
297 {
298 _recMemGetDIPv4(r, out_vp);
299 }
300
301
302 void
rwrec_MemSetDIPv4(rwRec * r,const void * in_vp)303 rwrec_MemSetDIPv4(
304 rwRec *r,
305 const void *in_vp)
306 {
307 _recMemSetDIPv4(r, in_vp);
308 }
309
310
311 int
rwrec_MemCmpDIPv4(const rwRec * r,const void * vp)312 rwrec_MemCmpDIPv4(
313 const rwRec *r,
314 const void *vp)
315 {
316 return _recMemCmpDIPv4(r, vp);
317 }
318
319
320 uint32_t
rwrec_GetMaskDIPv4(const rwRec * r,uint32_t mask)321 rwrec_GetMaskDIPv4(
322 const rwRec *r,
323 uint32_t mask)
324 {
325 return _recGetMaskDIPv4(r, mask);
326 }
327
328
329 void
rwrec_ApplyMaskDIPv4(rwRec * r,uint32_t mask)330 rwrec_ApplyMaskDIPv4(
331 rwRec *r,
332 uint32_t mask)
333 {
334 _recApplyMaskDIPv4(r, mask);
335 }
336
337
338 uint16_t
rwrec_GetSPort(const rwRec * r)339 rwrec_GetSPort(
340 const rwRec *r)
341 {
342 return _recGetSPort(r);
343 }
344
345
346 void
rwrec_SetSPort(rwRec * r,uint16_t in_v)347 rwrec_SetSPort(
348 rwRec *r,
349 uint16_t in_v)
350 {
351 _recSetSPort(r, in_v);
352 }
353
354
355 void
rwrec_MemGetSPort(const rwRec * r,void * out_vp)356 rwrec_MemGetSPort(
357 const rwRec *r,
358 void *out_vp)
359 {
360 _recMemGetSPort(r, out_vp);
361 }
362
363
364 void
rwrec_MemSetSPort(rwRec * r,const void * in_vp)365 rwrec_MemSetSPort(
366 rwRec *r,
367 const void *in_vp)
368 {
369 _recMemSetSPort(r, in_vp);
370 }
371
372
373 int
rwrec_MemCmpSPort(const rwRec * r,const void * vp)374 rwrec_MemCmpSPort(
375 const rwRec *r,
376 const void *vp)
377 {
378 return _recMemCmpSPort(r, vp);
379 }
380
381
382 uint16_t
rwrec_GetDPort(const rwRec * r)383 rwrec_GetDPort(
384 const rwRec *r)
385 {
386 return _recGetDPort(r);
387 }
388
389
390 void
rwrec_SetDPort(rwRec * r,uint16_t in_v)391 rwrec_SetDPort(
392 rwRec *r,
393 uint16_t in_v)
394 {
395 _recSetDPort(r, in_v);
396 }
397
398
399 void
rwrec_MemGetDPort(const rwRec * r,void * out_vp)400 rwrec_MemGetDPort(
401 const rwRec *r,
402 void *out_vp)
403 {
404 _recMemGetDPort(r, out_vp);
405 }
406
407
408 void
rwrec_MemSetDPort(rwRec * r,const void * in_vp)409 rwrec_MemSetDPort(
410 rwRec *r,
411 const void *in_vp)
412 {
413 _recMemSetDPort(r, in_vp);
414 }
415
416
417 int
rwrec_MemCmpDPort(const rwRec * r,const void * vp)418 rwrec_MemCmpDPort(
419 const rwRec *r,
420 const void *vp)
421 {
422 return _recMemCmpDPort(r, vp);
423 }
424
425
426 uint8_t
rwrec_GetProto(const rwRec * r)427 rwrec_GetProto(
428 const rwRec *r)
429 {
430 return _recGetProto(r);
431 }
432
433
434 void
rwrec_SetProto(rwRec * r,uint8_t in_v)435 rwrec_SetProto(
436 rwRec *r,
437 uint8_t in_v)
438 {
439 _recSetProto(r, in_v);
440 }
441
442
443 void
rwrec_MemGetProto(const rwRec * r,void * out_vp)444 rwrec_MemGetProto(
445 const rwRec *r,
446 void *out_vp)
447 {
448 _recMemGetProto(r, out_vp);
449 }
450
451
452 void
rwrec_MemSetProto(rwRec * r,const void * in_vp)453 rwrec_MemSetProto(
454 rwRec *r,
455 const void *in_vp)
456 {
457 _recMemSetProto(r, in_vp);
458 }
459
460
461 int
rwrec_MemCmpProto(const rwRec * r,const void * vp)462 rwrec_MemCmpProto(
463 const rwRec *r,
464 const void *vp)
465 {
466 return _recMemCmpProto(r, vp);
467 }
468
469
470 uint32_t
rwrec_GetPkts(const rwRec * r)471 rwrec_GetPkts(
472 const rwRec *r)
473 {
474 return _recGetPkts(r);
475 }
476
477
478 void
rwrec_SetPkts(rwRec * r,uint32_t in_v)479 rwrec_SetPkts(
480 rwRec *r,
481 uint32_t in_v)
482 {
483 _recSetPkts(r, in_v);
484 }
485
486
487 void
rwrec_MemGetPkts(const rwRec * r,void * out_vp)488 rwrec_MemGetPkts(
489 const rwRec *r,
490 void *out_vp)
491 {
492 _recMemGetPkts(r, out_vp);
493 }
494
495
496 void
rwrec_MemSetPkts(rwRec * r,const void * in_vp)497 rwrec_MemSetPkts(
498 rwRec *r,
499 const void *in_vp)
500 {
501 _recMemSetPkts(r, in_vp);
502 }
503
504
505 int
rwrec_MemCmpPkts(const rwRec * r,const void * vp)506 rwrec_MemCmpPkts(
507 const rwRec *r,
508 const void *vp)
509 {
510 return _recMemCmpPkts(r, vp);
511 }
512
513
514 uint32_t
rwrec_GetBytes(const rwRec * r)515 rwrec_GetBytes(
516 const rwRec *r)
517 {
518 return _recGetBytes(r);
519 }
520
521
522 void
rwrec_SetBytes(rwRec * r,uint32_t in_v)523 rwrec_SetBytes(
524 rwRec *r,
525 uint32_t in_v)
526 {
527 _recSetBytes(r, in_v);
528 }
529
530
531 void
rwrec_MemGetBytes(const rwRec * r,void * out_vp)532 rwrec_MemGetBytes(
533 const rwRec *r,
534 void *out_vp)
535 {
536 _recMemGetBytes(r, out_vp);
537 }
538
539
540 void
rwrec_MemSetBytes(rwRec * r,const void * in_vp)541 rwrec_MemSetBytes(
542 rwRec *r,
543 const void *in_vp)
544 {
545 _recMemSetBytes(r, in_vp);
546 }
547
548
549 int
rwrec_MemCmpBytes(const rwRec * r,const void * vp)550 rwrec_MemCmpBytes(
551 const rwRec *r,
552 const void *vp)
553 {
554 return _recMemCmpBytes(r, vp);
555 }
556
557
558 uint8_t
rwrec_GetFlags(const rwRec * r)559 rwrec_GetFlags(
560 const rwRec *r)
561 {
562 return _recGetFlags(r);
563 }
564
565
566 void
rwrec_SetFlags(rwRec * r,uint8_t in_v)567 rwrec_SetFlags(
568 rwRec *r,
569 uint8_t in_v)
570 {
571 _recSetFlags(r, in_v);
572 }
573
574
575 void
rwrec_MemGetFlags(const rwRec * r,void * out_vp)576 rwrec_MemGetFlags(
577 const rwRec *r,
578 void *out_vp)
579 {
580 _recMemGetFlags(r, out_vp);
581 }
582
583
584 void
rwrec_MemSetFlags(rwRec * r,const void * in_vp)585 rwrec_MemSetFlags(
586 rwRec *r,
587 const void *in_vp)
588 {
589 _recMemSetFlags(r, in_vp);
590 }
591
592
593 int
rwrec_MemCmpFlags(const rwRec * r,const void * vp)594 rwrec_MemCmpFlags(
595 const rwRec *r,
596 const void *vp)
597 {
598 return _recMemCmpFlags(r, vp);
599 }
600
601
602 sktime_t
rwrec_GetStartTime(const rwRec * r)603 rwrec_GetStartTime(
604 const rwRec *r)
605 {
606 return _recGetStartTime(r);
607 }
608
609
610 void
rwrec_SetStartTime(rwRec * r,sktime_t in_v)611 rwrec_SetStartTime(
612 rwRec *r,
613 sktime_t in_v)
614 {
615 _recSetStartTime(r, in_v);
616 }
617
618
619 void
rwrec_MemGetStartTime(const rwRec * r,void * out_vp)620 rwrec_MemGetStartTime(
621 const rwRec *r,
622 void *out_vp)
623 {
624 _recMemGetStartTime(r, out_vp);
625 }
626
627
628 void
rwrec_MemSetStartTime(rwRec * r,const void * in_vp)629 rwrec_MemSetStartTime(
630 rwRec *r,
631 const void *in_vp)
632 {
633 _recMemSetStartTime(r, in_vp);
634 }
635
636
637 int
rwrec_MemCmpStartTime(const rwRec * r,const void * vp)638 rwrec_MemCmpStartTime(
639 const rwRec *r,
640 const void *vp)
641 {
642 return _recMemCmpStartTime(r, vp);
643 }
644
645
646 uint32_t
rwrec_GetStartSeconds(const rwRec * r)647 rwrec_GetStartSeconds(
648 const rwRec *r)
649 {
650 return _recGetStartSeconds(r);
651 }
652
653
654 void
rwrec_MemGetStartSeconds(const rwRec * r,void * out_vp)655 rwrec_MemGetStartSeconds(
656 const rwRec *r,
657 void *out_vp)
658 {
659 _recMemGetStartSeconds(r, out_vp);
660 }
661
662
663 uint32_t
rwrec_GetElapsed(const rwRec * r)664 rwrec_GetElapsed(
665 const rwRec *r)
666 {
667 return _recGetElapsed(r);
668 }
669
670
671 void
rwrec_SetElapsed(rwRec * r,sktime_t in_v)672 rwrec_SetElapsed(
673 rwRec *r,
674 sktime_t in_v)
675 {
676 _recSetElapsed(r, in_v);
677 }
678
679
680 void
rwrec_MemGetElapsed(const rwRec * r,void * out_vp)681 rwrec_MemGetElapsed(
682 const rwRec *r,
683 void *out_vp)
684 {
685 _recMemGetElapsed(r, out_vp);
686 }
687
688
689 void
rwrec_MemSetElapsed(rwRec * r,const void * in_vp)690 rwrec_MemSetElapsed(
691 rwRec *r,
692 const void *in_vp)
693 {
694 _recMemSetElapsed(r, in_vp);
695 }
696
697
698 int
rwrec_MemCmpElapsed(const rwRec * r,const void * vp)699 rwrec_MemCmpElapsed(
700 const rwRec *r,
701 const void *vp)
702 {
703 return _recMemCmpElapsed(r, vp);
704 }
705
706
707 uint32_t
rwrec_GetElapsedSeconds(const rwRec * r)708 rwrec_GetElapsedSeconds(
709 const rwRec *r)
710 {
711 return _recGetElapsedSeconds(r);
712 }
713
714
715 void
rwrec_MemGetElapsedSeconds(const rwRec * r,void * out_vp)716 rwrec_MemGetElapsedSeconds(
717 const rwRec *r,
718 void *out_vp)
719 {
720 _recMemGetElapsedSeconds(r, out_vp);
721 }
722
723
724 sktime_t
rwrec_GetEndTime(const rwRec * r)725 rwrec_GetEndTime(
726 const rwRec *r)
727 {
728 return _recGetEndTime(r);
729 }
730
731
732 void
rwrec_MemGetEndTime(const rwRec * r,void * out_vp)733 rwrec_MemGetEndTime(
734 const rwRec *r,
735 void *out_vp)
736 {
737 _recMemGetEndTime(r, out_vp);
738 }
739
740
741 uint32_t
rwrec_GetEndSeconds(const rwRec * r)742 rwrec_GetEndSeconds(
743 const rwRec *r)
744 {
745 return _recGetEndSeconds(r);
746 }
747
748
749 void
rwrec_MemGetEndSeconds(const rwRec * r,void * out_vp)750 rwrec_MemGetEndSeconds(
751 const rwRec *r,
752 void *out_vp)
753 {
754 _recMemGetEndSeconds(r, out_vp);
755 }
756
757
758 sk_sensor_id_t
rwrec_GetSensor(const rwRec * r)759 rwrec_GetSensor(
760 const rwRec *r)
761 {
762 return _recGetSensor(r);
763 }
764
765
766 void
rwrec_SetSensor(rwRec * r,sk_sensor_id_t in_v)767 rwrec_SetSensor(
768 rwRec *r,
769 sk_sensor_id_t in_v)
770 {
771 _recSetSensor(r, in_v);
772 }
773
774
775 void
rwrec_MemGetSensor(const rwRec * r,void * out_vp)776 rwrec_MemGetSensor(
777 const rwRec *r,
778 void *out_vp)
779 {
780 _recMemGetSensor(r, out_vp);
781 }
782
783
784 void
rwrec_MemSetSensor(rwRec * r,const void * in_vp)785 rwrec_MemSetSensor(
786 rwRec *r,
787 const void *in_vp)
788 {
789 _recMemSetSensor(r, in_vp);
790 }
791
792
793 int
rwrec_MemCmpSensor(const rwRec * r,const void * vp)794 rwrec_MemCmpSensor(
795 const rwRec *r,
796 const void *vp)
797 {
798 return _recMemCmpSensor(r, vp);
799 }
800
801
802 uint32_t
rwrec_GetNhIPv4(const rwRec * r)803 rwrec_GetNhIPv4(
804 const rwRec *r)
805 {
806 return _recGetNhIPv4(r);
807 }
808
809
810 void
rwrec_SetNhIPv4(rwRec * r,uint32_t in_v)811 rwrec_SetNhIPv4(
812 rwRec *r,
813 uint32_t in_v)
814 {
815 _recSetNhIPv4(r, in_v);
816 }
817
818
819 void
rwrec_MemGetNhIPv4(const rwRec * r,void * out_vp)820 rwrec_MemGetNhIPv4(
821 const rwRec *r,
822 void *out_vp)
823 {
824 _recMemGetNhIPv4(r, out_vp);
825 }
826
827
828 void
rwrec_MemSetNhIPv4(rwRec * r,const void * in_vp)829 rwrec_MemSetNhIPv4(
830 rwRec *r,
831 const void *in_vp)
832 {
833 _recMemSetNhIPv4(r, in_vp);
834 }
835
836
837 int
rwrec_MemCmpNhIPv4(const rwRec * r,const void * vp)838 rwrec_MemCmpNhIPv4(
839 const rwRec *r,
840 const void *vp)
841 {
842 return _recMemCmpNhIPv4(r, vp);
843 }
844
845
846 uint32_t
rwrec_GetMaskNhIPv4(const rwRec * r,uint32_t mask)847 rwrec_GetMaskNhIPv4(
848 const rwRec *r,
849 uint32_t mask)
850 {
851 return _recGetMaskNhIPv4(r, mask);
852 }
853
854
855 void
rwrec_ApplyMaskNhIPv4(rwRec * r,uint32_t mask)856 rwrec_ApplyMaskNhIPv4(
857 rwRec *r,
858 uint32_t mask)
859 {
860 _recApplyMaskNhIPv4(r, mask);
861 }
862
863
864 uint16_t
rwrec_GetInput(const rwRec * r)865 rwrec_GetInput(
866 const rwRec *r)
867 {
868 return _recGetInput(r);
869 }
870
871
872 void
rwrec_SetInput(rwRec * r,uint16_t in_v)873 rwrec_SetInput(
874 rwRec *r,
875 uint16_t in_v)
876 {
877 _recSetInput(r, in_v);
878 }
879
880
881 void
rwrec_MemGetInput(const rwRec * r,void * out_vp)882 rwrec_MemGetInput(
883 const rwRec *r,
884 void *out_vp)
885 {
886 _recMemGetInput(r, out_vp);
887 }
888
889
890 void
rwrec_MemSetInput(rwRec * r,const void * in_vp)891 rwrec_MemSetInput(
892 rwRec *r,
893 const void *in_vp)
894 {
895 _recMemSetInput(r, in_vp);
896 }
897
898
899 int
rwrec_MemCmpInput(const rwRec * r,const void * vp)900 rwrec_MemCmpInput(
901 const rwRec *r,
902 const void *vp)
903 {
904 return _recMemCmpInput(r, vp);
905 }
906
907
908 uint16_t
rwrec_GetOutput(const rwRec * r)909 rwrec_GetOutput(
910 const rwRec *r)
911 {
912 return _recGetOutput(r);
913 }
914
915
916 void
rwrec_SetOutput(rwRec * r,uint16_t in_v)917 rwrec_SetOutput(
918 rwRec *r,
919 uint16_t in_v)
920 {
921 _recSetOutput(r, in_v);
922 }
923
924
925 void
rwrec_MemGetOutput(const rwRec * r,void * out_vp)926 rwrec_MemGetOutput(
927 const rwRec *r,
928 void *out_vp)
929 {
930 _recMemGetOutput(r, out_vp);
931 }
932
933
934 void
rwrec_MemSetOutput(rwRec * r,const void * in_vp)935 rwrec_MemSetOutput(
936 rwRec *r,
937 const void *in_vp)
938 {
939 _recMemSetOutput(r, in_vp);
940 }
941
942
943 int
rwrec_MemCmpOutput(const rwRec * r,const void * vp)944 rwrec_MemCmpOutput(
945 const rwRec *r,
946 const void *vp)
947 {
948 return _recMemCmpOutput(r, vp);
949 }
950
951
952 uint8_t
rwrec_GetInitFlags(const rwRec * r)953 rwrec_GetInitFlags(
954 const rwRec *r)
955 {
956 return _recGetInitFlags(r);
957 }
958
959
960 void
rwrec_SetInitFlags(rwRec * r,uint8_t in_v)961 rwrec_SetInitFlags(
962 rwRec *r,
963 uint8_t in_v)
964 {
965 _recSetInitFlags(r, in_v);
966 }
967
968
969 void
rwrec_MemGetInitFlags(const rwRec * r,void * out_vp)970 rwrec_MemGetInitFlags(
971 const rwRec *r,
972 void *out_vp)
973 {
974 _recMemGetInitFlags(r, out_vp);
975 }
976
977
978 void
rwrec_MemSetInitFlags(rwRec * r,const void * in_vp)979 rwrec_MemSetInitFlags(
980 rwRec *r,
981 const void *in_vp)
982 {
983 _recMemSetInitFlags(r, in_vp);
984 }
985
986
987 int
rwrec_MemCmpInitFlags(const rwRec * r,const void * vp)988 rwrec_MemCmpInitFlags(
989 const rwRec *r,
990 const void *vp)
991 {
992 return _recMemCmpInitFlags(r, vp);
993 }
994
995
996 uint8_t
rwrec_GetRestFlags(const rwRec * r)997 rwrec_GetRestFlags(
998 const rwRec *r)
999 {
1000 return _recGetRestFlags(r);
1001 }
1002
1003
1004 void
rwrec_SetRestFlags(rwRec * r,uint8_t in_v)1005 rwrec_SetRestFlags(
1006 rwRec *r,
1007 uint8_t in_v)
1008 {
1009 _recSetRestFlags(r, in_v);
1010 }
1011
1012
1013 void
rwrec_MemGetRestFlags(const rwRec * r,void * out_vp)1014 rwrec_MemGetRestFlags(
1015 const rwRec *r,
1016 void *out_vp)
1017 {
1018 _recMemGetRestFlags(r, out_vp);
1019 }
1020
1021
1022 void
rwrec_MemSetRestFlags(rwRec * r,const void * in_vp)1023 rwrec_MemSetRestFlags(
1024 rwRec *r,
1025 const void *in_vp)
1026 {
1027 _recMemSetRestFlags(r, in_vp);
1028 }
1029
1030
1031 int
rwrec_MemCmpRestFlags(const rwRec * r,const void * vp)1032 rwrec_MemCmpRestFlags(
1033 const rwRec *r,
1034 const void *vp)
1035 {
1036 return _recMemCmpRestFlags(r, vp);
1037 }
1038
1039
1040 uint8_t
rwrec_GetTcpState(const rwRec * r)1041 rwrec_GetTcpState(
1042 const rwRec *r)
1043 {
1044 return _recGetTcpState(r);
1045 }
1046
1047
1048 void
rwrec_SetTcpState(rwRec * r,uint8_t in_v)1049 rwrec_SetTcpState(
1050 rwRec *r,
1051 uint8_t in_v)
1052 {
1053 _recSetTcpState(r, in_v);
1054 }
1055
1056
1057 void
rwrec_MemGetTcpState(const rwRec * r,void * out_vp)1058 rwrec_MemGetTcpState(
1059 const rwRec *r,
1060 void *out_vp)
1061 {
1062 _recMemGetTcpState(r, out_vp);
1063 }
1064
1065
1066 void
rwrec_MemSetTcpState(rwRec * r,const void * in_vp)1067 rwrec_MemSetTcpState(
1068 rwRec *r,
1069 const void *in_vp)
1070 {
1071 _recMemSetTcpState(r, in_vp);
1072 }
1073
1074
1075 int
rwrec_MemCmpTcpState(const rwRec * r,const void * vp)1076 rwrec_MemCmpTcpState(
1077 const rwRec *r,
1078 const void *vp)
1079 {
1080 return _recMemCmpTcpState(r, vp);
1081 }
1082
1083
1084 sk_flowtype_id_t
rwrec_GetFlowType(const rwRec * r)1085 rwrec_GetFlowType(
1086 const rwRec *r)
1087 {
1088 return _recGetFlowType(r);
1089 }
1090
1091
1092 void
rwrec_SetFlowType(rwRec * r,sk_flowtype_id_t in_v)1093 rwrec_SetFlowType(
1094 rwRec *r,
1095 sk_flowtype_id_t in_v)
1096 {
1097 _recSetFlowType(r, in_v);
1098 }
1099
1100
1101 void
rwrec_MemGetFlowType(const rwRec * r,void * out_vp)1102 rwrec_MemGetFlowType(
1103 const rwRec *r,
1104 void *out_vp)
1105 {
1106 _recMemGetFlowType(r, out_vp);
1107 }
1108
1109
1110 void
rwrec_MemSetFlowType(rwRec * r,const void * in_vp)1111 rwrec_MemSetFlowType(
1112 rwRec *r,
1113 const void *in_vp)
1114 {
1115 _recMemSetFlowType(r, in_vp);
1116 }
1117
1118
1119 int
rwrec_MemCmpFlowType(const rwRec * r,const void * vp)1120 rwrec_MemCmpFlowType(
1121 const rwRec *r,
1122 const void *vp)
1123 {
1124 return _recMemCmpFlowType(r, vp);
1125 }
1126
1127
1128 uint16_t
rwrec_GetApplication(const rwRec * r)1129 rwrec_GetApplication(
1130 const rwRec *r)
1131 {
1132 return _recGetApplication(r);
1133 }
1134
1135
1136 void
rwrec_SetApplication(rwRec * r,uint16_t in_v)1137 rwrec_SetApplication(
1138 rwRec *r,
1139 uint16_t in_v)
1140 {
1141 _recSetApplication(r, in_v);
1142 }
1143
1144
1145 void
rwrec_MemGetApplication(const rwRec * r,void * out_vp)1146 rwrec_MemGetApplication(
1147 const rwRec *r,
1148 void *out_vp)
1149 {
1150 _recMemGetApplication(r, out_vp);
1151 }
1152
1153
1154 void
rwrec_MemSetApplication(rwRec * r,const void * in_vp)1155 rwrec_MemSetApplication(
1156 rwRec *r,
1157 const void *in_vp)
1158 {
1159 _recMemSetApplication(r, in_vp);
1160 }
1161
1162
1163 int
rwrec_MemCmpApplication(const rwRec * r,const void * vp)1164 rwrec_MemCmpApplication(
1165 const rwRec *r,
1166 const void *vp)
1167 {
1168 return _recMemCmpApplication(r, vp);
1169 }
1170
1171
1172 uint16_t
rwrec_GetMemo(const rwRec * r)1173 rwrec_GetMemo(
1174 const rwRec *r)
1175 {
1176 return _recGetMemo(r);
1177 }
1178
1179
1180 void
rwrec_SetMemo(rwRec * r,uint16_t in_v)1181 rwrec_SetMemo(
1182 rwRec *r,
1183 uint16_t in_v)
1184 {
1185 _recSetMemo(r, in_v);
1186 }
1187
1188
1189 void
rwrec_MemGetMemo(const rwRec * r,void * out_vp)1190 rwrec_MemGetMemo(
1191 const rwRec *r,
1192 void *out_vp)
1193 {
1194 _recMemGetMemo(r, out_vp);
1195 }
1196
1197
1198 void
rwrec_MemSetMemo(rwRec * r,const void * in_vp)1199 rwrec_MemSetMemo(
1200 rwRec *r,
1201 const void *in_vp)
1202 {
1203 _recMemSetMemo(r, in_vp);
1204 }
1205
1206
1207 int
rwrec_MemCmpMemo(const rwRec * r,const void * vp)1208 rwrec_MemCmpMemo(
1209 const rwRec *r,
1210 const void *vp)
1211 {
1212 return _recMemCmpMemo(r, vp);
1213 }
1214
1215
1216 void
rwrec_MemGetSIP(const rwRec * r,skipaddr_t * out_vp)1217 rwrec_MemGetSIP(
1218 const rwRec *r,
1219 skipaddr_t *out_vp)
1220 {
1221 _recMemGetSIP(r, out_vp);
1222 }
1223
1224
1225 void
rwrec_MemSetSIP(rwRec * r,const skipaddr_t * in_vp)1226 rwrec_MemSetSIP(
1227 rwRec *r,
1228 const skipaddr_t *in_vp)
1229 {
1230 _recMemSetSIP(r, in_vp);
1231 }
1232
1233
1234 int
rwrec_MemCmpSIP(const rwRec * r,const skipaddr_t * cmp_addr)1235 rwrec_MemCmpSIP(
1236 const rwRec *r,
1237 const skipaddr_t *cmp_addr)
1238 {
1239 #if !SK_ENABLE_IPV6
1240 return _recMemCmpSIP(r, cmp_addr);
1241 #else
1242 return recCompareIPAddr(r, &(r->sIP), cmp_addr);
1243 #endif
1244 }
1245
1246
1247 void
rwrec_ApplyMaskSIP(rwRec * r,const skipaddr_t * mask_addr)1248 rwrec_ApplyMaskSIP(
1249 rwRec *r,
1250 const skipaddr_t *mask_addr)
1251 {
1252 #if !SK_ENABLE_IPV6
1253 _recApplyMaskSIP(r, mask_addr);
1254 #else
1255 recApplyMaskIPAddr(r, &(r->sIP), mask_addr);
1256 #endif
1257 }
1258
1259
1260 void
rwrec_MemGetDIP(const rwRec * r,skipaddr_t * out_vp)1261 rwrec_MemGetDIP(
1262 const rwRec *r,
1263 skipaddr_t *out_vp)
1264 {
1265 _recMemGetDIP(r, out_vp);
1266 }
1267
1268
1269 void
rwrec_MemSetDIP(rwRec * r,const skipaddr_t * in_vp)1270 rwrec_MemSetDIP(
1271 rwRec *r,
1272 const skipaddr_t *in_vp)
1273 {
1274 _recMemSetDIP(r, in_vp);
1275 }
1276
1277
1278 int
rwrec_MemCmpDIP(const rwRec * r,const skipaddr_t * cmp_addr)1279 rwrec_MemCmpDIP(
1280 const rwRec *r,
1281 const skipaddr_t *cmp_addr)
1282 {
1283 #if !SK_ENABLE_IPV6
1284 return _recMemCmpDIP(r, cmp_addr);
1285 #else
1286 return recCompareIPAddr(r, &(r->dIP), cmp_addr);
1287 #endif
1288 }
1289
1290
1291 void
rwrec_ApplyMaskDIP(rwRec * r,const skipaddr_t * mask_addr)1292 rwrec_ApplyMaskDIP(
1293 rwRec *r,
1294 const skipaddr_t *mask_addr)
1295 {
1296 #if !SK_ENABLE_IPV6
1297 _recApplyMaskDIP(r, mask_addr);
1298 #else
1299 recApplyMaskIPAddr(r, &(r->dIP), mask_addr);
1300 #endif
1301 }
1302
1303
1304 void
rwrec_MemGetNhIP(const rwRec * r,skipaddr_t * out_vp)1305 rwrec_MemGetNhIP(
1306 const rwRec *r,
1307 skipaddr_t *out_vp)
1308 {
1309 _recMemGetNhIP(r, out_vp);
1310 }
1311
1312
1313 void
rwrec_MemSetNhIP(rwRec * r,const skipaddr_t * in_vp)1314 rwrec_MemSetNhIP(
1315 rwRec *r,
1316 const skipaddr_t *in_vp)
1317 {
1318 _recMemSetNhIP(r, in_vp);
1319 }
1320
1321
1322 int
rwrec_MemCmpNhIP(const rwRec * r,const skipaddr_t * cmp_addr)1323 rwrec_MemCmpNhIP(
1324 const rwRec *r,
1325 const skipaddr_t *cmp_addr)
1326 {
1327 #if !SK_ENABLE_IPV6
1328 return _recMemCmpNhIP(r, cmp_addr);
1329 #else
1330 return recCompareIPAddr(r, &(r->nhIP), cmp_addr);
1331 #endif
1332 }
1333
1334
1335 void
rwrec_ApplyMaskNhIP(rwRec * r,const skipaddr_t * mask_addr)1336 rwrec_ApplyMaskNhIP(
1337 rwRec *r,
1338 const skipaddr_t *mask_addr)
1339 {
1340 #if !SK_ENABLE_IPV6
1341 _recApplyMaskNhIP(r, mask_addr);
1342 #else
1343 recApplyMaskIPAddr(r, &(r->nhIP), mask_addr);
1344 #endif
1345 }
1346
1347
1348 #if SK_ENABLE_IPV6
1349
1350 int
rwrec_IsIPv6(const rwRec * r)1351 rwrec_IsIPv6(
1352 const rwRec *r)
1353 {
1354 return _recIsIPv6(r);
1355 }
1356
1357
1358 void
rwrec_ConvertToIPv6(rwRec * r)1359 rwrec_ConvertToIPv6(
1360 rwRec *r)
1361 {
1362 _recConvertToIPv6(r);
1363 }
1364
1365
1366 int
rwrec_ConvertToIPv4(rwRec * r)1367 rwrec_ConvertToIPv4(
1368 rwRec *r)
1369 {
1370 uint32_t ipv4;
1371
1372 if (!SK_IPV6_IS_V4INV6(r->sIP.ipu_ipv6)
1373 || !SK_IPV6_IS_V4INV6(r->dIP.ipu_ipv6)
1374 || (!SK_IPV6_IS_V4INV6(r->nhIP.ipu_ipv6)
1375 && !SK_IPV6_IS_ZERO(r->nhIP.ipu_ipv6)))
1376 {
1377 return -1;
1378 }
1379
1380 memcpy(&ipv4, &(r->sIP.ipu_ipv6[12]), 4);
1381 r->sIP.ipu_ipv4 = ntohl(ipv4);
1382
1383 memcpy(&ipv4, &(r->dIP.ipu_ipv6[12]), 4);
1384 r->dIP.ipu_ipv4 = ntohl(ipv4);
1385
1386 memcpy(&ipv4, &(r->nhIP.ipu_ipv6[12]), 4);
1387 r->nhIP.ipu_ipv4 = ntohl(ipv4);
1388
1389 _recSetIPv4(r);
1390
1391 return 0;
1392 }
1393
1394
1395 void
rwrec_SetIPv4(rwRec * r)1396 rwrec_SetIPv4(
1397 rwRec *r)
1398 {
1399 _recSetIPv4(r);
1400 }
1401
1402
1403 void
rwrec_SetIPv6(rwRec * r)1404 rwrec_SetIPv6(
1405 rwRec *r)
1406 {
1407 _recSetIPv6(r);
1408 }
1409
1410
1411 void
rwrec_MemGetSIPv6(const rwRec * r,void * out_vp)1412 rwrec_MemGetSIPv6(
1413 const rwRec *r,
1414 void *out_vp)
1415 {
1416 _recMemGetSIPv6(r, out_vp);
1417 }
1418
1419
1420 void
rwrec_MemSetSIPv6(rwRec * r,const void * in_vp)1421 rwrec_MemSetSIPv6(
1422 rwRec *r,
1423 const void *in_vp)
1424 {
1425 _recMemSetSIPv6(r, in_vp);
1426 }
1427
1428
1429 int
rwrec_MemCmpSIPv6(const rwRec * r,const void * vp)1430 rwrec_MemCmpSIPv6(
1431 const rwRec *r,
1432 const void *vp)
1433 {
1434 return _recMemCmpSIPv6(r, vp);
1435 }
1436
1437
1438 void
rwrec_ApplyMaskSIPv6(rwRec * r,const void * mask_vp)1439 rwrec_ApplyMaskSIPv6(
1440 rwRec *r,
1441 const void *mask_vp)
1442 {
1443 _recApplyMaskSIPv6(r, mask_vp);
1444 }
1445
1446
1447 void
rwrec_MemGetDIPv6(const rwRec * r,void * out_vp)1448 rwrec_MemGetDIPv6(
1449 const rwRec *r,
1450 void *out_vp)
1451 {
1452 _recMemGetDIPv6(r, out_vp);
1453 }
1454
1455
1456 void
rwrec_MemSetDIPv6(rwRec * r,const void * in_vp)1457 rwrec_MemSetDIPv6(
1458 rwRec *r,
1459 const void *in_vp)
1460 {
1461 _recMemSetDIPv6(r, in_vp);
1462 }
1463
1464
1465 int
rwrec_MemCmpDIPv6(const rwRec * r,const void * vp)1466 rwrec_MemCmpDIPv6(
1467 const rwRec *r,
1468 const void *vp)
1469 {
1470 return _recMemCmpDIPv6(r, vp);
1471 }
1472
1473
1474 void
rwrec_ApplyMaskDIPv6(rwRec * r,const void * mask_vp)1475 rwrec_ApplyMaskDIPv6(
1476 rwRec *r,
1477 const void *mask_vp)
1478 {
1479 _recApplyMaskDIPv6(r, mask_vp);
1480 }
1481
1482
1483 void
rwrec_MemGetNhIPv6(const rwRec * r,void * out_vp)1484 rwrec_MemGetNhIPv6(
1485 const rwRec *r,
1486 void *out_vp)
1487 {
1488 _recMemGetNhIPv6(r, out_vp);
1489 }
1490
1491
1492 void
rwrec_MemSetNhIPv6(rwRec * r,const void * in_vp)1493 rwrec_MemSetNhIPv6(
1494 rwRec *r,
1495 const void *in_vp)
1496 {
1497 _recMemSetNhIPv6(r, in_vp);
1498 }
1499
1500
1501 int
rwrec_MemCmpNhIPv6(const rwRec * r,const void * vp)1502 rwrec_MemCmpNhIPv6(
1503 const rwRec *r,
1504 const void *vp)
1505 {
1506 return _recMemCmpNhIPv6(r, vp);
1507 }
1508
1509
1510 void
rwrec_ApplyMaskNhIPv6(rwRec * r,const void * mask_vp)1511 rwrec_ApplyMaskNhIPv6(
1512 rwRec *r,
1513 const void *mask_vp)
1514 {
1515 _recApplyMaskNhIPv6(r, mask_vp);
1516 }
1517
1518
1519 #endif /* SK_ENABLE_IPV6 */
1520
1521
1522
1523 /*
1524 ** Local Variables:
1525 ** mode:c
1526 ** indent-tabs-mode:nil
1527 ** c-basic-offset:4
1528 ** End:
1529 */
1530