1 #include "cll1-0.6.2.h"
3 /* ====== iptables indexes are used to reduce complexity to log(N) ===== */
5 char *very_ugly_ipv4_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
<=32)
15 string(outip
,strlen(ip
)+10); /* assertion: 10>strlen("_%d_%d") */
19 /* should never exit here */
29 if(format_as_chainname
)
42 char *cutdot
=strchr(ip
+1,'.'); /*for bitmask<24*/
48 if(format_as_chainname
)
59 n
= atoi(ip
+1)-atoi(ip
+1)%(1<<(8-bitmask
%8));
66 /*debug printf("%d/%d => [_%d_%d]\n",atoi(ip+1),bitmask,n,bitmask); */
67 sprintf(outptr
,fmt
,n
,bitmask
);
68 if(!format_as_chainname
)
76 /* debug printf("[%s]\n",outip); */
87 /*should never exit here*/
92 char *index_id(char *ip
, int bitmask
)
94 return very_ugly_ipv4_code(ip
,bitmask
,1);
97 char *subnet_id(char *ip
, int bitmask
)
99 return very_ugly_ipv4_code(ip
,bitmask
,0);
This page took 0.320104 seconds and 4 git commands to generate.