SOURCES: ipac-ng-update.patch (NEW) - updated from iptables cvs

arekm arekm at pld-linux.org
Sat Dec 24 20:57:27 CET 2005


Author: arekm                        Date: Sat Dec 24 19:57:26 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- updated from iptables cvs

---- Files affected:
SOURCES:
   ipac-ng-update.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/ipac-ng-update.patch
diff -u /dev/null SOURCES/ipac-ng-update.patch:1.1
--- /dev/null	Sat Dec 24 20:57:26 2005
+++ SOURCES/ipac-ng-update.patch	Sat Dec 24 20:57:21 2005
@@ -0,0 +1,4102 @@
+diff -urN ipac-ng-1.31.org/agents/iptables/iptables.c ipac-ng-1.31/agents/iptables/iptables.c
+--- ipac-ng-1.31.org/agents/iptables/iptables.c	2004-06-28 00:08:54.000000000 +0200
++++ ipac-ng-1.31/agents/iptables/iptables.c	2005-12-24 22:43:25.940963000 +0100
+@@ -1221,12 +1221,10 @@
+ 			inverse = check_inverse_type(d->iface);
+ 			parse_interface(d->iface, fw.ip.iniface, fw.ip.iniface_mask);
+ 	                fw.ip.invflags |= (inverse ? IPT_INV_VIA_IN : 0);
+-			fw.nfcache = NFC_IP_IF_IN;
+ 		} else {
+ 			inverse = check_inverse_type(d->iface);
+ 			parse_interface(d->iface, fw.ip.outiface, fw.ip.outiface_mask);
+ 	                fw.ip.invflags |= (inverse ? IPT_INV_VIA_OUT : 0);
+-			fw.nfcache = NFC_IP_IF_OUT;
+ 		}
+ 	} else
+ 		fw.ip.invflags = 0;
+@@ -1254,7 +1252,6 @@
+ 			exit_error(PARAMETER_PROBLEM, 
+ 				"Incorrect rule: more than 1 source address\n");
+ 		fw.ip.src.s_addr = addrs[0].s_addr;
+-		fw.nfcache |= NFC_IP_SRC;
+ 	}
+ 	
+ 	if (strlen(d->dnet)>2) {
+@@ -1265,7 +1262,6 @@
+ 			exit_error(PARAMETER_PROBLEM, "Incorrect rule: more than 1 "
+ 					    "destination address\n");
+ 		fw.ip.dst.s_addr = addrs[0].s_addr;
+-		fw.nfcache |= NFC_IP_DST;
+ 	}
+ 
+ 	if ((d->sport[0]!='\0' || d->dport[0]!='\0') && d->protocol[0]=='\0')
+@@ -1286,7 +1282,6 @@
+ 
+ 	if (d->protocol[0] != '\0') {
+ 		fw.ip.proto = parse_protocol(d->protocol);
+-		fw.nfcache |= NFC_IP_PROTO;
+ 	}
+ 
+ 	if (d->protocol[0] != '\0' && d->protocol[0] != 'i') {
+diff -urN ipac-ng-1.31.org/agents/iptables/libip4tc.c ipac-ng-1.31/agents/iptables/libip4tc.c
+--- ipac-ng-1.31.org/agents/iptables/libip4tc.c	2003-07-06 12:33:23.000000000 +0200
++++ ipac-ng-1.31/agents/iptables/libip4tc.c	2005-12-24 22:37:37.000000000 +0100
+@@ -16,6 +16,7 @@
+ #include <errno.h>
+ #include <stdlib.h>
+ #include <stdio.h>
++#include <unistd.h>
+ 
+ #ifdef DEBUG_CONNTRACK
+ #define inline
+@@ -90,6 +91,7 @@
+ #define TC_SET_POLICY		iptc_set_policy
+ #define TC_GET_RAW_SOCKET	iptc_get_raw_socket
+ #define TC_INIT			iptc_init
++#define TC_FREE			iptc_free
+ #define TC_COMMIT		iptc_commit
+ #define TC_STRERROR		iptc_strerror
+ 
+@@ -127,8 +129,8 @@
+ 	size_t i;
+ 	STRUCT_ENTRY_TARGET *t;
+ 
+-	printf("Entry %u (%lu):\n", entry2index(handle, e),
+-	       entry2offset(handle, e));
++	printf("Entry %u (%lu):\n", iptcb_entry2index(handle, e),
++	       iptcb_entry2offset(handle, e));
+ 	printf("SRC IP: %u.%u.%u.%u/%u.%u.%u.%u\n",
+ 	       IP_PARTS(e->ip.src.s_addr),IP_PARTS(e->ip.smsk.s_addr));
+ 	printf("DST IP: %u.%u.%u.%u/%u.%u.%u.%u\n",
+@@ -143,21 +145,10 @@
+ 	printf("Flags: %02X\n", e->ip.flags);
+ 	printf("Invflags: %02X\n", e->ip.invflags);
+ 	printf("Counters: %llu packets, %llu bytes\n",
+-	       e->counters.pcnt, e->counters.bcnt);
++	       (unsigned long long)e->counters.pcnt, (unsigned long long)e->counters.bcnt);
+ 	printf("Cache: %08X ", e->nfcache);
+ 	if (e->nfcache & NFC_ALTERED) printf("ALTERED ");
+ 	if (e->nfcache & NFC_UNKNOWN) printf("UNKNOWN ");
+-	if (e->nfcache & NFC_IP_SRC) printf("IP_SRC ");
+-	if (e->nfcache & NFC_IP_DST) printf("IP_DST ");
+-	if (e->nfcache & NFC_IP_IF_IN) printf("IP_IF_IN ");
+-	if (e->nfcache & NFC_IP_IF_OUT) printf("IP_IF_OUT ");
+-	if (e->nfcache & NFC_IP_TOS) printf("IP_TOS ");
+-	if (e->nfcache & NFC_IP_PROTO) printf("IP_PROTO ");
+-	if (e->nfcache & NFC_IP_OPTIONS) printf("IP_OPTIONS ");
+-	if (e->nfcache & NFC_IP_TCPFLAGS) printf("IP_TCPFLAGS ");
+-	if (e->nfcache & NFC_IP_SRC_PT) printf("IP_SRC_PT ");
+-	if (e->nfcache & NFC_IP_DST_PT) printf("IP_DST_PT ");
+-	if (e->nfcache & NFC_IP_PROTO_UNKNOWN) printf("IP_PROTO_UNKNOWN ");
+ 	printf("\n");
+ 
+ 	IPT_MATCH_ITERATE(e, print_match);
+@@ -182,60 +173,49 @@
+ 	return 0;
+ }
+ 
+-static int
++static unsigned char *
+ is_same(const STRUCT_ENTRY *a, const STRUCT_ENTRY *b, unsigned char *matchmask)
+ {
+ 	unsigned int i;
+-	STRUCT_ENTRY_TARGET *ta, *tb;
+ 	unsigned char *mptr;
+ 
+ 	/* Always compare head structures: ignore mask here. */
+ 	if (a->ip.src.s_addr != b->ip.src.s_addr
+ 	    || a->ip.dst.s_addr != b->ip.dst.s_addr
+ 	    || a->ip.smsk.s_addr != b->ip.smsk.s_addr
+-	    || a->ip.smsk.s_addr != b->ip.smsk.s_addr
++	    || a->ip.dmsk.s_addr != b->ip.dmsk.s_addr
+ 	    || a->ip.proto != b->ip.proto
+ 	    || a->ip.flags != b->ip.flags
+ 	    || a->ip.invflags != b->ip.invflags)
+-		return 0;
++		return NULL;
+ 
+ 	for (i = 0; i < IFNAMSIZ; i++) {
+ 		if (a->ip.iniface_mask[i] != b->ip.iniface_mask[i])
+-			return 0;
++			return NULL;
+ 		if ((a->ip.iniface[i] & a->ip.iniface_mask[i])
+ 		    != (b->ip.iniface[i] & b->ip.iniface_mask[i]))
+-			return 0;
++			return NULL;
+ 		if (a->ip.outiface_mask[i] != b->ip.outiface_mask[i])
+-			return 0;
++			return NULL;
+ 		if ((a->ip.outiface[i] & a->ip.outiface_mask[i])
+ 		    != (b->ip.outiface[i] & b->ip.outiface_mask[i]))
+-			return 0;
++			return NULL;
+ 	}
+ 
+ 	if (a->nfcache != b->nfcache
+ 	    || a->target_offset != b->target_offset
+ 	    || a->next_offset != b->next_offset)
+-		return 0;
++		return NULL;
+ 
+ 	mptr = matchmask + sizeof(STRUCT_ENTRY);
+ 	if (IPT_MATCH_ITERATE(a, match_different, a->elems, b->elems, &mptr))
+-		return 0;
++		return NULL;
++	mptr += IPT_ALIGN(sizeof(struct ipt_entry_target));
+ 
+-	ta = GET_TARGET((STRUCT_ENTRY *)a);
+-	tb = GET_TARGET((STRUCT_ENTRY *)b);
+-	if (ta->u.target_size != tb->u.target_size)
+-		return 0;
+-	if (strcmp(ta->u.user.name, tb->u.user.name) != 0)
+-		return 0;
+-
+-	mptr += sizeof(*ta);
+-	if (target_different(ta->data, tb->data,
+-			     ta->u.target_size - sizeof(*ta), mptr))
+-		return 0;
+-
+-   	return 1;
++	return mptr;
+ }
+ 
++#if 0
+ /***************************** DEBUGGING ********************************/
+ static inline int
+ unconditional(const struct ipt_ip *ip)
+@@ -290,20 +270,20 @@
+ 		assert(t->verdict == -NF_DROP-1
+ 		       || t->verdict == -NF_ACCEPT-1
+ 		       || t->verdict == RETURN
+-		       || t->verdict < (int)h->entries.size);
++		       || t->verdict < (int)h->entries->size);
+ 
+ 		if (t->verdict >= 0) {
+ 			STRUCT_ENTRY *te = get_entry(h, t->verdict);
+ 			int idx;
+ 
+-			idx = entry2index(h, te);
++			idx = iptcb_entry2index(h, te);
+ 			assert(strcmp(GET_TARGET(te)->u.user.name,
+ 				      IPT_ERROR_TARGET)
+ 			       != 0);
+ 			assert(te != e);
+ 
+ 			/* Prior node must be error node, or this node. */
+-			assert(t->verdict == entry2offset(h, e)+e->next_offset
++			assert(t->verdict == iptcb_entry2offset(h, e)+e->next_offset
+ 			       || strcmp(GET_TARGET(index2entry(h, idx-1))
+ 					 ->u.user.name, IPT_ERROR_TARGET)
+ 			       == 0);
+@@ -335,7 +315,7 @@
+ 	return 0;
+ }
+ 
+-#ifndef NDEBUG
++#ifdef IPTC_DEBUG
+ /* Do every conceivable sanity check on the handle */
+ static void
+ do_check(TC_HANDLE_T h, unsigned int line)
+@@ -364,35 +344,90 @@
+ 
+ 		user_offset = h->info.hook_entry[NF_IP_LOCAL_OUT];
+ 	} else if (strcmp(h->info.name, "nat") == 0) {
+-		assert(h->info.valid_hooks
+-		       == (1 << NF_IP_PRE_ROUTING
+-			   | 1 << NF_IP_POST_ROUTING
+-			   | 1 << NF_IP_LOCAL_OUT));
++		assert((h->info.valid_hooks
++		        == (1 << NF_IP_PRE_ROUTING
++			    | 1 << NF_IP_POST_ROUTING
++			    | 1 << NF_IP_LOCAL_OUT)) ||
++		       (h->info.valid_hooks
++			== (1 << NF_IP_PRE_ROUTING
++			    | 1 << NF_IP_LOCAL_IN
++			    | 1 << NF_IP_POST_ROUTING
++			    | 1 << NF_IP_LOCAL_OUT)));
+ 
+ 		assert(h->info.hook_entry[NF_IP_PRE_ROUTING] == 0);
+ 
+ 		n = get_chain_end(h, 0);
++
+ 		n += get_entry(h, n)->next_offset;
+ 		assert(h->info.hook_entry[NF_IP_POST_ROUTING] == n);
+-
+ 		n = get_chain_end(h, n);
++
+ 		n += get_entry(h, n)->next_offset;
+ 		assert(h->info.hook_entry[NF_IP_LOCAL_OUT] == n);
+-
+ 		user_offset = h->info.hook_entry[NF_IP_LOCAL_OUT];
++
++		if (h->info.valid_hooks & (1 << NF_IP_LOCAL_IN)) {
++			n = get_chain_end(h, n);
++			n += get_entry(h, n)->next_offset;
++			assert(h->info.hook_entry[NF_IP_LOCAL_IN] == n);
++			user_offset = h->info.hook_entry[NF_IP_LOCAL_IN];
++		}
++
+ 	} else if (strcmp(h->info.name, "mangle") == 0) {
++		/* This code is getting ugly because linux < 2.4.18-pre6 had
++		 * two mangle hooks, linux >= 2.4.18-pre6 has five mangle hooks
++		 * */
++		assert((h->info.valid_hooks
++			== (1 << NF_IP_PRE_ROUTING
++			    | 1 << NF_IP_LOCAL_OUT)) || 
++		       (h->info.valid_hooks
++			== (1 << NF_IP_PRE_ROUTING
++			    | 1 << NF_IP_LOCAL_IN
++			    | 1 << NF_IP_FORWARD
++			    | 1 << NF_IP_LOCAL_OUT
++			    | 1 << NF_IP_POST_ROUTING)));
++
++		/* Hooks should be first five */
++		assert(h->info.hook_entry[NF_IP_PRE_ROUTING] == 0);
++
++		n = get_chain_end(h, 0);
++
++		if (h->info.valid_hooks & (1 << NF_IP_LOCAL_IN)) {
++			n += get_entry(h, n)->next_offset;
++			assert(h->info.hook_entry[NF_IP_LOCAL_IN] == n);
++			n = get_chain_end(h, n);
++		}
++
++		if (h->info.valid_hooks & (1 << NF_IP_FORWARD)) {
++			n += get_entry(h, n)->next_offset;
++			assert(h->info.hook_entry[NF_IP_FORWARD] == n);
++			n = get_chain_end(h, n);
++		}
++
++		n += get_entry(h, n)->next_offset;
++		assert(h->info.hook_entry[NF_IP_LOCAL_OUT] == n);
++		user_offset = h->info.hook_entry[NF_IP_LOCAL_OUT];
++
++		if (h->info.valid_hooks & (1 << NF_IP_POST_ROUTING)) {
++			n = get_chain_end(h, n);
++			n += get_entry(h, n)->next_offset;
++			assert(h->info.hook_entry[NF_IP_POST_ROUTING] == n);
++			user_offset = h->info.hook_entry[NF_IP_POST_ROUTING];
++		}
++	} else if (strcmp(h->info.name, "raw") == 0) {
+ 		assert(h->info.valid_hooks
+ 		       == (1 << NF_IP_PRE_ROUTING
+ 			   | 1 << NF_IP_LOCAL_OUT));
+ 
+-		/* Hooks should be first two */
++		/* Hooks should be first three */
+ 		assert(h->info.hook_entry[NF_IP_PRE_ROUTING] == 0);
+ 
+-		n = get_chain_end(h, 0);
++		n = get_chain_end(h, n);
+ 		n += get_entry(h, n)->next_offset;
+ 		assert(h->info.hook_entry[NF_IP_LOCAL_OUT] == n);
+ 
+ 		user_offset = h->info.hook_entry[NF_IP_LOCAL_OUT];
++
+ #ifdef NF_IP_DROPPING
+ 	} else if (strcmp(h->info.name, "drop") == 0) {
+ 		assert(h->info.valid_hooks == (1 << NF_IP_DROPPING));
+@@ -425,8 +460,8 @@
+ 		assert(unconditional(&e->ip));
+ 		assert(e->target_offset == sizeof(*e));
+ 		t = (STRUCT_STANDARD_TARGET *)GET_TARGET(e);
+-		assert(t->target.u.target_size == IPT_ALIGN(sizeof(*t)));
+-		assert(e->next_offset == sizeof(*e) + IPT_ALIGN(sizeof(*t)));
++		assert(t->target.u.target_size == ALIGN(sizeof(*t)));
++		assert(e->next_offset == sizeof(*e) + ALIGN(sizeof(*t)));
+ 
+ 		assert(strcmp(t->target.u.user.name, STANDARD_TARGET)==0);
+ 		assert(t->verdict == -NF_DROP-1 || t->verdict == -NF_ACCEPT-1);
+@@ -458,6 +493,8 @@
+ 	/* Final entry must be error node */
+ 	assert(strcmp(GET_TARGET(index2entry(h, h->new_number-1))
+ 		      ->u.user.name,
+-		      IPT_ERROR_TARGET) == 0);
++		      ERROR_TARGET) == 0);
+ }
+-#endif /*NDEBUG*/
++#endif /*IPTC_DEBUG*/
++
++#endif
+diff -urN ipac-ng-1.31.org/agents/iptables/libiptc.c ipac-ng-1.31/agents/iptables/libiptc.c
+--- ipac-ng-1.31.org/agents/iptables/libiptc.c	2003-07-06 13:34:52.000000000 +0200
++++ ipac-ng-1.31/agents/iptables/libiptc.c	2005-12-24 22:35:54.000000000 +0100
+@@ -1,4 +1,4 @@
+-/* Library which manipulates firewall rules.  Version $Revision$ */
++/* Library which manipulates firewall rules.  Version $Revision$ */
+ 
+ /* Architecture of firewall rules is as follows:
+  *
+@@ -8,22 +8,44 @@
+  * and a POLICY for built-ins.
+  */
+ 
+-/* (C)1999 Paul ``Rusty'' Russell - Placed under the GNU GPL (See
+-   COPYING for details). */
++/* (C) 1999 Paul ``Rusty'' Russell - Placed under the GNU GPL (See
++ * COPYING for details). 
++ * (C) 2000-2004 by the Netfilter Core Team <coreteam at netfilter.org>
++ *
++ * 2003-Jun-20: Harald Welte <laforge at netfilter.org>:
++ *	- Reimplementation of chain cache to use offsets instead of entries
++ * 2003-Jun-23: Harald Welte <laforge at netfilter.org>:
++ * 	- performance optimization, sponsored by Astaro AG (http://www.astaro.com/)
++ * 	  don't rebuild the chain cache after every operation, instead fix it
++ * 	  up after a ruleset change.  
++ * 2004-Aug-18: Harald Welte <laforge at netfilter.org>:
++ * 	- futher performance work: total reimplementation of libiptc.
++ * 	- libiptc now has a real internal (linked-list) represntation of the
++ * 	  ruleset and a parser/compiler from/to this internal representation
++ * 	- again sponsored by Astaro AG (http://www.astaro.com/)
++ */
++#include <sys/types.h>
++#include <sys/socket.h>
+ 
+-#ifndef IPT_LIB_DIR
+-#define IPT_LIB_DIR "/lib/iptables"
++#include "linux_list.h"
++
++//#define IPTC_DEBUG2 1
++
++#ifdef IPTC_DEBUG2
++#include <fcntl.h>
++#define DEBUGP(x, args...)	fprintf(stderr, "%s: " x, __FUNCTION__, ## args)
++#define DEBUGP_C(x, args...)	fprintf(stderr, x, ## args)
++#else
++#define DEBUGP(x, args...)
++#define DEBUGP_C(x, args...)
+ #endif
+ 
+-#ifndef __OPTIMIZE__
+-STRUCT_ENTRY_TARGET *
+-GET_TARGET(STRUCT_ENTRY *e)
+-{
+-	return (void *)e + e->target_offset;
+-}
++#ifndef IPT_LIB_DIR
++#define IPT_LIB_DIR "/usr/local/lib/iptables"
+ #endif
+ 
+ static int sockfd = -1;
++static int sockfd_use = 0;
+ static void *iptc_fn = NULL;
+ 
+ static const char *hooknames[]
+@@ -37,6 +59,16 @@
+ #endif
+ };
+ 
++/* Convenience structures */
++struct ipt_error_target
++{
++	STRUCT_ENTRY_TARGET t;
++	char error[TABLE_MAXNAMELEN];
++};
++
++struct chain_head;
++struct rule_head;
++
+ struct counter_map
+ {
+ 	enum {
+@@ -48,59 +80,95 @@
+ 	unsigned int mappos;
+ };
+ 
+-/* Convenience structures */
+-struct ipt_error_target
++enum iptcc_rule_type {
++	IPTCC_R_STANDARD,		/* standard target (ACCEPT, ...) */
++	IPTCC_R_MODULE,			/* extension module (SNAT, ...) */
++	IPTCC_R_FALLTHROUGH,		/* fallthrough rule */
++	IPTCC_R_JUMP,			/* jump to other chain */
++};
++
++struct rule_head
+ {
+-	STRUCT_ENTRY_TARGET t;
+-	char error[TABLE_MAXNAMELEN];
++	struct list_head list;
++	struct chain_head *chain;
++	struct counter_map counter_map;
++
++	unsigned int index;		/* index (needed for counter_map) */
++	unsigned int offset;		/* offset in rule blob */
++
++	enum iptcc_rule_type type;
++	struct chain_head *jump;	/* jump target, if IPTCC_R_JUMP */
++
++	unsigned int size;		/* size of entry data */
++	STRUCT_ENTRY entry[0];
+ };
+ 
+-struct chain_cache
++struct chain_head
+ {
++	struct list_head list;
+ 	char name[TABLE_MAXNAMELEN];
+-	/* This is the first rule in chain. */
+-	STRUCT_ENTRY *start;
+-	/* Last rule in chain */
+-	STRUCT_ENTRY *end;
++	unsigned int hooknum;		/* hook number+1 if builtin */
++	unsigned int references;	/* how many jumps reference us */
++	int verdict;			/* verdict if builtin */
++
++	STRUCT_COUNTERS counters;	/* per-chain counters */
++	struct counter_map counter_map;
++
++	unsigned int num_rules;		/* number of rules in list */
++	struct list_head rules;		/* list of rules */
++
++	unsigned int index;		/* index (needed for jump resolval) */
++	unsigned int head_offset;	/* offset in rule blob */
++	unsigned int foot_index;	/* index (needed for counter_map) */
++	unsigned int foot_offset;	/* offset in rule blob */
+ };
+ 
+ STRUCT_TC_HANDLE
+ {
+-	/* Have changes been made? */
+-	int changed;
+-	/* Size in here reflects original state. */
+-	STRUCT_GETINFO info;
++	int changed;			 /* Have changes been made? */
+ 
+-	struct counter_map *counter_map;
+-	/* Array of hook names */
+-	const char **hooknames;
+-
+-	/* Cached position of chain heads (NULL = no cache). */
+-	unsigned int cache_num_chains;
+-	unsigned int cache_num_builtins;
+-	struct chain_cache *cache_chain_heads;
+-
+-	/* Chain iterator: current chain cache entry. */
+-	struct chain_cache *cache_chain_iteration;
+-
+-	/* Rule iterator: terminal rule */
+-	STRUCT_ENTRY *cache_rule_end;
+-
+-	/* Number in here reflects current state. */
+-	unsigned int new_number;
+-	STRUCT_GET_ENTRIES entries;
++	struct list_head chains;
++	
++	struct chain_head *chain_iterator_cur;
++	struct rule_head *rule_iterator_cur;
++
++	STRUCT_GETINFO info;
++	STRUCT_GET_ENTRIES *entries;
+ };
+ 
++/* allocate a new chain head for the cache */
++static struct chain_head *iptcc_alloc_chain_head(const char *name, int hooknum)
++{
++	struct chain_head *c = malloc(sizeof(*c));
++	if (!c)
++		return NULL;
++	memset(c, 0, sizeof(*c));
++
++	strncpy(c->name, name, TABLE_MAXNAMELEN);
++	c->hooknum = hooknum;
++	INIT_LIST_HEAD(&c->rules);
++
++	return c;
++}
++
++/* allocate and initialize a new rule for the cache */
++static struct rule_head *iptcc_alloc_rule(struct chain_head *c, unsigned int size)
++{
++	struct rule_head *r = malloc(sizeof(*r)+size);
++	if (!r)
++		return NULL;
++	memset(r, 0, sizeof(*r));
++
++	r->chain = c;
++	r->size = size;
++
++	return r;
++}
++
++/* notify us that the ruleset has been modified by the user */
+ static void
+ set_changed(TC_HANDLE_T h)
+ {
+-	if (h->cache_chain_heads) {
+-		free(h->cache_chain_heads);
+-		h->cache_chain_heads = NULL;
+-		h->cache_num_chains = 0;
+-		h->cache_chain_iteration = NULL;
+-		h->cache_rule_end = NULL;
+-	}
+ 	h->changed = 1;
+ }
+ 
+@@ -111,8 +179,13 @@
+ #define CHECK(h)
+ #endif
+ 
++
++/**********************************************************************
++ * iptc blob utility functions (iptcb_*)
++ **********************************************************************/
++
+ static inline int
+-get_number(const STRUCT_ENTRY *i,
++iptcb_get_number(const STRUCT_ENTRY *i,
+ 	   const STRUCT_ENTRY *seek,
+ 	   unsigned int *pos)
+ {
+@@ -122,22 +195,8 @@
+ 	return 0;
+ }
+ 
+-static unsigned int
+-entry2index(const TC_HANDLE_T h, const STRUCT_ENTRY *seek)
+-{
+-	unsigned int pos = 0;
+-
+-	if (ENTRY_ITERATE(h->entries.entrytable, h->entries.size,
+-			  get_number, seek, &pos) == 0) {
+-		fprintf(stderr, "ERROR: offset %i not an entry!\n",
+-			(char *)seek - (char *)h->entries.entrytable);
+-		abort();
+-	}
+-	return pos;
+-}
+-
+ static inline int
+-get_entry_n(STRUCT_ENTRY *i,
++iptcb_get_entry_n(STRUCT_ENTRY *i,
+ 	    unsigned int number,
+ 	    unsigned int *pos,
+ 	    STRUCT_ENTRY **pe)
+@@ -150,51 +209,556 @@
+ 	return 0;
+ }
+ 
+-static STRUCT_ENTRY *
+-index2entry(TC_HANDLE_T h, unsigned int index)
++static inline STRUCT_ENTRY *
++iptcb_get_entry(TC_HANDLE_T h, unsigned int offset)
+ {
+-	unsigned int pos = 0;
+-	STRUCT_ENTRY *ret = NULL;
++	return (STRUCT_ENTRY *)((char *)h->entries->entrytable + offset);
++}
+ 
+-	ENTRY_ITERATE(h->entries.entrytable, h->entries.size,
+-		      get_entry_n, index, &pos, &ret);
++static unsigned int
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list