LOCAL void NetdrvConfig(END_DEVICE *pDrvCtrl) { /* Set promiscuous mode if it's asked for. */ if (END_FLAGS_GET(&pDrvCtrl->end) & IFF_PROMISC) { PRINTF_DEBUG(("\r\nSetting promiscuous mode on!")); } else { /*VOS_printf("\r\nSetting promiscuous mode off!");*/ } /* Set up address filter for multicasting. */ if (END_MULTI_LST_CNT(&pDrvCtrl->end) > 0) { NetdrvAddrFilterSet (pDrvCtrl); } return; }
/* Call IPsec engine status callback. */ static void vxworks_va_report( VxWorksVa *va, SshVirtualAdapterError error, SshVirtualAdapterStatusCB callback, void *context) { char name[END_NAME_MAX + 4]; SshVirtualAdapterState state; ssh_snprintf(name, sizeof name, "%s", va->name); if ((END_FLAGS_GET(&va->end) & IFF_UP)) state = SSH_VIRTUAL_ADAPTER_STATE_UP; else state = SSH_VIRTUAL_ADAPTER_STATE_DOWN; if (callback) callback(error, va->ifnum, name, state, va->adapter_context, context); }
LOCAL int NetdrvIoctl(END_DEVICE * pDrvCtrl, /* device receiving command */ int cmd, /* ioctl command code */ caddr_t data /* command argument */) { int error = 0; long value; switch (cmd) { case EIOCSADDR: if (data == NULL) { return (EINVAL); } bcopy ((char *)data, (char *)END_HADDR(&pDrvCtrl->end), END_HADDR_LEN(&pDrvCtrl->end)); break; case EIOCGADDR: if (data == NULL) { return (EINVAL); } bcopy ((char *)END_HADDR(&pDrvCtrl->end), (char *)data, END_HADDR_LEN(&pDrvCtrl->end)); break; case EIOCSFLAGS: value = (long)data; if (value < 0) { value = -(--value); END_FLAGS_CLR (&pDrvCtrl->end, value); } else { END_FLAGS_SET (&pDrvCtrl->end, value); } NetdrvConfig(pDrvCtrl); break; case EIOCGFLAGS: *(int *)data = END_FLAGS_GET(&pDrvCtrl->end); break; case EIOCPOLLSTART: /* Begin polled operation */ NetdrvPollStart (pDrvCtrl); break; case EIOCPOLLSTOP: /* End polled operation */ NetdrvPollStop (pDrvCtrl); break; case EIOCGMIB2: /* return MIB information */ if(data == NULL) { return (EINVAL); } bcopy((char *)&pDrvCtrl->end.mib2Tbl, (char *)data, sizeof(pDrvCtrl->end.mib2Tbl)); break; case EIOCGFBUF: /* return minimum First Buffer for chaining */ if(data == NULL) { return (EINVAL); } *(int *)data = NETDRV_MIN_FBUF; break; default: error = EINVAL; } return (error); }
/* VA device unload handler. */ static int vxworks_va_ioctl(END_OBJ *end, int cmd, caddr_t data) { VxWorksVa *va = (void *)end; /* This function can be called from outside tNetTask. No SSH_DEBUG() here. */ switch (cmd) { case EIOCSADDR: return EINVAL; case EIOCGADDR: if (data == NULL) return EINVAL; #ifdef ETHER_ADDR_LEN memcpy(data, va->enet_addr, ETHER_ADDR_LEN); #else /* ETHER_ADDR_LEN */ memcpy(data, va->enet_addr, 6); #endif /* ETHER_ADDR_LEN */ return 0; case EIOCSFLAGS: if ((long)data < 0) END_FLAGS_CLR(&va->end, ~(long)data); else END_FLAGS_SET (&va->end, (long)data); return 0; case EIOCGFLAGS: if (data == NULL) return EINVAL; *(long *)data = END_FLAGS_GET(end); return 0; #if VXWORKS_NETVER < 55122 case EIOCGMIB2: if (data == NULL) return EINVAL; bcopy(&va->end.mib2Tbl, data, sizeof va->end.mib2Tbl); return 0; #ifdef INCLUDE_RFC_2233 case EIOCGMIB2233: if (data == NULL || va->end.pMib2Tbl == NULL) return EINVAL; *((M2_ID **)data) = va->end.pMib2Tbl; return 0; #endif /* INCLUDE_RFC_2233 */ #else /* VXWORKS_NETVER < 55122 */ case EIOCGMIB2: case EIOCGMIB2233: if (data == NULL) return EINVAL; return endM2Ioctl(&va->end, cmd, data); #endif /* VXWORKS_NETVER < 55122 */ default: return EINVAL; } }
STATUS mirrorEndRunningState(void) { BRIDGE_PORT_INFO* pPortInfo; END_OBJ *pEnd0, *pEnd1; END_MEDIA media; int error; long flags; pEnd1 = endFindByName (MIRROR_DEV_NAME,MIRROR_STACK_UNIT_NUM); pEnd0 = endFindByName (MIRROR_DEV_NAME,MIRROR_BRIDGE_UNIT_NUM); if (pEnd1) flags = END_FLAGS_GET(pEnd1); else return OK; for (pPortInfo = (BRIDGE_PORT_INFO*)lstFirst(&bridgePortList); (pPortInfo != NULL) && (strcmp(pPortInfo->name, MIRROR_DEV_NAME)!=0); pPortInfo = (BRIDGE_PORT_INFO*)lstNext((NODE*)pPortInfo)) { muxIoctl(pPortInfo->pMuxBindCookie,EIOCGIFMEDIA,(char *)&media); LOG_MSG("mirrorEndRunningState: port %s, unit %d, status 0x%x\n", pPortInfo->name, pPortInfo->unitNum, media.endMediaStatus, 4, 5, 6); if ((media.endMediaStatus & (IFM_AVALID|IFM_ACTIVE)) == (IFM_AVALID|IFM_ACTIVE)) { if ((flags & IP_IFF_RUNNING) == 0) { LOG_MSG("mirrorEndRunningState: state changed to RUNNING\n", 1, 2, 3, 4, 5, 6); /* raise both interface flags - mark the devices as RUNNING */ if (pEnd0) END_FLAGS_SET (pEnd0, IP_IFF_RUNNING); END_FLAGS_SET (pEnd1, IP_IFF_RUNNING); /* inform the stack about the interface UP state change */ jobQueueStdPost (netJobQueueId, NET_TASK_QJOB_PRI, muxLinkUpNotify, pEnd1, NULL, NULL, NULL, NULL); } return OK; } } if (flags & IP_IFF_RUNNING) { LOG_MSG("mirrorEndRunningState: state changed to NOT RUNNING\n", 1, 2, 3, 4, 5, 6); /* mark both drivers as NOT RUNNING */ if (pEnd0) END_FLAGS_CLR (pEnd0, IP_IFF_RUNNING); END_FLAGS_CLR (pEnd1, IP_IFF_RUNNING); /* inform the stack about the interface UP state change */ jobQueueStdPost (netJobQueueId, NET_TASK_QJOB_PRI, muxLinkDownNotify, pEnd1, NULL, NULL, NULL, NULL); } return OK; }
LOCAL int mirrorEndIoctl ( END_CTRL* pDrvCtrl, int cmd, caddr_t data ) { int error = 0; long value; END_OBJ* pEndObj = &pDrvCtrl->endObject; END_MEDIA * pMedia; switch ((UINT)cmd) { case EIOCSADDR: if (data == NULL) { error = EINVAL; } else { bcopy((char*)data, (char*)END_HADDR(pEndObj), END_HADDR_LEN(pEndObj)); } break; case EIOCGADDR: if (data == NULL) { error = EINVAL; } else { bcopy((char*)END_HADDR(pEndObj), (char*)data, END_HADDR_LEN(pEndObj)); } break; case EIOCSFLAGS: value = (long)data; if (value < 0) { value = -value; value--; END_FLAGS_CLR(pEndObj, value); } else { END_FLAGS_SET(pEndObj, value); } if (END_FLAGS_GET(pEndObj) & IP_IFF_PROMISC) { pDrvCtrl->promiscuous = TRUE; } else { pDrvCtrl->promiscuous = FALSE; } break; case EIOCGFLAGS: if (data == NULL) { error = EINVAL; } else { *(int*)data = END_FLAGS_GET(pEndObj); } break; case EIOCGIFMEDIA: if (data == NULL) error = EINVAL; else { value = END_FLAGS_GET(pEndObj); pMedia = (END_MEDIA *)data; pMedia->endMediaActive = IFM_AVALID; pMedia->endMediaStatus = IFM_AVALID; if (value & IP_IFF_RUNNING) { LOG_MSG("ioctl with EIOCGIFMEDIA, set active bit \n", 1, 2, 3, 4, 5, 6); pMedia->endMediaStatus |= IFM_ACTIVE; } else { LOG_MSG("ioctl with EIOCGIFMEDIA, clear active bit \n", 1, 2, 3, 4, 5, 6); pMedia->endMediaStatus &= ~IFM_ACTIVE; } } break; case EIOCPOLLSTART: error = mirrorEndPollStart(pDrvCtrl); break; case EIOCPOLLSTOP: error = mirrorEndPollStop(pDrvCtrl); break; case EIOCGMIB2: if (data == NULL) { error = EINVAL; } else { bcopy((char*)&pDrvCtrl->endObject.mib2Tbl, (char*)data, sizeof(pDrvCtrl->endObject.mib2Tbl)); } break; case EIOCGFBUF: if (data == NULL) { error = EINVAL; } else { *(int*)data = LENGTH_MIN_FBUF; } break; default: error = EINVAL; break; } return error; }