Blob Blame History Raw
diff -up dnscap/dnscap.c.isc_list dnscap/dnscap.c
--- dnscap/dnscap.c.isc_list	2007-08-07 14:53:02.000000000 +0200
+++ dnscap/dnscap.c	2007-08-07 14:55:30.000000000 +0200
@@ -173,45 +173,45 @@ typedef struct {
 } iaddr;
 
 struct endpoint {
-	ISC_LINK(struct endpoint)  link;
+	LINK(struct endpoint)  link;
 	iaddr			ia;
 };
 typedef struct endpoint *endpoint_ptr;
-typedef ISC_LIST(struct endpoint) endpoint_list;
+typedef LIST(struct endpoint) endpoint_list;
 
 struct mypcap {
-	ISC_LINK(struct mypcap)	link;
+	LINK(struct mypcap)	link;
 	const char *		name;
 	int			fdes;
 	pcap_t *		pcap;
 	int			dlt;
 };
 typedef struct mypcap *mypcap_ptr;
-typedef ISC_LIST(struct mypcap) mypcap_list;
+typedef LIST(struct mypcap) mypcap_list;
 
 struct vlan {
-	ISC_LINK(struct vlan)	link;
+	LINK(struct vlan)	link;
 	unsigned		vlan;
 };
 typedef struct vlan *vlan_ptr;
-typedef ISC_LIST(struct vlan) vlan_list;
+typedef LIST(struct vlan) vlan_list;
 
 struct text {
-	ISC_LINK(struct text)	link;
+	LINK(struct text)	link;
 	size_t			len;
 	char *			text;
 };
 typedef struct text *text_ptr;
-typedef ISC_LIST(struct text) text_list;
+typedef LIST(struct text) text_list;
 #define text_size(len) (sizeof(struct text) + len)
 
 struct myregex {
-	ISC_LINK(struct myregex)  link;
+	LINK(struct myregex)  link;
 	regex_t			reg;
 	char *			str;
 };
 typedef struct myregex *myregex_ptr;
-typedef ISC_LIST(struct myregex) myregex_list;
+typedef LIST(struct myregex) myregex_list;
 
 /* Forward. */
 
@@ -385,11 +385,11 @@ parse_args(int argc, char *argv[]) {
 		ProgramName = argv[0];
 	else
 		ProgramName = p+1;
-	ISC_LIST_INIT(vlans);
-	ISC_LIST_INIT(mypcaps);
-	ISC_LIST_INIT(initiators);
-	ISC_LIST_INIT(responders);
-	ISC_LIST_INIT(myregexes);
+	INIT_LIST(vlans);
+	INIT_LIST(mypcaps);
+	INIT_LIST(initiators);
+	INIT_LIST(responders);
+	INIT_LIST(myregexes);
 	while ((ch = getopt(argc, argv,
 			    "ad1g6vs?i:o:l:p:m:h:e:q:r:b:k:t:c:x:")
 		) != EOF)
@@ -429,22 +429,22 @@ parse_args(int argc, char *argv[]) {
 				usage("-i makes no sense after -o");
 			mypcap = malloc(sizeof *mypcap);
 			assert(mypcap != NULL);
-			ISC_LINK_INIT(mypcap, link);
+			INIT_LINK(mypcap, link);
 			mypcap->name = strdup(optarg);
 			assert(mypcap->name != NULL);
 			mypcap->fdes = -1;
-			ISC_LIST_APPEND(mypcaps, mypcap, link);
+			APPEND(mypcaps, mypcap, link);
 			break;
 		case 'o':
-			if (!ISC_LIST_EMPTY(mypcaps))
+			if (!EMPTY(mypcaps))
 				usage("-o makes no sense after -i");
 			pcap_offline = malloc(sizeof *pcap_offline);
 			assert(pcap_offline != NULL);
-			ISC_LINK_INIT(pcap_offline, link);
+			INIT_LINK(pcap_offline, link);
 			pcap_offline->name = strdup(optarg);
 			assert(pcap_offline->name != NULL);
 			pcap_offline->fdes = -1;
-			ISC_LIST_APPEND(mypcaps, pcap_offline, link);
+			APPEND(mypcaps, pcap_offline, link);
 			break;
 		case 'l':
 			ul = strtoul(optarg, &p, 0);
@@ -452,9 +452,9 @@ parse_args(int argc, char *argv[]) {
 				usage("vlan must be 0 or an integer 1..4095");
 			vlan = malloc(sizeof *vlan);
 			assert(vlan != NULL);
-			ISC_LINK_INIT(vlan, link);
+			INIT_LINK(vlan, link);
 			vlan->vlan = (unsigned) ul;
-			ISC_LIST_APPEND(vlans, vlan, link);
+			APPEND(vlans, vlan, link);
 			break;
 		case 'p':
 			ul = strtoul(optarg, &p, 0);
@@ -529,7 +529,7 @@ parse_args(int argc, char *argv[]) {
 #if HAVE_BINDLIB
 			myregex = malloc(sizeof *myregex);
 			assert(myregex != NULL);
-			ISC_LINK_INIT(myregex, link);
+			INIT_LINK(myregex, link);
 			myregex->str = strdup(optarg);
 			i = regcomp(&myregex->reg, myregex->str, REGEX_CFLAGS);
 			if (i != 0) {
@@ -537,7 +537,7 @@ parse_args(int argc, char *argv[]) {
 					 errbuf, sizeof errbuf);
 				usage(errbuf);
 			}
-			ISC_LIST_APPEND(myregexes, myregex, link);
+			APPEND(myregexes, myregex, link);
 			break;
 #else
 			usage("-x option is disabled due to lack of libbind");
@@ -550,7 +550,7 @@ parse_args(int argc, char *argv[]) {
 	assert(err_wanted != 0U);
 	if (dump_type == nowhere && !dig_it)
 		usage("without -b or -g, there would be no output");
-	if (nonmatching && ISC_LIST_EMPTY(myregexes))
+	if (nonmatching && EMPTY(myregexes))
 		usage("without at least one -x, it makes no sense to say -v");
 	if (dumptrace >= 1) {
 		endpoint_ptr ep;
@@ -571,36 +571,36 @@ parse_args(int argc, char *argv[]) {
 			(err_wanted & ERR_YES) != 0 ? 'Y' : '.',
 			limit_seconds, limit_packets);
 		sep = "\tinit";
-		for (ep = ISC_LIST_HEAD(initiators);
+		for (ep = HEAD(initiators);
 		     ep != NULL;
-		     ep = ISC_LIST_NEXT(ep, link))
+		     ep = NEXT(ep, link))
 		{
 			fprintf(stderr, "%s %s", sep, ia_str(ep->ia));
 			sep = "";
 		}
-		if (!ISC_LIST_EMPTY(initiators))
+		if (!EMPTY(initiators))
 			fprintf(stderr, "\n");
 		sep = "\tresp";
-		for (ep = ISC_LIST_HEAD(responders);
+		for (ep = HEAD(responders);
 		     ep != NULL;
-		     ep = ISC_LIST_NEXT(ep, link))
+		     ep = NEXT(ep, link))
 		{
 			fprintf(stderr, "%s %s", sep, ia_str(ep->ia));
 			sep = "";
 		}
-		if (!ISC_LIST_EMPTY(responders))
+		if (!EMPTY(responders))
 			fprintf(stderr, "\n");
-		if (!ISC_LIST_EMPTY(myregexes)) {
+		if (!EMPTY(myregexes)) {
 			fprintf(stderr, "%s: pat (%smatching):",
 				ProgramName, nonmatching ? "non" : "");
-			for (mr = ISC_LIST_HEAD(myregexes);
+			for (mr = HEAD(myregexes);
 			     mr != NULL;
-			     mr = ISC_LIST_NEXT(mr, link))
+			     mr = NEXT(mr, link))
 				fprintf(stderr, " /%s/", mr->str);
 			fprintf(stderr, "\n");
 		}
 	}
-	if (ISC_LIST_EMPTY(mypcaps)) {
+	if (EMPTY(mypcaps)) {
 		const char *name;
 #ifdef __linux__
 		name = NULL;	/* "all interfaces" */
@@ -614,10 +614,10 @@ parse_args(int argc, char *argv[]) {
 #endif
 		mypcap = malloc(sizeof *mypcap);
 		assert(mypcap != NULL);
-		ISC_LINK_INIT(mypcap, link);
+		INIT_LINK(mypcap, link);
 		mypcap->name = strdup(name);
 		mypcap->fdes = -1;
-		ISC_LIST_APPEND(mypcaps, mypcap, link);
+		APPEND(mypcaps, mypcap, link);
 	}
 }
 
@@ -668,9 +668,9 @@ endpoint_add(endpoint_list *list, iaddr 
 
 	ep = malloc(sizeof *ep);
 	assert(ep != NULL);
-	ISC_LINK_INIT(ep, link);
+	INIT_LINK(ep, link);
 	ep->ia = ia;
-	ISC_LIST_APPEND(*list, ep, link);
+	APPEND(*list, ep, link);
 }
 
 static void
@@ -703,9 +703,9 @@ prepare_bpft(void) {
 	}
 
 	/* Make a BPF program to do early course kernel-level filtering. */
-	ISC_LIST_INIT(bpfl);
+	INIT_LIST(bpfl);
 	len = 0;
-	if (!ISC_LIST_EMPTY(vlans))
+	if (!EMPTY(vlans))
 		len += text_add(&bpfl, "vlan and ");
 	len += text_add(&bpfl, "udp port %d", dns_port);
 	if (!v6bug) {
@@ -722,22 +722,22 @@ prepare_bpft(void) {
 			len += text_add(&bpfl, " and udp[11] & 0x%x = 0x%x",
 					udp11_mbs, udp11_mbs);
 	}
-	if (!ISC_LIST_EMPTY(initiators) && !ISC_LIST_EMPTY(responders)) {
+	if (!EMPTY(initiators) && !EMPTY(responders)) {
 		const char *or = "or", *lp = "(", *sep;
 		endpoint_ptr ep;
 
 		len += text_add(&bpfl, " and host");
 		sep = lp;
-		for (ep = ISC_LIST_HEAD(initiators);
+		for (ep = HEAD(initiators);
 		     ep != NULL;
-		     ep = ISC_LIST_NEXT(ep, link))
+		     ep = NEXT(ep, link))
 		{
 			len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
 			sep = or;
 		}
-		for (ep = ISC_LIST_HEAD(responders);
+		for (ep = HEAD(responders);
 		     ep != NULL;
-		     ep = ISC_LIST_NEXT(ep, link))
+		     ep = NEXT(ep, link))
 		{
 			len += text_add(&bpfl, " %s %s", sep, ia_str(ep->ia));
 			sep = or;
@@ -747,9 +747,9 @@ prepare_bpft(void) {
 	bpft = malloc(len + 1);
 	assert(bpft != NULL);
 	bpft[0] = '\0';
-	for (text = ISC_LIST_HEAD(bpfl);
+	for (text = HEAD(bpfl);
 	     text != NULL;
-	     text = ISC_LIST_NEXT(text, link))
+	     text = NEXT(text, link))
 		strcat(bpft, text->text);
 	text_free(&bpfl);
 	if (dumptrace >= 1)
@@ -768,9 +768,9 @@ static int
 ep_present(const endpoint_list *list, iaddr ia) {
 	endpoint_ptr ep;
 
-	for (ep = ISC_LIST_HEAD(*list);
+	for (ep = HEAD(*list);
 	     ep != NULL;
-	     ep = ISC_LIST_NEXT(ep, link))
+	     ep = NEXT(ep, link))
 		if (ia.af == ep->ia.af)
 			switch (ia.af) {
 			case AF_INET:
@@ -796,12 +796,12 @@ text_add(text_list *list, const char *fm
 
 	text = malloc(sizeof *text);
 	assert(text != NULL);
-	ISC_LINK_INIT(text, link);
+	INIT_LINK(text, link);
 	va_start(ap, fmt);
 	len = vasprintf(&text->text, fmt, ap);
 	assert(len >= 0);
 	va_end(ap);
-	ISC_LIST_APPEND(*list, text, link);
+	APPEND(*list, text, link);
 	return (len);
 }
 
@@ -809,8 +809,8 @@ static void
 text_free(text_list *list) {
 	text_ptr text;
 
-	while ((text = ISC_LIST_HEAD(*list)) != NULL) {
-		ISC_LIST_UNLINK(*list, text, link);
+	while ((text = HEAD(*list)) != NULL) {
+		UNLINK(*list, text, link);
 		free(text);
 	}
 }
@@ -819,12 +819,12 @@ static void
 open_pcaps(void) {
 	mypcap_ptr mypcap;
 
-	assert(!ISC_LIST_EMPTY(mypcaps));
+	assert(!EMPTY(mypcaps));
 	FD_ZERO(&mypcap_fdset);
 	pcap_maxfd = 0;
-	for (mypcap = ISC_LIST_HEAD(mypcaps);
+	for (mypcap = HEAD(mypcaps);
 	     mypcap != NULL;
-	     mypcap = ISC_LIST_NEXT(mypcap, link))
+	     mypcap = NEXT(mypcap, link))
 	{
 		struct bpf_program bpfp;
 #ifdef __APPLE__
@@ -887,9 +887,9 @@ poll_pcaps(void) {
 		return;
 	}
 	/* Poll them all. */
-	for (mypcap = ISC_LIST_HEAD(mypcaps);
+	for (mypcap = HEAD(mypcaps);
 	     mypcap != NULL;
-	     mypcap = ISC_LIST_NEXT(mypcap, link))
+	     mypcap = NEXT(mypcap, link))
 	{
 		n = pcap_dispatch(mypcap->pcap, -1, dl_pkt,
 				  (u_char *)mypcap);
@@ -907,9 +907,9 @@ static void
 breakloop_pcaps(void) {
 	mypcap_ptr mypcap;
 
-	for (mypcap = ISC_LIST_HEAD(mypcaps);
+	for (mypcap = HEAD(mypcaps);
 	     mypcap != NULL;
-	     mypcap = ISC_LIST_NEXT(mypcap, link))
+	     mypcap = NEXT(mypcap, link))
 		pcap_breakloop(mypcap->pcap);
 }
 
@@ -917,9 +917,9 @@ static void
 close_pcaps(void) {
 	mypcap_ptr mypcap;
 
-	for (mypcap = ISC_LIST_HEAD(mypcaps);
+	for (mypcap = HEAD(mypcaps);
 	     mypcap != NULL;
-	     mypcap = ISC_LIST_NEXT(mypcap, link))
+	     mypcap = NEXT(mypcap, link))
 		pcap_close(mypcap->pcap);
 	pcap_close(pcap_dead);
 }
@@ -1009,12 +1009,12 @@ dl_pkt(u_char *user, const struct pcap_p
 		return;
 	}
 
-	if (!ISC_LIST_EMPTY(vlans)) {
+	if (!EMPTY(vlans)) {
 		vlan_ptr vl;
 
-		for (vl = ISC_LIST_HEAD(vlans);
+		for (vl = HEAD(vlans);
 		     vl != NULL;
-		     vl = ISC_LIST_NEXT(vl, link))
+		     vl = NEXT(vl, link))
 			if (vl->vlan == vlan || vl->vlan == 0)
 				break;
 		if (vl == NULL)
@@ -1213,9 +1213,9 @@ network_pkt(const char *descr, my_bpftim
 	} else {
 		return;
 	}
-	if (!((ISC_LIST_EMPTY(initiators) ||
+	if (!((EMPTY(initiators) ||
 	       ep_present(&initiators, initiator)) &&
-	      (ISC_LIST_EMPTY(responders) ||
+	      (EMPTY(responders) ||
 	       ep_present(&responders, responder))))
 		return;
 	if (!(((msg_wanted & MSG_QUERY) != 0 && dns.opcode == ns_o_query) ||
@@ -1229,7 +1229,7 @@ network_pkt(const char *descr, my_bpftim
 			return;
 	}
 #if HAVE_BINDLIB
-	if (!ISC_LIST_EMPTY(myregexes)) {
+	if (!EMPTY(myregexes)) {
 		ns_msg msg;
 		ns_sect s;
 		int match;
@@ -1257,9 +1257,9 @@ network_pkt(const char *descr, my_bpftim
 						return;
 					look = pres;
 				}
-				for (myregex = ISC_LIST_HEAD(myregexes);
+				for (myregex = HEAD(myregexes);
 				     myregex != NULL && !match;
-				     myregex = ISC_LIST_NEXT(myregex, link))
+				     myregex = NEXT(myregex, link))
 					if (regexec(&myregex->reg, look,
 						    0, NULL, 0) == 0)
 					{