--- /dev/null
+#include "cll1-0.6.2.h"\r
+\r
+/* ====== iptables indexes are used to reduce complexity to log8(N) ===== */\r
+\r
+char *very_ugly_ipv4_code(char *inip, int bitmask, int format_as_chainname)\r
+{\r
+ /* warning: this function was debugged only for bitmask values 20,24,28 !!!*/\r
+ int dot=0, n;\r
+ char *ip,*outip,*outptr,*fmt;\r
+\r
+ duplicate(inip,ip);\r
+ /* debug printf("(%s,%d) -> ",ip,bitmask); */\r
+\r
+ if(ip && *ip && bitmask>=0 && bitmask<=32)\r
+ {\r
+ string(outip,strlen(ip)+10); /*fuck unicode? assertion: 10>strlen("_%d_%d") */\r
+ }\r
+ else \r
+ {\r
+ /* should never exit here */\r
+ return "undefined";\r
+ }\r
+ outptr=outip;\r
+ while(ip && *ip)\r
+ {\r
+ if(*ip=='.')\r
+ {\r
+ if(dot<(bitmask/8-1)) \r
+ {\r
+ if(format_as_chainname)\r
+ {\r
+ *outptr='_';\r
+ }\r
+ else\r
+ {\r
+ *outptr='.';\r
+ }\r
+ outptr++;\r
+ dot++;\r
+ }\r
+ else\r
+ {\r
+ char *cutdot=strchr(ip+1,'.'); /*for bitmask<24*/ \r
+ if(cutdot)\r
+ {\r
+ *cutdot = '\0';\r
+ }\r
+ \r
+ if(format_as_chainname)\r
+ {\r
+ fmt = "_%d_%d";\r
+ }\r
+ else\r
+ {\r
+ fmt = ".%d";\r
+ }\r
+ \r
+ if(bitmask%8)\r
+ {\r
+ n = atoi(ip+1)-atoi(ip+1)%(1<<(8-bitmask%8));\r
+ }\r
+ else\r
+ {\r
+ n = 0;\r
+ }\r
+\r
+ /*debug printf("%d/%d => [_%d_%d]\n",atoi(ip+1),bitmask,n,bitmask); */\r
+ sprintf(outptr,fmt,n,bitmask);\r
+ if(!format_as_chainname)\r
+ {\r
+ while(bitmask<24)\r
+ {\r
+ strcat(outip,".0");\r
+ bitmask+=8;\r
+ }\r
+ }\r
+ /* debug printf("[%s]\n",outip); */\r
+ return outip;\r
+ }\r
+ }\r
+ else \r
+ {\r
+ *outptr=*ip;\r
+ outptr++;\r
+ }\r
+ ip++;\r
+ }\r
+ /*should never exit here*/\r
+ *outptr='\0';\r
+ return outip;\r
+}\r
+\r
+char *index_id(char *ip,int bitmask)\r
+{ \r
+ return very_ugly_ipv4_code(ip,bitmask,1);\r
+}\r
+\r
+char *subnet_id(char *ip,int bitmask)\r
+{\r
+ return very_ugly_ipv4_code(ip,bitmask,0);\r
+}\r
list(Index);\r
} *idxs=NULL, *idx, *metaindex;\r
\r
-\r
void TheIP(void);\r
/* function implemented in parsehosts.c */\r
\r
/* ====== iptables indexes are used to reduce complexity to log8(N) ===== */\r
\r
-char *very_ugly_ipv4_code(char *inip, int bitmask, int format_as_chainname)\r
-{\r
- /* warning: this function was debugged only for bitmask values 20,24,28 !!!*/\r
- int dot=0, n;\r
- char *ip,*outip,*outptr,*fmt;\r
-\r
- duplicate(inip,ip);\r
- /* debug printf("(%s,%d) -> ",ip,bitmask); */\r
+char *index_id(char *ip, int bitmask);\r
+/* function implemented in ipv4subnets.c */\r
\r
- if(ip && *ip && bitmask>=0 && bitmask<=32)\r
- {\r
- string(outip,strlen(ip)+10); /*fuck unicode? assertion: 10>strlen("_%d_%d") */\r
- }\r
- else \r
- {\r
- /* should never exit here */\r
- return "undefined";\r
- }\r
- outptr=outip;\r
- while(ip && *ip)\r
- {\r
- if(*ip=='.')\r
- {\r
- if(dot<(bitmask/8-1)) \r
- {\r
- if(format_as_chainname)\r
- {\r
- *outptr='_';\r
- }\r
- else\r
- {\r
- *outptr='.';\r
- }\r
- outptr++;\r
- dot++;\r
- }\r
- else\r
- {\r
- char *cutdot=strchr(ip+1,'.'); /*for bitmask<24*/ \r
- if(cutdot)\r
- {\r
- *cutdot = '\0';\r
- }\r
- \r
- if(format_as_chainname)\r
- {\r
- fmt = "_%d_%d";\r
- }\r
- else\r
- {\r
- fmt = ".%d";\r
- }\r
- \r
- if(bitmask%8)\r
- {\r
- n = atoi(ip+1)-atoi(ip+1)%(1<<(8-bitmask%8));\r
- }\r
- else\r
- {\r
- n = 0;\r
- }\r
-\r
- /*debug printf("%d/%d => [_%d_%d]\n",atoi(ip+1),bitmask,n,bitmask); */\r
- sprintf(outptr,fmt,n,bitmask);\r
- if(!format_as_chainname)\r
- {\r
- while(bitmask<24)\r
- {\r
- strcat(outip,".0");\r
- bitmask+=8;\r
- }\r
- }\r
- /* debug printf("[%s]\n",outip); */\r
- return outip;\r
- }\r
- }\r
- else \r
- {\r
- *outptr=*ip;\r
- outptr++;\r
- }\r
- ip++;\r
- }\r
- /*should never exit here*/\r
- *outptr='\0';\r
- return outip;\r
-}\r
-\r
-char *index_id(char *ip,int bitmask)\r
-{ \r
- return very_ugly_ipv4_code(ip,bitmask,1);\r
-}\r
-\r
-char *subnet_id(char *ip,int bitmask)\r
-{\r
- return very_ugly_ipv4_code(ip,bitmask,0);\r
-}\r
+char *subnet_id(char *ip, int bitmask);\r
+/* function implemented in ipv4subnets.c */\r
\r
-/* ================= Let's parse configuration file here =================== */\r
+/* ================= Let's parse configuration file here ================ */\r
\r
void reject_config_and_exit(char *filename)\r
{\r