diff -Nur squid-2.5.STABLE9/src/cache_cf.c squid-2.5.STABLE9-zph/src/cache_cf.c
--- squid-2.5.STABLE9/src/cache_cf.c	2005-02-21 04:55:04.000000000 +0200
+++ squid-2.5.STABLE9-zph/src/cache_cf.c	2005-05-16 13:47:29.597512520 +0300
@@ -213,6 +213,11 @@
     int i;
     if (token == NULL)
 	self_destruct();
+    if (token[0] == '0' && token[1] == 'x') {		/* seems to be hex */
+	if (sscanf(token, "%x", &i) != 1)
+	    self_destruct();
+	return i;
+    }
     if (sscanf(token, "%d", &i) != 1)
 	self_destruct();
     return i;
diff -Nur squid-2.5.STABLE9/src/cf.data.pre squid-2.5.STABLE9-zph/src/cf.data.pre
--- squid-2.5.STABLE9/src/cf.data.pre	2005-02-23 02:06:34.000000000 +0200
+++ squid-2.5.STABLE9-zph/src/cf.data.pre	2005-05-16 13:47:29.606511152 +0300
@@ -2340,6 +2340,36 @@
 	matching line.
 DOC_END
 
+NAME: zph_tos_local
+TYPE: int
+DEFAULT: 0
+LOC: Config.zph_tos_local
+DOC_START
+	Allows you to select a TOS/Diffserv value to mark local hits. Read above
+	(tcp_outgoing_tos) for details/requirements about TOS.
+	Default: 0 (disabled).
+DOC_END
+
+NAME: zph_tos_peer
+TYPE: int
+DEFAULT: 0
+LOC: Config.zph_tos_peer
+DOC_START
+	Allows you to select a TOS/Diffserv value to mark peer hits. Read above
+	(tcp_outgoing_tos) for details/requirements about TOS.
+	Default: 0 (disabled).
+DOC_END
+
+NAME: zph_tos_parent
+COMMENT: on|off
+TYPE: onoff
+LOC: Config.onoff.zph_tos_parent
+DEFAULT: on
+DOC_START
+	Set this to off if you want only sibling hits to be marked.
+	If set to on (default), parent hits are being marked too.
+DOC_END
+
 NAME: tcp_outgoing_address
 TYPE: acl_address
 DEFAULT: none
diff -Nur squid-2.5.STABLE9/src/client_side.c squid-2.5.STABLE9-zph/src/client_side.c
--- squid-2.5.STABLE9/src/client_side.c	2005-02-20 21:07:45.000000000 +0200
+++ squid-2.5.STABLE9-zph/src/client_side.c	2005-05-16 13:47:29.620509024 +0300
@@ -1975,6 +1975,42 @@
 	return;
     }
     if (http->out.offset == 0) {
+	if (Config.zph_tos_local || Config.zph_tos_peer) {
+	    int need_change = 0;
+	    int hit = 0;
+	    int tos = 0;
+	    int tos_old = 0;
+	    int tos_len = sizeof(tos_old);
+
+	    if (Config.zph_tos_local && isTcpHit(http->log_type)) {	/* local hit */
+		hit = 1;
+		tos = Config.zph_tos_local;
+	    } else if (Config.zph_tos_peer &&
+		(http->request->hier.code == SIBLING_HIT ||		/* sibling hit */
+		(Config.onoff.zph_tos_parent &&
+		http->request->hier.code == PARENT_HIT))) {		/* parent hit */
+		hit = 1;
+		tos = Config.zph_tos_peer;
+	    }
+	    if (http->request->flags.proxy_keepalive) {
+		if (getsockopt(fd, IPPROTO_IP, IP_TOS, &tos_old, &tos_len) < 0) {
+		    debug(33, 1) ("ZPH: getsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
+		} else if (hit && tos_old != tos) {	/* HIT: 1-st request, or previous was MISS, */
+		    need_change = 1;			/* or local/parent hit change */
+		} else if (!hit && tos_old) {		/* MISS: previous was HIT */
+		    tos = 0;
+		    need_change = 1;
+		}
+	    } else if (hit) {				/* no keepalive */
+		need_change = 1;
+	    }
+	    if (need_change) {
+		if (setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)) < 0) {
+		    debug(33, 1) ("ZPH: setsockopt(IP_TOS) on FD %d: %s\n", fd, xstrerror());
+		}
+	    }
+	}
+
 	rep = clientBuildReply(http, buf, size);
 	if (rep) {
 	    aclCheck_t *ch;
diff -Nur squid-2.5.STABLE9/src/structs.h squid-2.5.STABLE9-zph/src/structs.h
--- squid-2.5.STABLE9/src/structs.h	2005-02-23 02:06:35.000000000 +0200
+++ squid-2.5.STABLE9-zph/src/structs.h	2005-05-16 13:47:44.733211544 +0300
@@ -608,6 +608,7 @@
 	int relaxed_header_parser;
 	int accel_uses_host_header;
 	int accel_no_pmtu_disc;
+	int zph_tos_parent;
     } onoff;
     acl *aclList;
     struct {
@@ -710,6 +711,8 @@
     char *store_dir_select_algorithm;
     int sleep_after_fork;	/* microseconds */
     external_acl *externalAclHelperList;
+    int zph_tos_local;
+    int zph_tos_peer;
 };
 
 struct _SquidConfig2 {
