From 9b709859db5310444052d13ed8ebccec6ead1669 Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Sat, 11 Feb 2012 10:42:40 -0500 Subject: Actually remove the #ifdef OLD_COMPAT and NEW_COMPAT code To my knowledge, this hasn't been enabled by anyone in ages --- server/dispatch.c | 13 ---- server/server.c | 50 ------------- server/subscr.c | 205 ------------------------------------------------------ 3 files changed, 268 deletions(-) diff --git a/server/dispatch.c b/server/dispatch.c index 7851135..b591ec6 100644 --- a/server/dispatch.c +++ b/server/dispatch.c @@ -889,11 +889,6 @@ nack_cancel(ZNotice_t *notice, notice->z_uid.tv.tv_sec, notice->z_uid.tv.tv_usec)); } -/* for compatibility when sending subscription information to old clients */ -#ifdef OLD_COMPAT -#define OLD_ZEPHYR_VERSION "ZEPH0.0" -#endif /* OLD_COMPAT */ - /* Dispatch an HM_CTL notice. */ Code_t @@ -1008,14 +1003,6 @@ control_dispatch(ZNotice_t *notice, someone who has no subscriptions does NOT get a SERVNAK but rather an empty list. Note we must therefore check authentication inside subscr_sendlist */ -#ifdef OLD_COMPAT - /* only acknowledge if *not* old version; the old version - acknowledges the packet with the reply */ - if (strcmp(notice->z_version, OLD_ZEPHYR_VERSION) != 0) - ack(notice, who); -#else /* !OLD_COMPAT */ - ack(notice, who); -#endif /* OLD_COMPAT */ subscr_sendlist(notice, auth, who); return ZERR_NONE; } else if (!auth) { diff --git a/server/server.c b/server/server.c index f2684c1..de1b051 100644 --- a/server/server.c +++ b/server/server.c @@ -112,17 +112,6 @@ long timo_up = TIMO_UP; long timo_tardy = TIMO_TARDY; long timo_dead = TIMO_DEAD; -/* counters to measure old protocol use */ -#ifdef OLD_COMPAT -int old_compat_count_uloc = 0; -int old_compat_count_ulocate = 0; -int old_compat_count_subscr = 0; -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT -int new_compat_count_uloc = 0; -int new_compat_count_subscr = 0; -#endif /* NEW_COMPAT */ - #ifdef DEBUG int zalone; #endif /* DEBUG */ @@ -756,20 +745,6 @@ send_stats(struct sockaddr_in *who) sprintf(buf, "%ld seconds operational",NOW - uptime); upt = strsave(buf); -#ifdef OLD_COMPAT - if (old_compat_count_uloc) - extrafields++; - if (old_compat_count_ulocate) - extrafields++; - if (old_compat_count_subscr) - extrafields++; -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT - if (new_compat_count_uloc) - extrafields++; - if (new_compat_count_subscr) - extrafields++; -#endif /* NEW_COMPAT */ extrafields += nrealms; responses = (char **) malloc((NUM_FIXED + nservers + extrafields) * sizeof(char *)); @@ -785,31 +760,6 @@ send_stats(struct sockaddr_in *who) otherservers[i].dumping ? " (DUMPING)" : ""); responses[num_resp++] = strsave(buf); } -#ifdef OLD_COMPAT - if (old_compat_count_uloc) { - sprintf(buf, "%d old old location requests", old_compat_count_uloc); - responses[num_resp++] = strsave(buf); - } - if (old_compat_count_ulocate) { - sprintf(buf, "%d old old loc lookup requests", - old_compat_count_ulocate); - responses[num_resp++] = strsave(buf); - } - if (old_compat_count_subscr) { - sprintf(buf, "%d old old subscr requests", old_compat_count_subscr); - responses[num_resp++] = strsave(buf); - } -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT - if (new_compat_count_uloc) { - sprintf(buf, "%d new old location requests", new_compat_count_uloc); - responses[num_resp++] = strsave(buf); - } - if (new_compat_count_subscr) { - sprintf(buf, "%d new old subscr requests", new_compat_count_subscr); - responses[num_resp++] = strsave(buf); - } -#endif /* NEW_COMPAT */ for (realm = otherrealms, i = 0; i < nrealms ; i++, realm++) { sprintf(buf, "%s(%s)/%s", realm->name, inet_ntoa((realm->addrs[realm->idx]).sin_addr), diff --git a/server/subscr.c b/server/subscr.c index a646f72..7c5099b 100644 --- a/server/subscr.c +++ b/server/subscr.c @@ -66,22 +66,6 @@ C_Block serv_key; Sched serv_ksched; #endif -/* for compatibility when sending subscription information to old clients */ - -#ifdef OLD_COMPAT -#define OLD_ZEPHYR_VERSION "ZEPH0.0" -#define OLD_CLIENT_INCOMPSUBS "INCOMP" -static void old_compat_subscr_sendlist(ZNotice_t *notice, int auth, - struct sockaddr_in *who); -extern int old_compat_count_subscr; /* counter of old use */ -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT -#define NEW_OLD_ZEPHYR_VERSION "ZEPH0.1" -static void new_old_compat_subscr_sendlist(ZNotice_t *notice, int auth, - struct sockaddr_in *who); -extern int new_compat_count_subscr; /* counter of old use */ -#endif /* NEW_COMPAT */ - static Code_t add_subscriptions(Client *who, Destlist *subs_queue, ZNotice_t *notice, Server *server); static Destlist *extract_subscriptions(ZNotice_t *notice); @@ -444,22 +428,6 @@ subscr_sendlist(ZNotice_t *notice, struct sockaddr_in send_to_who; Code_t retval; -#ifdef OLD_COMPAT - if (strcmp(notice->z_version, OLD_ZEPHYR_VERSION) == 0) { - /* we are talking to an old client; use the old-style - acknowledgement-message */ - old_compat_subscr_sendlist(notice, auth, who); - return; - } -#endif /* OLD_COMPAT */ -#ifdef NEW_COMPAT - if (strcmp(notice->z_version, NEW_OLD_ZEPHYR_VERSION) == 0) { - /* we are talking to a new old client; use the new-old-style - acknowledgement-message */ - new_old_compat_subscr_sendlist(notice, auth, who); - return; - } -#endif /* NEW_COMPAT */ answer = subscr_marshal_subs(notice, auth, who, &found); send_to_who = *who; send_to_who.sin_port = notice->z_port; /* Return port */ @@ -588,179 +556,6 @@ subscr_marshal_subs(ZNotice_t *notice, return answer; } -#ifdef NEW_COMPAT -static void -new_old_compat_subscr_sendlist(notice, auth, who) - ZNotice_t *notice; - int auth; - struct sockaddr_in *who; -{ - Code_t retval; - ZNotice_t reply; - ZPacket_t reppacket; - int packlen, found, count, initfound, zerofound; - char buf[64]; - const char **answer; - struct sockaddr_in send_to_who; - int i; - - new_compat_count_subscr++; - - syslog(LOG_INFO, "new old subscr, %s", inet_ntoa(who->sin_addr)); - reply = *notice; - reply.z_kind = SERVACK; - reply.z_authent_len = 0; /* save some space */ - reply.z_auth = 0; - - send_to_who = *who; - send_to_who.sin_port = notice->z_port; /* Return port */ - - retval = ZSetDestAddr(&send_to_who); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "new_old_subscr_sendlist set addr: %s", - error_message(retval)); - return; - } - - /* retrieve the subscriptions */ - answer = subscr_marshal_subs(notice, auth, who, &found); - - /* note that when there are no subscriptions, found == 0, so - we needn't worry about answer being NULL since - ZFormatSmallRawNoticeList won't reference the pointer */ - - /* send 5 at a time until we are finished */ - count = found?((found-1) / 5 + 1):1; /* total # to be sent */ - i = 0; /* pkt # counter */ - initfound = found; - zerofound = (found == 0); - while (found > 0 || zerofound) { - packlen = sizeof(reppacket); - sprintf(buf, "%d/%d", ++i, count); - reply.z_opcode = buf; - retval = ZFormatSmallRawNoticeList(&reply, - answer + (initfound - found) - * NUM_FIELDS, - ((found > 5) ? 5 : found) - * NUM_FIELDS, - reppacket, &packlen); - if (retval != ZERR_NONE) { - syslog(LOG_ERR, "subscr_sendlist format: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSendPacket(reppacket, packlen, 0); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist xmit: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - found -= 5; - zerofound = 0; - } - if (answer) - free(answer); -} -#endif /* NEW_COMPAT */ - -#ifdef OLD_COMPAT -static void -old_compat_subscr_sendlist(notice, auth, who) - ZNotice_t *notice; - int auth; - struct sockaddr_in *who; -{ - Client *client = client_find(&who->sin_addr, notice->z_port); - Destlist *subs; - Code_t retval; - ZNotice_t reply; - ZPacket_t reppacket; - int packlen, i, found = 0; - char **answer = NULL; - - old_compat_count_subscr++; - - syslog(LOG_INFO, "old old subscr, %s", inet_ntoa(who->sin_addr)); - if (client && client->subs) { - - /* check authenticity here. The user must be authentic to get - a list of subscriptions. If he is not subscribed to - anything, the above test fails, and he gets a response - indicating no subscriptions */ - - if (!auth) { - clt_ack(notice, who, AUTH_FAILED); - return; - } - - for (subs = client->subs; subs; subs = subs->next) - found++; - /* found is now the number of subscriptions */ - - /* coalesce the subscription information into a list of char *'s */ - answer = (char **) malloc(found * NUM_FIELDS * sizeof(char *)); - if (!answer) { - syslog(LOG_ERR, "old_subscr_sendlist no mem(answer)"); - found = 0; - } else { - i = 0; - for (subs = client->subs; subs; subs = subs->next) { - answer[i*NUM_FIELDS] = subs->dest.classname->string; - answer[i*NUM_FIELDS + 1] = subs->dest.inst->string; - answer[i*NUM_FIELDS + 2] = subs->dest.recip->string; - i++; - } - } - } - - /* note that when there are no subscriptions, found == 0, so - we needn't worry about answer being NULL */ - - reply = *notice; - reply.z_kind = SERVACK; - reply.z_authent_len = 0; /* save some space */ - reply.z_auth = 0; - - /* if it's too long, chop off one at a time till it fits */ - while ((retval = ZFormatSmallRawNoticeList(&reply, answer, - found * NUM_FIELDS, - reppacket, - &packlen)) != ZERR_PKTLEN) { - found--; - reply.z_opcode = OLD_CLIENT_INCOMPSUBS; - } - if (retval != ZERR_NONE) { - syslog(LOG_ERR, "old_subscr_sendlist format: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSetDestAddr(who); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist set addr: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - retval = ZSendPacket(reppacket, packlen, 0); - if (retval != ZERR_NONE) { - syslog(LOG_WARNING, "subscr_sendlist xmit: %s", - error_message(retval)); - if (answer) - free(answer); - return; - } - if (answer) - free(answer); -} -#endif /* OLD_COMPAT */ - static Code_t subscr_send_some_subs(char *opcode, struct sockaddr_in *addr, Destlist *subs, char *subject) { -- cgit v1.2.3