Hi I am pretty much desperate at this moment with the problem. I don't understand why I am kept getting "invalid argument" from commit. I am using 1.4.7 and the kernel is 2.6.33. Can someone please point me to the right direction? How can I debug this issue? Thanks, p On Sat, Jul 10, 2010 at 11:15 PM, Pete Kay <petedao@xxxxxxxxx> wrote: > Hi, > > I have written a very simple program to add iptables rule, but I am > kept getting " Too many levels of symbolic links" . > > Does anyone know what is wrong? > > > int ret = 0; > iptc_handle_t h = iptc_init("nat"); > > struct ipt_entry_match *match; > struct ipt_udp *match_udp; > struct ipt_entry_target *target; > char callee_inhibitor_buf[IPTC_FULL_SIZE]; > struct ipt_entry *entry = (struct ipt_entry *) callee_inhibitor_buf; > > > memset(entry, 0, IPTC_FULL_SIZE); > entry->ip.proto = IPPROTO_UDP; > entry->ip.src.s_addr = inet_addr("192.168.3.2"); > > memset(&entry->ip.smsk, 255, sizeof(struct in_addr)); > entry ->ip.smsk.s_addr = 0xffffffff; > entry->ip.dst.s_addr = inet_addr("200.168.3.3"); > entry ->ip.dmsk.s_addr = 0xffffffff; > entry->target_offset = IPTC_ENTRY_SIZE + IPTC_MATCH_SIZE; > entry->next_offset = IPTC_FULL_SIZE; > match = (struct ipt_entry_match *) entry->elems; > // match = (struct ipt_entry_match *)entry->elems; > match->u.user.match_size = IPTC_MATCH_SIZE; > strcpy(match->u.user.name, "udp"); > match_udp = (struct ipt_udp*) &match->data; > match_udp->spts[0] = 5060;match_udp->spts[1] = 5060; > match_udp->dpts[0] = 5070;match_udp->dpts[1] = 5070; > target = (struct ipt_entry_target*) (match + IPTC_MATCH_SIZE); > > target->u.user.target_size = IPTC_TARGET_SIZE; > strcpy(target->u.user.name, "ACCEPT"); > ret = iptc_append_entry ("PREROUTING", entry, h); > if (!ret) { > printf("append : %s\n", iptc_strerror(errno)); > } > ret =iptc_commit(h); > printf("commit =[%i]\n", ret); > if (!ret) { > printf("commit: %s\n", iptc_strerror(errno)); > } > -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html