2 * ntp_peer.c - management of data maintained for peer associations
12 #include "ntp_lists.h"
13 #include "ntp_stdlib.h"
14 #include "ntp_control.h"
15 #include <ntp_random.h>
18 * Table of valid association combinations
19 * ---------------------------------------
22 * peer->mode | UNSPEC ACTIVE PASSIVE CLIENT SERVER BCAST
23 * ---------- | ---------------------------------------------
24 * NO_PEER | e 1 0 1 1 1
25 * ACTIVE | e 1 1 0 0 0
26 * PASSIVE | e 1 e 0 0 0
27 * CLIENT | e 0 0 0 1 0
28 * SERVER | e 0 0 0 0 0
30 * BCLIENT | e 0 0 0 e 1
32 * One point to note here: a packet in BCAST mode can potentially match
33 * a peer in CLIENT mode, but we that is a special case and we check for
34 * that early in the decision process. This avoids having to keep track
35 * of what kind of associations are possible etc... We actually
36 * circumvent that problem by requiring that the first b(m)roadcast
37 * received after the change back to BCLIENT mode sets the clock.
39 #define AM_MODES 7 /* number of rows and columns */
40 #define NO_PEER 0 /* action when no peer is found */
42 int AM[AM_MODES][AM_MODES] = {
44 /* peer { UNSPEC, ACTIVE, PASSIVE, CLIENT, SERVER, BCAST } */
46 /*NONE*/{ AM_ERR, AM_NEWPASS, AM_NOMATCH, AM_FXMIT, AM_MANYCAST, AM_NEWBCL},
48 /*A*/ { AM_ERR, AM_PROCPKT, AM_PROCPKT, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH},
50 /*P*/ { AM_ERR, AM_PROCPKT, AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH},
52 /*C*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_PROCPKT, AM_NOMATCH},
54 /*S*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH},
56 /*BCST*/{ AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH},
58 /*BCL*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_PROCPKT},
61 #define MATCH_ASSOC(x, y) AM[(x)][(y)]
64 * These routines manage the allocation of memory to peer structures
65 * and the maintenance of three data structures involving all peers:
67 * - peer_list is a single list with all peers, suitable for scanning
68 * operations over all peers.
69 * - peer_adr_hash is an array of lists indexed by hashed peer address.
70 * - peer_aid_hash is an array of lists indexed by hashed associd.
72 * They also maintain a free list of peer structures, peer_free.
74 * The three main entry points are findpeer(), which looks for matching
75 * peer structures in the peer list, newpeer(), which allocates a new
76 * peer structure and adds it to the list, and unpeer(), which
77 * demobilizes the association and deallocates the structure.
82 struct peer *peer_hash[NTP_HASH_SIZE]; /* peer hash table */
83 int peer_hash_count[NTP_HASH_SIZE]; /* peers in each bucket */
84 struct peer *assoc_hash[NTP_HASH_SIZE]; /* association ID hash table */
85 int assoc_hash_count[NTP_HASH_SIZE];/* peers in each bucket */
86 struct peer *peer_list; /* peer structures list */
87 static struct peer *peer_free; /* peer structures free list */
88 int peer_free_count; /* count of free structures */
91 * Association ID. We initialize this value randomly, then assign a new
92 * value every time an association is mobilized.
94 static associd_t current_association_ID; /* association ID */
95 static associd_t initial_association_ID; /* association ID */
98 * Memory allocation watermarks.
100 #define INIT_PEER_ALLOC 8 /* static preallocation */
101 #define INC_PEER_ALLOC 4 /* add N more when empty */
104 * Miscellaneous statistic counters which may be queried.
106 u_long peer_timereset; /* time stat counters zeroed */
107 u_long findpeer_calls; /* calls to findpeer */
108 u_long assocpeer_calls; /* calls to findpeerbyassoc */
109 u_long peer_allocations; /* allocations from free list */
110 u_long peer_demobilizations; /* structs freed to free list */
111 int total_peer_structs; /* peer structs */
112 int peer_associations; /* mobilized associations */
113 int peer_preempt; /* preemptable associations */
114 static struct peer init_peer_alloc[INIT_PEER_ALLOC]; /* init alloc */
116 static struct peer * findexistingpeer_name(const char *, u_short,
118 static struct peer * findexistingpeer_addr(sockaddr_u *,
121 static void free_peer(struct peer *, int);
122 static void getmorepeermem(void);
123 static int score(struct peer *);
127 * init_peer - initialize peer data structures and counters
129 * N.B. We use the random number routine in here. It had better be
130 * initialized prior to getting here.
138 * Initialize peer free list from static allocation.
140 for (i = COUNTOF(init_peer_alloc) - 1; i >= 0; i--)
141 LINK_SLIST(peer_free, &init_peer_alloc[i], p_link);
142 total_peer_structs = COUNTOF(init_peer_alloc);
143 peer_free_count = COUNTOF(init_peer_alloc);
146 * Initialize our first association ID
149 current_association_ID = ntp_random() & ASSOCID_MAX;
150 while (!current_association_ID);
151 initial_association_ID = current_association_ID;
156 * getmorepeermem - add more peer structures to the free list
164 peers = emalloc_zero(INC_PEER_ALLOC * sizeof(*peers));
166 for (i = INC_PEER_ALLOC - 1; i >= 0; i--)
167 LINK_SLIST(peer_free, &peers[i], p_link);
169 total_peer_structs += INC_PEER_ALLOC;
170 peer_free_count += INC_PEER_ALLOC;
175 findexistingpeer_name(
176 const char * hostname,
178 struct peer * start_peer,
184 if (NULL == start_peer)
187 p = start_peer->p_link;
188 for (; p != NULL; p = p->p_link)
189 if (p->hostname != NULL
190 && (-1 == mode || p->hmode == mode)
191 && (AF_UNSPEC == hname_fam
192 || AF_UNSPEC == AF(&p->srcadr)
193 || hname_fam == AF(&p->srcadr))
194 && !strcasecmp(p->hostname, hostname))
202 findexistingpeer_addr(
204 struct peer * start_peer,
211 DPRINTF(2, ("findexistingpeer_addr(%s, %s, %d, 0x%x)\n",
214 ? sptoa(&start_peer->srcadr)
216 mode, (u_int)cast_flags));
219 * start_peer is included so we can locate instances of the
220 * same peer through different interfaces in the hash table.
221 * Without MDF_BCLNT, a match requires the same mode and remote
222 * address. MDF_BCLNT associations start out as MODE_CLIENT
223 * if broadcastdelay is not specified, and switch to
224 * MODE_BCLIENT after estimating the one-way delay. Duplicate
225 * associations are expanded in definition to match any other
226 * MDF_BCLNT with the same srcadr (remote, unicast address).
228 if (NULL == start_peer)
229 peer = peer_hash[NTP_HASH_ADDR(addr)];
231 peer = start_peer->adr_link;
233 while (peer != NULL) {
234 DPRINTF(3, ("%s %s %d %d 0x%x 0x%x ", sptoa(addr),
235 sptoa(&peer->srcadr), mode, peer->hmode,
236 (u_int)cast_flags, (u_int)peer->cast_flags));
237 if ((-1 == mode || peer->hmode == mode ||
238 ((MDF_BCLNT & peer->cast_flags) &&
239 (MDF_BCLNT & cast_flags))) &&
240 ADDR_PORT_EQ(addr, &peer->srcadr)) {
241 DPRINTF(3, ("found.\n"));
245 peer = peer->adr_link;
253 * findexistingpeer - search by address and return a pointer to a peer.
258 const char * hostname,
259 struct peer * start_peer,
264 if (hostname != NULL)
265 return findexistingpeer_name(hostname, AF(addr),
268 return findexistingpeer_addr(addr, start_peer, mode,
274 * findpeer - find and return a peer match for a received datagram in
275 * the peer_hash table.
279 struct recvbuf *rbufp,
291 srcadr = &rbufp->recv_srcadr;
292 hash = NTP_HASH_ADDR(srcadr);
293 for (p = peer_hash[hash]; p != NULL; p = p->adr_link) {
294 if (ADDR_PORT_EQ(srcadr, &p->srcadr)) {
297 * if the association matching rules determine
298 * that this is not a valid combination, then
299 * look for the next valid peer association.
301 *action = MATCH_ASSOC(p->hmode, pkt_mode);
304 * A response to our manycastclient solicitation
305 * might be misassociated with an ephemeral peer
306 * already spun for the server. If the packet's
307 * org timestamp doesn't match the peer's, check
308 * if it matches the ACST prototype peer's. If
309 * so it is a redundant solicitation response,
310 * return AM_ERR to discard it. [Bug 1762]
312 if (MODE_SERVER == pkt_mode &&
313 AM_PROCPKT == *action) {
314 pkt = &rbufp->recv_pkt;
315 NTOHL_FP(&pkt->org, &pkt_org);
316 if (!L_ISEQU(&p->aorg, &pkt_org) &&
317 findmanycastpeer(rbufp))
322 * if an error was returned, exit back right
325 if (*action == AM_ERR)
329 * if a match is found, we stop our search.
331 if (*action != AM_NOMATCH)
337 * If no matching association is found
340 *action = MATCH_ASSOC(NO_PEER, pkt_mode);
341 } else if (p->dstadr != rbufp->dstadr) {
342 set_peerdstadr(p, rbufp->dstadr);
343 if (p->dstadr == rbufp->dstadr) {
344 DPRINTF(1, ("Changed %s local address to match response\n",
346 return findpeer(rbufp, pkt_mode, action);
353 * findpeerbyassoc - find and return a peer using his association ID
364 hash = assoc & NTP_HASH_MASK;
365 for (p = assoc_hash[hash]; p != NULL; p = p->aid_link)
366 if (assoc == p->associd)
373 * clear_all - flush all time values for all associations
381 * This routine is called when the clock is stepped, and so all
382 * previously saved time values are untrusted.
384 for (p = peer_list; p != NULL; p = p->p_link)
385 if (!(MDF_TXONLY_MASK & p->cast_flags))
386 peer_clear(p, "STEP");
388 DPRINTF(1, ("clear_all: at %lu\n", current_time));
393 * score_all() - determine if an association can be demobilized
397 struct peer *peer /* peer structure pointer */
405 * This routine finds the minimum score for all preemptible
406 * associations and returns > 0 if the association can be
411 for (speer = peer_list; speer != NULL; speer = speer->p_link)
412 if (speer->flags & FLAG_PREEMPT) {
417 DPRINTF(1, ("score_all: at %lu score %d min %d\n",
418 current_time, tamp, temp));
428 * score() - calculate preemption score
432 struct peer *peer /* peer structure pointer */
438 * This routine calculates the premption score from the peer
439 * error bits and status. Increasing values are more cherished.
442 if (!(peer->flash & TEST10))
443 temp++; /* 1 good synch and stratum */
444 if (!(peer->flash & TEST13))
445 temp++; /* 2 reachable */
446 if (!(peer->flash & TEST12))
447 temp++; /* 3 no loop */
448 if (!(peer->flash & TEST11))
449 temp++; /* 4 good distance */
450 if (peer->status >= CTL_PST_SEL_SELCAND)
451 temp++; /* 5 in the hunt */
452 if (peer->status != CTL_PST_SEL_EXCESS)
453 temp++; /* 6 not spare tire */
454 return (temp); /* selection status */
459 * free_peer - internal routine to free memory referred to by a struct
460 * peer and return it to the peer free list. If unlink is
461 * nonzero, unlink from the various lists.
469 struct peer * unlinked;
473 hash = NTP_HASH_ADDR(&p->srcadr);
474 peer_hash_count[hash]--;
476 UNLINK_SLIST(unlinked, peer_hash[hash], p, adr_link,
478 if (NULL == unlinked) {
479 peer_hash_count[hash]++;
480 msyslog(LOG_ERR, "peer %s not in address table!",
485 * Remove him from the association hash as well.
487 hash = p->associd & NTP_HASH_MASK;
488 assoc_hash_count[hash]--;
490 UNLINK_SLIST(unlinked, assoc_hash[hash], p, aid_link,
492 if (NULL == unlinked) {
493 assoc_hash_count[hash]++;
495 "peer %s not in association ID table!",
499 /* Remove him from the overall list. */
500 UNLINK_SLIST(unlinked, peer_list, p, p_link,
502 if (NULL == unlinked)
503 msyslog(LOG_ERR, "%s not in peer list!",
507 if (p->hostname != NULL)
510 if (p->ident != NULL)
513 if (p->addrs != NULL)
514 free(p->addrs); /* from copy_addrinfo_list() */
516 /* Add his corporeal form to peer free list */
518 LINK_SLIST(peer_free, p, p_link);
524 * unpeer - remove peer structure from hash table and free structure
531 mprintf_event(PEVNT_DEMOBIL, peer, "assoc %u", peer->associd);
532 restrict_source(&peer->srcadr, 1, 0);
533 set_peerdstadr(peer, NULL);
534 peer_demobilizations++;
536 if (FLAG_PREEMPT & peer->flags)
540 * If this peer is actually a clock, shut it down first
542 if (FLAG_REFCLOCK & peer->flags)
543 refclock_unpeer(peer);
546 free_peer(peer, TRUE);
551 * peer_config - configure a new association
556 const char * hostname,
565 const char * ident /* autokey group */
571 * We do a dirty little jig to figure the cast flags. This is
572 * probably not the best place to do this, at least until the
573 * configure code is rebuilt. Note only one flag can be set.
577 if (IS_MCAST(srcadr))
578 cast_flags = MDF_MCAST;
580 cast_flags = MDF_BCAST;
584 if (hostname != NULL && SOCK_UNSPEC(srcadr))
585 cast_flags = MDF_POOL;
586 else if (IS_MCAST(srcadr))
587 cast_flags = MDF_ACAST;
589 cast_flags = MDF_UCAST;
593 cast_flags = MDF_UCAST;
597 * Mobilize the association and initialize its variables. If
598 * emulating ntpdate, force iburst. For pool and manycastclient
599 * strip FLAG_PREEMPT as the prototype associations are not
600 * themselves preemptible, though the resulting associations
603 flags |= FLAG_CONFIG;
605 flags |= FLAG_IBURST;
606 if ((MDF_ACAST | MDF_POOL) & cast_flags)
607 flags &= ~FLAG_PREEMPT;
608 return newpeer(srcadr, hostname, dstadr, hmode, version,
609 minpoll, maxpoll, flags, cast_flags, ttl, key, ident);
613 * setup peer dstadr field keeping it in sync with the interface
622 struct peer * unlinked;
624 if (p->dstadr == dstadr)
628 * Don't accept updates to a separate multicast receive-only
629 * endpt while a BCLNT peer is running its unicast protocol.
631 if (dstadr != NULL && (FLAG_BC_VOL & p->flags) &&
632 (INT_MCASTIF & dstadr->flags) && MODE_CLIENT == p->hmode) {
635 if (p->dstadr != NULL) {
636 p->dstadr->peercnt--;
637 UNLINK_SLIST(unlinked, p->dstadr->peers, p, ilink,
639 msyslog(LOG_INFO, "%s local addr %s -> %s",
640 stoa(&p->srcadr), latoa(p->dstadr),
644 if (dstadr != NULL) {
645 LINK_SLIST(dstadr->peers, p, ilink);
651 * attempt to re-rebind interface if necessary
654 peer_refresh_interface(
661 niface = select_peerinterface(p, &p->srcadr, NULL);
664 "peer_refresh_interface: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %u key %08x: new interface: ",
665 p->dstadr == NULL ? "<null>" :
666 stoa(&p->dstadr->sin), stoa(&p->srcadr), p->hmode,
667 p->version, p->minpoll, p->maxpoll, p->flags, p->cast_flags,
669 if (niface != NULL) {
671 "fd=%d, bfd=%d, name=%.16s, flags=0x%x, ifindex=%u, sin=%s",
672 niface->fd, niface->bfd, niface->name,
673 niface->flags, niface->ifindex,
674 stoa(&niface->sin)));
675 if (niface->flags & INT_BROADCAST)
676 DPRINTF(4, (", bcast=%s",
677 stoa(&niface->bcast)));
678 DPRINTF(4, (", mask=%s\n", stoa(&niface->mask)));
680 DPRINTF(4, ("<NONE>\n"));
684 set_peerdstadr(p, niface);
685 if (p->dstadr != NULL) {
687 * clear crypto if we change the local address
689 if (p->dstadr != piface && !(MDF_ACAST & p->cast_flags)
690 && MODE_BROADCAST != p->pmode)
691 peer_clear(p, "XFAC");
694 * Broadcast needs the socket enabled for broadcast
696 if (MDF_BCAST & p->cast_flags)
697 enable_broadcast(p->dstadr, &p->srcadr);
700 * Multicast needs the socket interface enabled for
703 if (MDF_MCAST & p->cast_flags)
704 enable_multicast_if(p->dstadr, &p->srcadr);
710 * refresh_all_peerinterfaces - see that all interface bindings are up
714 refresh_all_peerinterfaces(void)
719 * this is called when the interface list has changed
720 * give all peers a chance to find a better interface
721 * but only if either they don't have an address already
722 * or if the one they have hasn't worked for a while.
724 for (p = peer_list; p != NULL; p = p->p_link) {
725 if (!(p->dstadr && (p->reach & 0x3))) // Bug 2849 XOR 2043
726 peer_refresh_interface(p);
732 * newpeer - initialize a new peer association
737 const char * hostname,
753 DEBUG_REQUIRE(srcadr);
757 * If Autokey is requested but not configured, complain loudly.
760 if (key > NTP_MAXKEY) {
763 } else if (flags & FLAG_SKEY) {
764 msyslog(LOG_ERR, "Autokey not configured");
771 * For now only pool associations have a hostname.
773 INSIST(NULL == hostname || (MDF_POOL & cast_flags));
776 * First search from the beginning for an association with given
777 * remote address and mode. If an interface is given, search
778 * from there to find the association which matches that
779 * destination. If the given interface is "any", track down the
780 * actual interface, because that's what gets put into the peer
783 if (dstadr != NULL) {
784 peer = findexistingpeer(srcadr, hostname, NULL, hmode,
786 while (peer != NULL) {
787 if (peer->dstadr == dstadr ||
788 ((MDF_BCLNT & cast_flags) &&
789 (MDF_BCLNT & peer->cast_flags)))
792 if (dstadr == ANY_INTERFACE_CHOOSE(srcadr) &&
793 peer->dstadr == findinterface(srcadr))
796 peer = findexistingpeer(srcadr, hostname, peer,
800 /* no endpt address given */
801 peer = findexistingpeer(srcadr, hostname, NULL, hmode,
806 * If a peer is found, this would be a duplicate and we don't
807 * allow that. This avoids duplicate ephemeral (broadcast/
808 * multicast) and preemptible (manycast and pool) client
812 DPRINTF(2, ("newpeer(%s) found existing association\n",
820 * Allocate a new peer structure. Some dirt here, since some of
821 * the initialization requires knowlege of our system state.
823 if (peer_free_count == 0)
825 UNLINK_HEAD_SLIST(peer, peer_free, p_link);
826 INSIST(peer != NULL);
829 if (FLAG_PREEMPT & flags)
833 * Assign an association ID and increment the system variable.
835 peer->associd = current_association_ID;
836 if (++current_association_ID == 0)
837 ++current_association_ID;
839 peer->srcadr = *srcadr;
840 if (hostname != NULL)
841 peer->hostname = estrdup(hostname);
843 peer->version = version;
845 peer->cast_flags = cast_flags;
847 select_peerinterface(peer, srcadr, dstadr));
850 * It is an error to set minpoll less than NTP_MINPOLL or to
851 * set maxpoll greater than NTP_MAXPOLL. However, minpoll is
852 * clamped not greater than NTP_MAXPOLL and maxpoll is clamped
853 * not less than NTP_MINPOLL without complaint. Finally,
854 * minpoll is clamped not greater than maxpoll.
857 peer->minpoll = NTP_MINDPOLL;
859 peer->minpoll = min(minpoll, NTP_MAXPOLL);
861 peer->maxpoll = NTP_MAXDPOLL;
863 peer->maxpoll = max(maxpoll, NTP_MINPOLL);
864 if (peer->minpoll > peer->maxpoll)
865 peer->minpoll = peer->maxpoll;
867 if (peer->dstadr != NULL)
868 DPRINTF(3, ("newpeer(%s): using fd %d and our addr %s\n",
869 stoa(srcadr), peer->dstadr->fd,
870 stoa(&peer->dstadr->sin)));
872 DPRINTF(3, ("newpeer(%s): local interface currently not bound\n",
876 * Broadcast needs the socket enabled for broadcast
878 if ((MDF_BCAST & cast_flags) && peer->dstadr != NULL)
879 enable_broadcast(peer->dstadr, srcadr);
882 * Multicast needs the socket interface enabled for multicast
884 if ((MDF_MCAST & cast_flags) && peer->dstadr != NULL)
885 enable_multicast_if(peer->dstadr, srcadr);
888 if (key > NTP_MAXKEY)
889 peer->flags |= FLAG_SKEY;
894 peer->ident = estrdup(ident);
895 peer->precision = sys_precision;
896 peer->hpoll = peer->minpoll;
897 if (cast_flags & MDF_ACAST)
898 peer_clear(peer, "ACST");
899 else if (cast_flags & MDF_POOL)
900 peer_clear(peer, "POOL");
901 else if (cast_flags & MDF_MCAST)
902 peer_clear(peer, "MCST");
903 else if (cast_flags & MDF_BCAST)
904 peer_clear(peer, "BCST");
906 peer_clear(peer, "INIT");
911 * Note time on statistics timers.
913 peer->timereset = current_time;
914 peer->timereachable = current_time;
915 peer->timereceived = current_time;
917 if (ISREFCLOCKADR(&peer->srcadr)) {
920 * We let the reference clock support do clock
921 * dependent initialization. This includes setting
922 * the peer timer, since the clock may have requirements
926 peer->maxpoll = peer->minpoll;
927 if (!refclock_newpeer(peer)) {
929 * Dump it, something screwed up
931 set_peerdstadr(peer, NULL);
936 msyslog(LOG_ERR, "refclock %s isn't supported. ntpd was compiled without refclock support.",
937 stoa(&peer->srcadr));
938 set_peerdstadr(peer, NULL);
941 #endif /* REFCLOCK */
945 * Put the new peer in the hash tables.
947 hash = NTP_HASH_ADDR(&peer->srcadr);
948 LINK_SLIST(peer_hash[hash], peer, adr_link);
949 peer_hash_count[hash]++;
950 hash = peer->associd & NTP_HASH_MASK;
951 LINK_SLIST(assoc_hash[hash], peer, aid_link);
952 assoc_hash_count[hash]++;
953 LINK_SLIST(peer_list, peer, p_link);
955 restrict_source(&peer->srcadr, 0, 0);
956 mprintf_event(PEVNT_MOBIL, peer, "assoc %d", peer->associd);
957 DPRINTF(1, ("newpeer: %s->%s mode %u vers %u poll %u %u flags 0x%x 0x%x ttl %u key %08x\n",
958 latoa(peer->dstadr), stoa(&peer->srcadr), peer->hmode,
959 peer->version, peer->minpoll, peer->maxpoll, peer->flags,
960 peer->cast_flags, peer->ttl, peer->keyid));
966 * peer_clr_stats - clear peer module statistics counters
973 peer_allocations = 0;
974 peer_demobilizations = 0;
975 peer_timereset = current_time;
980 * peer_reset - reset statistics counters
990 peer->timereset = current_time;
997 peer->seldisptoolarge = 0;
1003 * peer_all_reset - reset all peer statistics counters
1006 peer_all_reset(void)
1010 for (peer = peer_list; peer != NULL; peer = peer->p_link)
1016 * findmanycastpeer - find and return a manycastclient or pool
1017 * association matching a received response.
1021 struct recvbuf *rbufp /* receive buffer pointer */
1029 * This routine is called upon arrival of a server-mode response
1030 * to a manycastclient multicast solicitation, or to a pool
1031 * server unicast solicitation. Search the peer list for a
1032 * manycastclient association where the last transmit timestamp
1033 * matches the response packet's originate timestamp. There can
1034 * be multiple manycastclient associations, or multiple pool
1035 * solicitation assocations, so this assumes the transmit
1036 * timestamps are unique for such.
1038 pkt = &rbufp->recv_pkt;
1039 for (peer = peer_list; peer != NULL; peer = peer->p_link)
1040 if (MDF_SOLICIT_MASK & peer->cast_flags) {
1041 NTOHL_FP(&pkt->org, &p_org);
1042 if (L_ISEQU(&p_org, &peer->aorg))
1049 /* peer_cleanup - clean peer list prior to shutdown */
1050 void peer_cleanup(void)
1055 for (assoc = initial_association_ID; assoc != current_association_ID; assoc++) {
1057 peer = findpeerbyassoc(assoc);
1062 peer = findpeerbyassoc(current_association_ID);