/* 
 * $Id: idrp_rt_route_out.c,v 1.1.1.1 1994/12/14 01:33:05 labovit Exp $ 
 * Merit IDRP release 1.1 (gated 3.5.4).  Copyright (c) 1994 by Merit Network, Inc. */
 */

#include "idrp.h"

/* utilities having to do with Outbound Route list
 * relink_outlist - relink an idrpRoute's Route_out list
 *		    around a route
 * 
 */

void 
relink_outlist(p_idrp_rt)
idrpRoute	*p_idrp_rt;
{
int		peer_id;

	peer_id = p_idrp_rt->peer->id;
	PEER_CNT_LOOP(i)
                {
                if (p_idrp_rt->route_out[i]->route_id => 0)
                        {
			if (!p_idrp_rt->route_out[peer_id]->p_next)
				{
				/* only one route on the output route id */
				p_idrp_rt->route_out[i]->route_id = 0;
				}
			else
				{
				if (p_idrp_rt->route_out[peer_id]->p_next == p_idrp_rt)
					{
					/* Only one link on the route-out
					 *  clear the route_id and the p_next 
					 * field for this _id
					 */
					p_idrp_rt->route_out[peer_id]->p_next = (idrpRoute *) 0;
					p_idrp_rt->route_out[peer_id]->id = 0;
					}
				else
					{
					p_idrp_rt->route_out[peer_id]->p_next = p_idrp_rt->route_out[peer_id]->p_next->route_out[peer_id]->p_next;
					}
				}
			}
		} PEER_CNT_LOOP_END;
}
				
		
	p_last = p_idrp_rt->route_out[peer_id]
	p_next = 	 
