1 #include "cll1-0.6.2.h"
3 /* ====== iptables indexes are used to reduce complexity to log(N) ===== */
5 char *very_ugly_ipv6_code(char *inip
, int bitmask
, int format_as_chainname
)
8 char *ip
,*outip
,*outptr
,*fmt
;
11 /* debug printf("(%s,%d) -> ",ip,bitmask); */
13 if(ip
&& *ip
&& bitmask
>=0 && bitmask
<=64)
15 string(outip
,strlen(ip
)+10); /* assertion: 10>strlen("_%d_%d") */
19 /* should never exit here */
27 if(colon
<(bitmask
/16-1))
29 if(format_as_chainname
)
42 char *cutcolon
=strchr(ip
+1,':');
48 if(format_as_chainname
)
59 sscanf(ip
+1, "%x", &h
);
60 /* printf("[debug - %s scanned hexa as %x]\n",ip+1,h);*/
61 n
= h
-h
%(1<<(16-bitmask
%16));
68 /* printf("%d/%d => [_%d_%d]\n",h,bitmask,n,bitmask); */
69 sprintf(outptr
,fmt
,n
,bitmask
);
70 if(!format_as_chainname
)
72 strcat(outip
,"::"); /* ahem :-) */
74 /* debug printf("[%s]\n",outip); */
85 /*should never exit here*/
90 char *index6_id(char *ip
,int bitmask
)
92 return very_ugly_ipv6_code(ip
,bitmask
,1);
95 char *subnet6_id(char *ip
,int bitmask
)
97 return very_ugly_ipv6_code(ip
,bitmask
,0);
This page took 0.442665 seconds and 4 git commands to generate.