sys/netinet/if_atm.c
int
atmresolve(struct rtentry *rt, struct mbuf *m, struct sockaddr *dst,
	   struct atm_pseudohdr *desten)
{
	struct sockaddr_dl *sdl;

	if (m->m_flags & (M_BCAST|M_MCAST)) {
		log(LOG_INFO, "atmresolve: BCAST/MCAST packet detected/dumped");
		goto bad;
	}

	if (rt == NULL) {
		rt = RTALLOC1(dst, 0);
		if (rt == NULL) goto bad; /* failed */
		rt->rt_refcnt--;	/* don't keep LL references */
		if ((rt->rt_flags & RTF_GATEWAY) != 0 ||
			(rt->rt_flags & RTF_LLINFO) == 0 ||
			/* XXX: are we using LLINFO? */
			rt->rt_gateway->sa_family != AF_LINK) {
				goto bad;
		}
	}

	/*
	 * note that rt_gateway is a sockaddr_dl which contains the
	 * atm_pseudohdr data structure for this route.   we currently
	 * don't need any rt_llinfo info (but will if we want to support
	 * ATM ARP [c.f. if_ether.c]).
	 */

	sdl = SDL(rt->rt_gateway);

	/*
	 * Check the address family and length is valid, the address
	 * is resolved; otherwise, try to resolve.
	 */


	if (sdl->sdl_family == AF_LINK && sdl->sdl_alen == sizeof(*desten)) {
		bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
		return(1);	/* ok, go for it! */
	}

	/*
	 * we got an entry, but it doesn't have valid link address
	 * info in it (it is prob. the interface route, which has
	 * sdl_alen == 0).    dump packet.  (fall through to "bad").
	 */

bad:
	m_freem(m);
	return(0);
}
/*
 * atmresolve:
 *   inputs:
 *     [1] "rt" = the link level route to use (or null if need to look one up)
 *     [2] "m" = mbuf containing the data to be sent
 *     [3] "dst" = sockaddr_in (IP) address of dest.
 *   output:
 *     [4] "desten" = ATM pseudo header which we will fill in VPI/VCI info
 *   return:
 *     0 == resolve FAILED; note that "m" gets m_freem'd in this case
 *     1 == resolve OK; desten contains result
 *
 *   XXX: will need more work if we wish to support ATMARP in the kernel,
 *   but this is enough for PVCs entered via the "route" command.
 */


will need more work if we wish to support ATMARP in the kernel,
but this is enough for PVCs entered via the "route" command.
will need more work if we wish to support ATMARP in the kernel but this is enough for PVCs entered via the " route " command .
int
atmresolve(struct rtentry *rt, struct mbuf *m, struct sockaddr *dst,
	   struct atm_pseudohdr *desten)
{
	struct sockaddr_dl *sdl;
	if (m->m_flags & (M_BCAST|M_MCAST)) {
		log(LOG_INFO, "atmresolve: BCAST/MCAST packet detected/dumped");
		goto bad;
	}
	if (rt == NULL) {
		rt = RTALLOC1(dst, 0);
		if (rt == NULL) goto bad; 
		rt->rt_refcnt--;	
		if ((rt->rt_flags & RTF_GATEWAY) != 0 ||
			(rt->rt_flags & RTF_LLINFO) == 0 ||
			rt->rt_gateway->sa_family != AF_LINK) {
				goto bad;
		}
	}
	sdl = SDL(rt->rt_gateway);
	if (sdl->sdl_family == AF_LINK && sdl->sdl_alen == sizeof(*desten)) {
		bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
		return(1);	
	}
bad:
	m_freem(m);
	return(0);
}
int atmresolve ( struct rtentry * rt , struct mbuf * m , struct sockaddr * dst , struct atm_pseudohdr * desten ) { struct sockaddr_dl * sdl ; if ( m -> m_flags & ( M_BCAST | M_MCAST ) ) { log ( LOG_INFO , " " ) ; goto bad ; } if ( rt == NULL ) { rt = RTALLOC1 ( dst , 0 ) ; if ( rt == NULL ) goto bad ; rt -> rt_refcnt -- ; if ( ( rt -> rt_flags & RTF_GATEWAY ) != 0 || ( rt -> rt_flags & RTF_LLINFO ) == 0 || rt -> rt_gateway -> sa_family != AF_LINK ) { goto bad ; } } sdl = SDL ( rt -> rt_gateway ) ; if ( sdl -> sdl_family == AF_LINK && sdl -> sdl_alen == sizeof ( * desten ) ) { bcopy ( LLADDR ( sdl ) , desten , sdl -> sdl_alen ) ; return ( 1 ) ; } bad : m_freem ( m ) ; return ( 0 ) ; }
atmresolve:
   inputs:
     [1] "rt" = the link level route to use (or null if need to look one up)
     [2] "m" = mbuf containing the data to be sent
     [3] "dst" = sockaddr_in (IP) address of dest.
atmresolve : inputs : [ 1 ] " rt " = the link level route to use ( or null if need to look one up ) [ 2 ] " m " = mbuf containing the data to be sent [ 3 ] " dst " = sockaddr_in ( IP ) address of dest .
/* failed */ /* don't keep LL references */ /* XXX: are we using LLINFO? */ /*
	 * note that rt_gateway is a sockaddr_dl which contains the
	 * atm_pseudohdr data structure for this route.   we currently
	 * don't need any rt_llinfo info (but will if we want to support
	 * ATM ARP [c.f. if_ether.c]).
	 */ /*
	 * Check the address family and length is valid, the address
	 * is resolved; otherwise, try to resolve.
	 */ /* ok, go for it! */ /*
	 * we got an entry, but it doesn't have valid link address
	 * info in it (it is prob. the interface route, which has
	 * sdl_alen == 0).    dump packet.  (fall through to "bad").
	 */