0b40229dc73ad26e7bcf1ad9c4f8de3d390139ae
1 #include "cll1-0.6.2.h"
3 /* ====== iptables indexes are used to reduce complexity to log8(N) ===== */
5 char *very_ugly_ipv4_code(char *inip
, int bitmask
, int format_as_chainname
)
7 /* warning: this function was debugged only for bitmask values 20,24,28 !!!*/
9 char *ip
,*outip
,*outptr
,*fmt
;
12 /* debug printf("(%s,%d) -> ",ip,bitmask); */
14 if(ip
&& *ip
&& bitmask
>=0 && bitmask
<=32)
16 string(outip
,strlen(ip
)+10); /*fuck unicode? assertion: 10>strlen("_%d_%d") */
20 /* should never exit here */
30 if(format_as_chainname
)
43 char *cutdot
=strchr(ip
+1,'.'); /*for bitmask<24*/
49 if(format_as_chainname
)
60 n
= atoi(ip
+1)-atoi(ip
+1)%(1<<(8-bitmask
%8));
67 /*debug printf("%d/%d => [_%d_%d]\n",atoi(ip+1),bitmask,n,bitmask); */
68 sprintf(outptr
,fmt
,n
,bitmask
);
69 if(!format_as_chainname
)
77 /* debug printf("[%s]\n",outip); */
88 /*should never exit here*/
93 char *index_id(char *ip
,int bitmask
)
95 return very_ugly_ipv4_code(ip
,bitmask
,1);
98 char *subnet_id(char *ip
,int bitmask
)
100 return very_ugly_ipv4_code(ip
,bitmask
,0);
This page took 0.294023 seconds and 3 git commands to generate.