sys/netproto/atm/ipatm/ipatm_load.c
static int
ipatm_start(void)
{
	struct atm_pif	*pip;
	struct atm_nif	*nip;
	int	err, i;

	/*
	 * Verify software version
	 */
	if (atm_version != ATM_VERSION) {
		log(LOG_ERR, "version mismatch: ipatm=%d.%d kernel=%d.%d\n",
			ATM_VERS_MAJ(ATM_VERSION), ATM_VERS_MIN(ATM_VERSION),
			ATM_VERS_MAJ(atm_version), ATM_VERS_MIN(atm_version));
		return (EINVAL);
	}

	/*
	 * Register ourselves as a network convergence module
	 */
	err = atm_netconv_register(&ipatm_ncm);
	if (err)
		goto done;

	/*
	 * Register ourselves as an ATM endpoint
	 */
	err = atm_endpoint_register(&ipatm_endpt);
	if (err)
		goto done;

	/*
	 * Get current system configuration
	 */
	crit_enter();
	for (pip = atm_interface_head; pip; pip = pip->pif_next) {
		/*
		 * Process each network interface
		 */
		for (nip = pip->pif_nif; nip; nip = nip->nif_pnext) {
			struct ifnet    *ifp = (struct ifnet *)nip;
			struct in_ifaddr	*ia;
			struct in_ifaddr_container *iac;

			/*
			 * Attach interface
			 */
			err = ipatm_nifstat(NCM_ATTACH, nip, 0);
			if (err) {
				crit_exit();
				goto done;
			}

			/*
			 * If IP address has been set, register it
			 */
			TAILQ_FOREACH(iac, &in_ifaddrheads[mycpuid], ia_link) {
				if (iac->ia->ia_ifp == ifp)
					break;
			}
			if (iac) {
				ia = iac->ia;
				err = ipatm_nifstat(NCM_SETADDR, nip, (int)ia);
				if (err) {
					crit_exit();
					goto done;
				}
			}
		}
	}
	crit_exit();

	/*
	 * Fill in union fields
	 */
	ipatm_aal5llc.aal.v.aal5.forward_max_SDU_size =
		ATM_NIF_MTU + IPATM_LLC_LEN;
	ipatm_aal5llc.aal.v.aal5.backward_max_SDU_size =
		ATM_NIF_MTU + IPATM_LLC_LEN;
	ipatm_aal5llc.aal.v.aal5.SSCS_type = T_ATM_NULL;
	ipatm_aal5llc.blli.v.layer_2_protocol.ID.simple_ID = T_ATM_BLLI2_I8802;

	ipatm_aal5null.aal.v.aal5.forward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal5null.aal.v.aal5.backward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal5null.aal.v.aal5.SSCS_type = T_ATM_NULL;

	ipatm_aal4null.aal.v.aal4.forward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal4null.aal.v.aal4.backward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal4null.aal.v.aal4.SSCS_type = T_ATM_NULL;
	ipatm_aal4null.aal.v.aal4.mid_low = 0;
	ipatm_aal4null.aal.v.aal4.mid_high = 1023;

	/*
	 * Listen for incoming calls
	 */
	for (i = 0;
	     i < (sizeof(ipatm_listeners) / sizeof(struct ipatm_listener));
	     i++) {
		struct attr_aal	*aalp = &ipatm_listeners[i].attr.aal;
		int	maxsdu = ATM_NIF_MTU;

		/*
		 * Fill in union fields
		 */
		if (ipatm_listeners[i].attr.blli.tag_l2 == T_ATM_PRESENT) {
			struct t_atm_blli *bp = &ipatm_listeners[i].attr.blli.v;

			bp->layer_2_protocol.ID.simple_ID = T_ATM_BLLI2_I8802;
			maxsdu += IPATM_LLC_LEN;
		}
		if (aalp->type == ATM_AAL5) {
			aalp->v.aal5.forward_max_SDU_size = maxsdu;
			aalp->v.aal5.backward_max_SDU_size = maxsdu;
			aalp->v.aal5.SSCS_type = T_ATM_NULL;
		} else {
			aalp->v.aal4.forward_max_SDU_size = maxsdu;
			aalp->v.aal4.backward_max_SDU_size = maxsdu;
			aalp->v.aal4.SSCS_type = T_ATM_NULL;
			aalp->v.aal4.mid_low = 0;
			aalp->v.aal4.mid_high = 1023;
		}

		/*
		 * Now start listening
		 */
		if ((err = atm_cm_listen(&ipatm_endpt, (void *)i,
				&ipatm_listeners[i].attr,
				&ipatm_listeners[i].conn)) != 0)
			goto done;
	}

	/*
	 * Start background VCC idle timer
	 */
	atm_timeout(&ipatm_itimer, IPATM_IDLE_TIME, ipatm_itimeout);

done:
	return (err);
}
/*
 * Initialize ipatm processing
 * 
 * This will be called during module loading.  We'll just register
 * ourselves and wait for the packets to start flying.
 *
 * Arguments:
 *	none
 *
 * Returns:
 *	0 	startup was successful 
 *	errno	startup failed - reason indicated
 *
 */
Initialize ipatm processing

This will be called during module loading.  We'll just register
ourselves and wait for the packets to start flying.

none

0       startup was successful
errno   startup failed - reason indicated
Initialize ipatm processing This will be called during module loading . We ' ll just register ourselves and wait for the packets to start flying . none 0 startup was successful errno startup failed - reason indicated
static int
ipatm_start(void)
{
	struct atm_pif	*pip;
	struct atm_nif	*nip;
	int	err, i;
	if (atm_version != ATM_VERSION) {
		log(LOG_ERR, "version mismatch: ipatm=%d.%d kernel=%d.%d\n",
			ATM_VERS_MAJ(ATM_VERSION), ATM_VERS_MIN(ATM_VERSION),
			ATM_VERS_MAJ(atm_version), ATM_VERS_MIN(atm_version));
		return (EINVAL);
	}
	err = atm_netconv_register(&ipatm_ncm);
	if (err)
		goto done;
	err = atm_endpoint_register(&ipatm_endpt);
	if (err)
		goto done;
	crit_enter();
	for (pip = atm_interface_head; pip; pip = pip->pif_next) {
		for (nip = pip->pif_nif; nip; nip = nip->nif_pnext) {
			struct ifnet    *ifp = (struct ifnet *)nip;
			struct in_ifaddr	*ia;
			struct in_ifaddr_container *iac;
			err = ipatm_nifstat(NCM_ATTACH, nip, 0);
			if (err) {
				crit_exit();
				goto done;
			}
			TAILQ_FOREACH(iac, &in_ifaddrheads[mycpuid], ia_link) {
				if (iac->ia->ia_ifp == ifp)
					break;
			}
			if (iac) {
				ia = iac->ia;
				err = ipatm_nifstat(NCM_SETADDR, nip, (int)ia);
				if (err) {
					crit_exit();
					goto done;
				}
			}
		}
	}
	crit_exit();
	ipatm_aal5llc.aal.v.aal5.forward_max_SDU_size =
		ATM_NIF_MTU + IPATM_LLC_LEN;
	ipatm_aal5llc.aal.v.aal5.backward_max_SDU_size =
		ATM_NIF_MTU + IPATM_LLC_LEN;
	ipatm_aal5llc.aal.v.aal5.SSCS_type = T_ATM_NULL;
	ipatm_aal5llc.blli.v.layer_2_protocol.ID.simple_ID = T_ATM_BLLI2_I8802;
	ipatm_aal5null.aal.v.aal5.forward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal5null.aal.v.aal5.backward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal5null.aal.v.aal5.SSCS_type = T_ATM_NULL;
	ipatm_aal4null.aal.v.aal4.forward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal4null.aal.v.aal4.backward_max_SDU_size = ATM_NIF_MTU;
	ipatm_aal4null.aal.v.aal4.SSCS_type = T_ATM_NULL;
	ipatm_aal4null.aal.v.aal4.mid_low = 0;
	ipatm_aal4null.aal.v.aal4.mid_high = 1023;
	for (i = 0;
	     i < (sizeof(ipatm_listeners) / sizeof(struct ipatm_listener));
	     i++) {
		struct attr_aal	*aalp = &ipatm_listeners[i].attr.aal;
		int	maxsdu = ATM_NIF_MTU;
		if (ipatm_listeners[i].attr.blli.tag_l2 == T_ATM_PRESENT) {
			struct t_atm_blli *bp = &ipatm_listeners[i].attr.blli.v;
			bp->layer_2_protocol.ID.simple_ID = T_ATM_BLLI2_I8802;
			maxsdu += IPATM_LLC_LEN;
		}
		if (aalp->type == ATM_AAL5) {
			aalp->v.aal5.forward_max_SDU_size = maxsdu;
			aalp->v.aal5.backward_max_SDU_size = maxsdu;
			aalp->v.aal5.SSCS_type = T_ATM_NULL;
		} else {
			aalp->v.aal4.forward_max_SDU_size = maxsdu;
			aalp->v.aal4.backward_max_SDU_size = maxsdu;
			aalp->v.aal4.SSCS_type = T_ATM_NULL;
			aalp->v.aal4.mid_low = 0;
			aalp->v.aal4.mid_high = 1023;
		}
		if ((err = atm_cm_listen(&ipatm_endpt, (void *)i,
				&ipatm_listeners[i].attr,
				&ipatm_listeners[i].conn)) != 0)
			goto done;
	}
	atm_timeout(&ipatm_itimer, IPATM_IDLE_TIME, ipatm_itimeout);
done:
	return (err);
}
static int ipatm_start ( void ) { struct atm_pif * pip ; struct atm_nif * nip ; int err , i ; if ( atm_version != ATM_VERSION ) { log ( LOG_ERR , " \n " , ATM_VERS_MAJ ( ATM_VERSION ) , ATM_VERS_MIN ( ATM_VERSION ) , ATM_VERS_MAJ ( atm_version ) , ATM_VERS_MIN ( atm_version ) ) ; return ( EINVAL ) ; } err = atm_netconv_register ( & ipatm_ncm ) ; if ( err ) goto done ; err = atm_endpoint_register ( & ipatm_endpt ) ; if ( err ) goto done ; crit_enter ( ) ; for ( pip = atm_interface_head ; pip ; pip = pip -> pif_next ) { for ( nip = pip -> pif_nif ; nip ; nip = nip -> nif_pnext ) { struct ifnet * ifp = ( struct ifnet * ) nip ; struct in_ifaddr * ia ; struct in_ifaddr_container * iac ; err = ipatm_nifstat ( NCM_ATTACH , nip , 0 ) ; if ( err ) { crit_exit ( ) ; goto done ; } TAILQ_FOREACH ( iac , & in_ifaddrheads [ mycpuid ] , ia_link ) { if ( iac -> ia -> ia_ifp == ifp ) break ; } if ( iac ) { ia = iac -> ia ; err = ipatm_nifstat ( NCM_SETADDR , nip , ( int ) ia ) ; if ( err ) { crit_exit ( ) ; goto done ; } } } } crit_exit ( ) ; ipatm_aal5llc . aal . v . aal5 . forward_max_SDU_size = ATM_NIF_MTU + IPATM_LLC_LEN ; ipatm_aal5llc . aal . v . aal5 . backward_max_SDU_size = ATM_NIF_MTU + IPATM_LLC_LEN ; ipatm_aal5llc . aal . v . aal5 . SSCS_type = T_ATM_NULL ; ipatm_aal5llc . blli . v . layer_2_protocol . ID . simple_ID = T_ATM_BLLI2_I8802 ; ipatm_aal5null . aal . v . aal5 . forward_max_SDU_size = ATM_NIF_MTU ; ipatm_aal5null . aal . v . aal5 . backward_max_SDU_size = ATM_NIF_MTU ; ipatm_aal5null . aal . v . aal5 . SSCS_type = T_ATM_NULL ; ipatm_aal4null . aal . v . aal4 . forward_max_SDU_size = ATM_NIF_MTU ; ipatm_aal4null . aal . v . aal4 . backward_max_SDU_size = ATM_NIF_MTU ; ipatm_aal4null . aal . v . aal4 . SSCS_type = T_ATM_NULL ; ipatm_aal4null . aal . v . aal4 . mid_low = 0 ; ipatm_aal4null . aal . v . aal4 . mid_high = 1023 ; for ( i = 0 ; i < ( sizeof ( ipatm_listeners ) / sizeof ( struct ipatm_listener ) ) ; i ++ ) { struct attr_aal * aalp = & ipatm_listeners [ i ] . attr . aal ; int maxsdu = ATM_NIF_MTU ; if ( ipatm_listeners [ i ] . attr . blli . tag_l2 == T_ATM_PRESENT ) { struct t_atm_blli * bp = & ipatm_listeners [ i ] . attr . blli . v ; bp -> layer_2_protocol . ID . simple_ID = T_ATM_BLLI2_I8802 ; maxsdu += IPATM_LLC_LEN ; } if ( aalp -> type == ATM_AAL5 ) { aalp -> v . aal5 . forward_max_SDU_size = maxsdu ; aalp -> v . aal5 . backward_max_SDU_size = maxsdu ; aalp -> v . aal5 . SSCS_type = T_ATM_NULL ; } else { aalp -> v . aal4 . forward_max_SDU_size = maxsdu ; aalp -> v . aal4 . backward_max_SDU_size = maxsdu ; aalp -> v . aal4 . SSCS_type = T_ATM_NULL ; aalp -> v . aal4 . mid_low = 0 ; aalp -> v . aal4 . mid_high = 1023 ; } if ( ( err = atm_cm_listen ( & ipatm_endpt , ( void * ) i , & ipatm_listeners [ i ] . attr , & ipatm_listeners [ i ] . conn ) ) != 0 ) goto done ; } atm_timeout ( & ipatm_itimer , IPATM_IDLE_TIME , ipatm_itimeout ) ; done : return ( err ) ; }
Initialize ipatm processing
Initialize ipatm processing
/*
	 * Verify software version
	 */ /*
	 * Register ourselves as a network convergence module
	 */ /*
	 * Register ourselves as an ATM endpoint
	 */ /*
	 * Get current system configuration
	 */ /*
		 * Process each network interface
		 */ /*
			 * Attach interface
			 */ /*
			 * If IP address has been set, register it
			 */ /*
	 * Fill in union fields
	 */ /*
	 * Listen for incoming calls
	 */ /*
		 * Fill in union fields
		 */ /*
		 * Now start listening
		 */ /*
	 * Start background VCC idle timer
	 */