muxIoctl(AtmSrvCtrl[unit].pCookie, EIOCGFLAGS, (caddr_t)&flags);
pIfp->if_flags = flags;
if (muxIoctl(AtmSrvCtrl[unit].pCookie, EIOCGMIB2, (caddr_t)&mib2Tbl) == ERROR)
return (ERROR);
pIfp->if_mtu = mib2Tbl.ifMtu;
pIfp->if_baudrate = mib2Tbl.ifSpeed;
pIfp->if_type = mib2Tbl.ifType;
pIfp->if_addrlen = mib2Tbl.ifPhysAddress.addrLength;
pIfp->if_flags |= IFF_BROADCAST;
if (muxIoctl (AtmSrvCtrl[unit].pCookie, EIOCGHDRLEN, (caddr_t)&ifHdrLen)!= OK)
pIfp->if_hdrlen = 0;
else
pIfp->if_hdrlen = (UCHAR)ifHdrLen;
pIfp->if_init = NULL;
pIfp->if_ioctl = ifIoCtrl;
/* 在这里定义该协议类型报文发送时要调用的处理函数 */
pIfp->if_output = AtmSrv1483RoutedService;
pIfp->if_reset = NULL;
pIfp->pCookie = AtmSrvCtrl[unit].pCookie;
pIfp->if_resolve = NULL;
pIfp->if_flags |= (IFF_UP | IFF_RUNNING | IFF_NOTRAILERS | IFF_NOARP);
if(atmif[unit].ifp)
if_dettach(atmif[unit].ifp);
/* 向 MUX 层注册该 Service */
if_attach (pIfp);
6.2.2 Service 数据结构初始化
我们定义 AAL5 业务网络服务子层的数据结构如下:
typedef struct atm_srv_ctrl
{
int tLinkType; /* 定义协议类型*/
int encapLength; /* 定义该协议封装用的 PDU 大小*/
char encapData[50]; /* 该协议使用的 PDU 内容 */
END_OBJ * pCookie; /* 底层设备驱动单元索引 */
struct ifnet ifp; /* 注册后返回的网络服务子层索引*/
}ATM_SRV_CTRL;
其中:
tLinkType 定义的协议类型主要有RFC1483Bridged, RFC1483Routed, ATMARP,PPPOA,PPPOE等。在 atmifAttach 例程中,就是将该值作为协议类型参数调用 muxBind 函数的。