/* Kernel module to match one of a list of Source IP addresses: IP addresses are in the same place so we can treat them as equal */ #include #include #include #include #include #include #include #if 0 #define duprintf(format, args...) printk(format , ## args) #else #define duprintf(format, args...) #endif /* Returns 1 if the port is matched by the test, 0 otherwise. */ static inline int msip_match(const u_int32_t *iplist, u_int8_t count, u_int8_t flags, u_int32_t src) { /* JAH_TODO...Eventually need to optimize the search here */ unsigned int i; u_int32_t tmp_ip; for (i=0; inh.iph; const struct ipt_multiip *multiinfo = matchinfo; return (msip_match(multiinfo->multip, multiinfo->count, multiinfo->flags, ntohl(iph->saddr))); } /*---------------------------------------------------------*/ /* checkentry function */ /* */ /* Called when user tries to insert an entry of this type. */ /*---------------------------------------------------------*/ static int checkentry(const char *tablename, const struct ipt_ip *ip, void *matchinfo, unsigned int matchsize, unsigned int hook_mask) { /* verify size */ if (matchsize != IPT_ALIGN(sizeof(struct ipt_multiip))) return 0; return 1; } static struct ipt_match multiip_match = { { NULL, NULL }, "mip", &match, &checkentry, NULL, THIS_MODULE }; static int __init init(void) { return ipt_register_match(&multiip_match); } static void __exit fini(void) { ipt_unregister_match(&multiip_match); } module_init(init); module_exit(fini); MODULE_LICENSE("GPL");