29
29
#include "nat46-core.h"
30
30
#include "nat46-module.h"
31
31
32
- void
32
+ static void
33
33
nat46debug_dump (nat46_instance_t * nat46 , int level , void * addr , int len )
34
34
{
35
35
char tohex [] = "0123456789ABCDEF" ;
@@ -118,7 +118,7 @@ char *get_next_arg(char **ptail) {
118
118
* Parse an IPv6 address (if pref_len is NULL), or prefix (if it isn't).
119
119
* parses destructively (places \0 between address and prefix len)
120
120
*/
121
- int try_parse_ipv6_prefix (struct in6_addr * pref , int * pref_len , char * arg ) {
121
+ static int try_parse_ipv6_prefix (struct in6_addr * pref , int * pref_len , char * arg ) {
122
122
int err = 0 ;
123
123
char * arg_plen = strchr (arg , '/' );
124
124
if (arg_plen ) {
@@ -131,7 +131,7 @@ int try_parse_ipv6_prefix(struct in6_addr *pref, int *pref_len, char *arg) {
131
131
return err ;
132
132
}
133
133
134
- int try_parse_ipv4_prefix (u32 * v4addr , int * pref_len , char * arg ) {
134
+ static int try_parse_ipv4_prefix (u32 * v4addr , int * pref_len , char * arg ) {
135
135
int err = 0 ;
136
136
char * arg_plen = strchr (arg , '/' );
137
137
if (arg_plen ) {
@@ -151,7 +151,7 @@ int try_parse_ipv4_prefix(u32 *v4addr, int *pref_len, char *arg) {
151
151
* destructive.
152
152
*/
153
153
154
- int try_parse_rule_arg (nat46_xlate_rule_t * rule , char * arg_name , char * * ptail ) {
154
+ static int try_parse_rule_arg (nat46_xlate_rule_t * rule , char * arg_name , char * * ptail ) {
155
155
int err = 0 ;
156
156
char * val = get_next_arg (ptail );
157
157
if (NULL == val ) {
@@ -225,7 +225,7 @@ int nat46_set_config(nat46_instance_t *nat46, char *buf, int count) {
225
225
return ret ;
226
226
}
227
227
228
- char * xlate_style_to_string (nat46_xlate_style_t style ) {
228
+ static char * xlate_style_to_string (nat46_xlate_style_t style ) {
229
229
switch (style ) {
230
230
case NAT46_XLATE_NONE :
231
231
return "NONE" ;
@@ -372,7 +372,7 @@ From RFC6052, section 2.2:
372
372
373
373
********************************************************************/
374
374
375
- void xlate_v4_to_nat64 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 ) {
375
+ static void xlate_v4_to_nat64 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 ) {
376
376
char * ipv4 = pipv4 ;
377
377
char * ipv6 = pipv6 ;
378
378
@@ -413,7 +413,7 @@ void xlate_v4_to_nat64(nat46_instance_t *nat46, nat46_xlate_rule_t *rule, void *
413
413
}
414
414
}
415
415
416
- int xlate_nat64_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 ) {
416
+ static int xlate_nat64_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 ) {
417
417
char * ipv4 = pipv4 ;
418
418
char * ipv6 = pipv6 ;
419
419
int cmp = -1 ;
@@ -597,7 +597,7 @@ bitarray_copy(const void *src_org, int src_offset, int src_len,
597
597
}
598
598
}
599
599
600
- int xlate_map_v4_to_v6 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 , uint16_t * pl4id , int map_version ) {
600
+ static int xlate_map_v4_to_v6 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 , uint16_t * pl4id , int map_version ) {
601
601
int ret = 0 ;
602
602
u32 * pv4u32 = pipv4 ;
603
603
uint8_t * p6 = pipv6 ;
@@ -699,7 +699,7 @@ int xlate_map_v4_to_v6(nat46_instance_t *nat46, nat46_xlate_rule_t *rule, void *
699
699
return ret ;
700
700
}
701
701
702
- int xlate_map_v6_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 , int version ) {
702
+ static int xlate_map_v6_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 , int version ) {
703
703
uint8_t v4_lsb_bits_len = 32 - rule -> v4_pref_len ;
704
704
705
705
if (memcmp (pipv6 , & rule -> v6_pref , rule -> v6_pref_len /8 )) {
@@ -734,7 +734,7 @@ int xlate_map_v6_to_v4(nat46_instance_t *nat46, nat46_xlate_rule_t *rule, void *
734
734
return 1 ;
735
735
}
736
736
737
- int xlate_v4_to_v6 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 , uint16_t * pl4id ) {
737
+ static int xlate_v4_to_v6 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv4 , void * pipv6 , uint16_t * pl4id ) {
738
738
int ret = 0 ;
739
739
switch (rule -> style ) {
740
740
case NAT46_XLATE_NONE : /* always fail unless it is a host 1:1 translation */
@@ -759,7 +759,7 @@ int xlate_v4_to_v6(nat46_instance_t *nat46, nat46_xlate_rule_t *rule, void *pipv
759
759
return ret ;
760
760
}
761
761
762
- int xlate_v6_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 ) {
762
+ static int xlate_v6_to_v4 (nat46_instance_t * nat46 , nat46_xlate_rule_t * rule , void * pipv6 , void * pipv4 ) {
763
763
int ret = 0 ;
764
764
switch (rule -> style ) {
765
765
case NAT46_XLATE_NONE : /* always fail unless it is a host 1:1 translation */
@@ -782,7 +782,7 @@ int xlate_v6_to_v4(nat46_instance_t *nat46, nat46_xlate_rule_t *rule, void *pipv
782
782
return ret ;
783
783
}
784
784
785
- __sum16 csum16_upd (__sum16 csum , u16 old , u16 new ) {
785
+ static __sum16 csum16_upd (__sum16 csum , u16 old , u16 new ) {
786
786
u32 s ;
787
787
csum = ntohs (~csum );
788
788
s = (u32 )csum + ntohs (~old ) + ntohs (new );
@@ -793,7 +793,7 @@ __sum16 csum16_upd(__sum16 csum, u16 old, u16 new) {
793
793
794
794
/* Add the TCP/UDP pseudoheader, basing on the existing checksum */
795
795
796
- __sum16 csum_tcpudp_remagic (__be32 saddr , __be32 daddr , u32 len ,
796
+ static __sum16 csum_tcpudp_remagic (__be32 saddr , __be32 daddr , u32 len ,
797
797
unsigned char proto , u16 csum ) {
798
798
u16 * pdata ;
799
799
u16 len0 , len1 ;
@@ -814,7 +814,7 @@ __sum16 csum_tcpudp_remagic(__be32 saddr, __be32 daddr, u32 len,
814
814
}
815
815
816
816
/* Undo the IPv6 pseudoheader inclusion into the checksum */
817
- __sum16 csum_ipv6_unmagic (nat46_instance_t * nat46 , const struct in6_addr * saddr ,
817
+ static __sum16 csum_ipv6_unmagic (nat46_instance_t * nat46 , const struct in6_addr * saddr ,
818
818
const struct in6_addr * daddr ,
819
819
__u32 len , unsigned short proto ,
820
820
__sum16 csum ) {
@@ -841,7 +841,7 @@ __sum16 csum_ipv6_unmagic(nat46_instance_t *nat46, const struct in6_addr *saddr,
841
841
}
842
842
843
843
/* Update ICMPv6 type/code with incremental checksum adjustment */
844
- void update_icmp6_type_code (nat46_instance_t * nat46 , struct icmp6hdr * icmp6h , u8 type , u8 code ) {
844
+ static void update_icmp6_type_code (nat46_instance_t * nat46 , struct icmp6hdr * icmp6h , u8 type , u8 code ) {
845
845
u16 old_tc = * ((u16 * )icmp6h );
846
846
u16 new_tc ;
847
847
u16 old_csum = icmp6h -> icmp6_cksum ;
@@ -856,22 +856,22 @@ void update_icmp6_type_code(nat46_instance_t *nat46, struct icmp6hdr *icmp6h, u8
856
856
}
857
857
858
858
859
- u16 get_next_ip_id (void ) {
859
+ static u16 get_next_ip_id (void ) {
860
860
static u16 id = 0 ;
861
861
return id ++ ;
862
862
}
863
863
864
- u16 fold_ipv6_frag_id (u32 v6id ) {
864
+ static u16 fold_ipv6_frag_id (u32 v6id ) {
865
865
return ((0xffff & (v6id >> 16 )) ^ (v6id & 0xffff ));
866
866
}
867
867
868
- void * add_offset (void * ptr , u16 offset ) {
868
+ static void * add_offset (void * ptr , u16 offset ) {
869
869
return (((char * )ptr )+ offset );
870
870
}
871
871
872
872
873
873
/* FIXME: traverse the headers properly */
874
- void * get_next_header_ptr6 (void * pv6 , int v6_len ) {
874
+ static void * get_next_header_ptr6 (void * pv6 , int v6_len ) {
875
875
struct ipv6hdr * ip6h = pv6 ;
876
876
void * ret = (ip6h + 1 );
877
877
@@ -885,7 +885,7 @@ void *get_next_header_ptr6(void *pv6, int v6_len) {
885
885
return ret ;
886
886
}
887
887
888
- void fill_v4hdr_from_v6hdr (struct iphdr * iph , struct ipv6hdr * ip6h , __u32 v4saddr , __u32 v4daddr , __u16 id , __u16 frag_off , __u16 proto , int l3_payload_len ) {
888
+ static void fill_v4hdr_from_v6hdr (struct iphdr * iph , struct ipv6hdr * ip6h , __u32 v4saddr , __u32 v4daddr , __u16 id , __u16 frag_off , __u16 proto , int l3_payload_len ) {
889
889
iph -> ttl = ip6h -> hop_limit ;
890
890
iph -> saddr = v4saddr ;
891
891
iph -> daddr = v4daddr ;
@@ -898,7 +898,7 @@ void fill_v4hdr_from_v6hdr(struct iphdr * iph, struct ipv6hdr *ip6h, __u32 v4sad
898
898
iph -> check = ip_fast_csum ((unsigned char * )iph , iph -> ihl );
899
899
}
900
900
901
- u16 unchecksum16 (void * p , int count , u16 csum ) {
901
+ static u16 unchecksum16 (void * p , int count , u16 csum ) {
902
902
u16 * pu16 = p ;
903
903
int i = count ;
904
904
while (i -- ) {
@@ -907,7 +907,7 @@ u16 unchecksum16(void *p, int count, u16 csum) {
907
907
return csum ;
908
908
}
909
909
910
- u16 rechecksum16 (void * p , int count , u16 csum ) {
910
+ static u16 rechecksum16 (void * p , int count , u16 csum ) {
911
911
u16 * pu16 = p ;
912
912
int i = count ;
913
913
while (i -- ) {
@@ -917,11 +917,11 @@ u16 rechecksum16(void *p, int count, u16 csum) {
917
917
}
918
918
919
919
/* Last rule in group must not have "none" as either source or destination */
920
- int is_last_pair_in_group (nat46_xlate_rulepair_t * apair ) {
920
+ static int is_last_pair_in_group (nat46_xlate_rulepair_t * apair ) {
921
921
return ( (apair -> local .style != NAT46_XLATE_NONE ) && (apair -> remote .style != NAT46_XLATE_NONE ) );
922
922
}
923
923
924
- void pairs_xlate_v6_to_v4_inner (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , __u32 * pv4saddr , __u32 * pv4daddr ) {
924
+ static void pairs_xlate_v6_to_v4_inner (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , __u32 * pv4saddr , __u32 * pv4daddr ) {
925
925
int ipair = 0 ;
926
926
nat46_xlate_rulepair_t * apair = NULL ;
927
927
int xlate_src = -1 ;
@@ -959,7 +959,7 @@ void pairs_xlate_v6_to_v4_inner(nat46_instance_t *nat46, struct ipv6hdr *ip6h, _
959
959
* Translate this header and attempt to extract the sport/dport
960
960
* so the callers can use them for translation as well.
961
961
*/
962
- int xlate_payload6_to4 (nat46_instance_t * nat46 , void * pv6 , void * ptrans_hdr , int v6_len , u16 * ul_sum , int * ptailTruncSize ) {
962
+ static int xlate_payload6_to4 (nat46_instance_t * nat46 , void * pv6 , void * ptrans_hdr , int v6_len , u16 * ul_sum , int * ptailTruncSize ) {
963
963
struct ipv6hdr * ip6h = pv6 ;
964
964
__u32 v4saddr , v4daddr ;
965
965
struct iphdr new_ipv4 ;
@@ -1049,12 +1049,12 @@ int xlate_payload6_to4(nat46_instance_t *nat46, void *pv6, void *ptrans_hdr, int
1049
1049
return (v6_len - IPV6V4HDRDELTA );
1050
1050
}
1051
1051
1052
- u8 * icmp_parameter_ptr (struct icmphdr * icmph ) {
1052
+ static u8 * icmp_parameter_ptr (struct icmphdr * icmph ) {
1053
1053
u8 * icmp_pptr = ((u8 * )(icmph ))+ 4 ;
1054
1054
return icmp_pptr ;
1055
1055
}
1056
1056
1057
- u32 * icmp6_parameter_ptr (struct icmp6hdr * icmp6h ) {
1057
+ static u32 * icmp6_parameter_ptr (struct icmp6hdr * icmp6h ) {
1058
1058
u32 * icmp6_pptr = ((u32 * )(icmp6h ))+ 1 ;
1059
1059
return icmp6_pptr ;
1060
1060
}
@@ -1282,7 +1282,7 @@ static void nat46_fixup_icmp6(nat46_instance_t *nat46, struct ipv6hdr *ip6h, str
1282
1282
}
1283
1283
1284
1284
1285
- int ip6_input_not_interested (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , struct sk_buff * old_skb ) {
1285
+ static int ip6_input_not_interested (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , struct sk_buff * old_skb ) {
1286
1286
if (old_skb -> protocol != htons (ETH_P_IPV6 )) {
1287
1287
nat46debug (3 , "Not an IPv6 packet" );
1288
1288
return 1 ;
@@ -1533,7 +1533,7 @@ static uint16_t nat46_fixup_icmp(nat46_instance_t *nat46, struct iphdr *iph, str
1533
1533
return ret ;
1534
1534
}
1535
1535
1536
- int pairs_xlate_v6_to_v4_outer (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , uint16_t proto , __u32 * pv4saddr , __u32 * pv4daddr ) {
1536
+ static int pairs_xlate_v6_to_v4_outer (nat46_instance_t * nat46 , struct ipv6hdr * ip6h , uint16_t proto , __u32 * pv4saddr , __u32 * pv4daddr ) {
1537
1537
int ipair = 0 ;
1538
1538
nat46_xlate_rulepair_t * apair = NULL ;
1539
1539
int xlate_src = -1 ;
@@ -1743,7 +1743,7 @@ int nat46_ipv6_input(struct sk_buff *old_skb) {
1743
1743
1744
1744
1745
1745
1746
- void ip6_update_csum (struct sk_buff * skb , struct ipv6hdr * ip6hdr , int do_atomic_frag )
1746
+ static void ip6_update_csum (struct sk_buff * skb , struct ipv6hdr * ip6hdr , int do_atomic_frag )
1747
1747
{
1748
1748
u32 sum1 = 0 ;
1749
1749
u16 sum2 = 0 ;
@@ -1767,8 +1767,8 @@ void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomi
1767
1767
unsigned udplen = ntohs (ip6hdr -> payload_len ) - (do_atomic_frag ?8 :0 ); /* UDP hdr + payload */
1768
1768
1769
1769
if ((udp -> check == 0 ) && zero_csum_pass ) {
1770
- /* zero checksum and the config to pass it is set - do nothing with it */
1771
- break ;
1770
+ /* zero checksum and the config to pass it is set - do nothing with it */
1771
+ break ;
1772
1772
}
1773
1773
1774
1774
oldsum = udp -> check ;
@@ -1797,7 +1797,7 @@ void ip6_update_csum(struct sk_buff * skb, struct ipv6hdr * ip6hdr, int do_atomi
1797
1797
}
1798
1798
}
1799
1799
1800
- int ip4_input_not_interested (nat46_instance_t * nat46 , struct iphdr * iph , struct sk_buff * old_skb ) {
1800
+ static int ip4_input_not_interested (nat46_instance_t * nat46 , struct iphdr * iph , struct sk_buff * old_skb ) {
1801
1801
if (old_skb -> protocol != htons (ETH_P_IP )) {
1802
1802
nat46debug (3 , "Not an IPv4 packet" );
1803
1803
return 1 ;
@@ -1806,7 +1806,7 @@ int ip4_input_not_interested(nat46_instance_t *nat46, struct iphdr *iph, struct
1806
1806
return 0 ;
1807
1807
}
1808
1808
1809
- int pairs_xlate_v4_to_v6_outer (nat46_instance_t * nat46 , struct iphdr * hdr4 , uint16_t * sport , uint16_t * dport , void * v6saddr , void * v6daddr ) {
1809
+ static int pairs_xlate_v4_to_v6_outer (nat46_instance_t * nat46 , struct iphdr * hdr4 , uint16_t * sport , uint16_t * dport , void * v6saddr , void * v6daddr ) {
1810
1810
int ipair = 0 ;
1811
1811
nat46_xlate_rulepair_t * apair = NULL ;
1812
1812
int xlate_src = -1 ;
0 commit comments