EMail::EMail(Node *parent, const char *name, Node::Type type, bool mandatory) : Node(parent, name, type, mandatory), _id(this, "id", Node::ATTRIBUTE, true), _domain(this, "domain", Node::ATTRIBUTE, true) { getInterfaces().push_back(&_id); getInterfaces().push_back(&_domain); }
void InstantiationList::run() { for (auto iter = getInterfaces()->begin(); iter != getInterfaces()->end(); iter++) { (*iter)->check(); } delete getInterfaces(); }
Bounds::Bounds(Node *parent, const char *name, Node::Type type, bool mandatory) : Node(parent, name, type, mandatory), _minlat(this, "minlat", Node::ATTRIBUTE, true), _minlon(this, "minlon", Node::ATTRIBUTE, true), _maxlat(this, "maxlat", Node::ATTRIBUTE, true), _maxlon(this, "maxlon", Node::ATTRIBUTE, true) { getInterfaces().push_back(&_minlat); getInterfaces().push_back(&_minlon); getInterfaces().push_back(&_maxlat); getInterfaces().push_back(&_maxlon); }
QString NetworkInterface::getFirstWiredDevice() { QString tmp; QStringList ifs = getInterfaces(); for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it ) { // List of devices to exclude not real ethernet QString tmpDev = *it; if (tmpDev.indexOf("lo0") == -1 && tmpDev.indexOf("lagg") == -1 && tmpDev.indexOf("lo1") == -1 && tmpDev.indexOf("lo2") == -1 && tmpDev.indexOf("lo3") == -1 && tmpDev.indexOf("fwe") == -1 && tmpDev.indexOf("plip") == -1 && tmpDev.indexOf("pfsync") == -1 && tmpDev.indexOf("pflog") == -1 && tmpDev.indexOf("ipfw") == -1 && tmpDev.indexOf("tun") == -1 && tmpDev.indexOf("usbus") == -1 && tmpDev.indexOf("vboxnet") == -1 && tmpDev.indexOf("wlan") == -1 ) { NetworkInterface ifr(tmpDev); if (! ifr.isWireless()) { return tmpDev; } } } return tmp; }
bool ClassInfo::derivesFromImpl(const char *name, bool considerInterface) const { if (strcasecmp(name, getParentClass()) == 0) { return true; } // We don't support redeclared parents anyway. const ClassInfo *parent = FindClass(getParentClass()); if (parent && parent->derivesFromImpl(name, considerInterface)) { return true; } if (considerInterface) { const InterfaceMap &interfaces = getInterfaces(); for (InterfaceMap::const_iterator iter = interfaces.begin(); iter != interfaces.end(); ++iter) { if (strcasecmp(name, *iter) == 0) { return true; } const ClassInfo *parent = FindInterface(*iter); if (parent && parent->derivesFromImpl(name, considerInterface)) { return true; } } } return false; }
//When the block turns, it waits TURN_TIME before being able to notice another turn. void turn_task(void* parameters){ for(;;){ xSemaphoreTake(turnSemaphore,portMAX_DELAY); vTaskDelay(TURN_TIME); awareOfTurn = NOT_AWARE; saveOfMyInterfaces = getInterfaces(); } }
/* Returns 1 if one of the interfaces has the given IP */ int hasInterface(uchar *ip) { uchar interfaces[MAX_INTERFACES][4]; int numInterfaces = getInterfaces(interfaces); int i; for (i = 0; i < numInterfaces; i++) { if (!COMPARE_IP(interfaces[i], ip)) return 1; } return 0; }
ComponentInterface *SimComponent::getInterface(const char *type /* = NULL */, const char *name /* = NULL */, const SimComponent *owner /* = NULL */, bool notOwner /* = false */) { ComponentInterfaceList iLst; if( getInterfaces( &iLst, type, name, owner, notOwner ) ) return iLst[0]; return NULL; }
extern "C" void moduleGenerate(int fileDescriptor, std::map<std::string, std::string> postVars) { getInterfaces(); FILE *fp; fp = fdopen(fileDescriptor, "w"); assert(fp != NULL); doAction(postVars); fprintf(fp, "<!DOCTYPE html><html><head><meta http-equiv=\"refresh\" content=\"0; url=/interfaces\"></head></html>"); fflush(fp); }
TRK::TRK(Node *parent, const char *name, Node::Type type, bool mandatory) : Node(parent, name, type, mandatory), _name(this, "name", Node::ELEMENT, false), _cmt(this, "cmt", Node::ELEMENT, false), _desc(this, "desc", Node::ELEMENT, false), _src(this, "src", Node::ELEMENT, false), _number(this, "number", Node::ELEMENT, false), _type(this, "type", Node::ELEMENT, false), _extensions(this, "extensions", Node::ELEMENT, false), _trksegs(this, "trkseg", Node::ELEMENT, false), _links(this, "link", Node::ELEMENT, false) { getInterfaces().push_back(&_name); getInterfaces().push_back(&_cmt); getInterfaces().push_back(&_desc); getInterfaces().push_back(&_src); getInterfaces().push_back(&_number); getInterfaces().push_back(&_type); getInterfaces().push_back(&_extensions); getInterfaces().push_back(&_trksegs); getInterfaces().push_back(&_links); }
void UnresolvedNhopsProber::timeoutExpired() noexcept { std::lock_guard<std::mutex> g(lock_); auto state = sw_->getState(); for (const auto& ridAndNhopsRefCounts : nhops2RouteCount_) { for (const auto& nhopAndRefCount : ridAndNhopsRefCounts.second) { const auto& nhop = nhopAndRefCount.first; auto intf = state->getInterfaces()->getInterfaceIf(nhop.intf); if (!intf) { continue; // interface got unconfigured } // Probe all nexthops for which either don't have a L2 entry // or the entry is not resolved (port == 0). Note that we do // not exclude pending entries here since in case of recursive // routes we might get packets with destination set to prefix // that needs to be resolved recursively. In ARP and NDP code // we do not do route lookup when deciding to send ARP/NDP requests. // So we would only try to ARP/NDP for the destination if it // is in one of the interface subnets (which it won't be else // we won't have needed recursive resolution). So ARP/NDP for // all unresolved next hops. We could also consider doing route // lookups in ARP/NDP code, but by probing all unresolved next // hops we effectively do the same thing, since the next hops // probed come from after the route was (recursively) resolved. auto vlan = state->getVlans()->getVlanIf(intf->getVlanID()); CHECK(vlan); // must have vlan for configrued inteface if (nhop.nexthop.isV4()) { auto nhop4 = nhop.nexthop.asV4(); auto arpEntry = vlan->getArpTable()->getEntryIf(nhop4); if (!arpEntry || arpEntry->getPort() == 0) { VLOG(2) <<" Sending probe for unresolved next hop: " << nhop4; ArpHandler::sendArpRequest(sw_, vlan, nhop4); } } else { auto nhop6 = nhop.nexthop.asV6(); auto ndpEntry = vlan->getNdpTable()->getEntryIf(nhop6); if (!ndpEntry || ndpEntry->getPort() == 0) { VLOG(2) <<" Sending probe for unresolved next hop: " << nhop6; IPv6Handler::sendNeighborSolicitation(sw_, nhop6, vlan); } } } } scheduleTimeout(interval_); }
int CNetscapeFontModule::InitFontModule( ) { if( m_fontModuleStatus != FMSTATUS_NULL ) return( FONTERR_OK ); // already initialized if( createObjects() ) return( FONTERR_CreateObjectFail ); if ( getInterfaces() ) return( FONTERR_GetInterfacesFail ); if ( registerFontDisplayer() ) return( FONTERR_RegisterFontDisplayerFail ); m_fontModuleStatus = FMSTATUS_IntialOK; // create the RC object m_workingRC = convertDC(NULL); return( FONTERR_OK ); }
void PureClientContext::m_connectNeededCallbacks() { std::unordered_set<std::string> failedPaths; size_t successfulPaths{0}; for (auto const &iface : getInterfaces()) { /// @todo slightly overkill, but it works - tree traversal would be /// better. auto path = iface->getPath(); /// For every interface, if there's no handler at that path on the /// interface tree, try to set one up. if (!m_interfaces.getHandlerForPath(path)) { auto success = m_connectCallbacksOnPath(path); if (success) { successfulPaths++; } else { failedPaths.insert(path); } } } OSVR_DEV_VERBOSE("Connected " << successfulPaths << " of " << successfulPaths + failedPaths.size() << " unconnected paths successfully"); }
GPX::GPX() : Node(nullptr, "gpx", Node::ELEMENT, true), _version(this, "version", Node::ATTRIBUTE, true), _creator(this, "creator", Node::ATTRIBUTE, true), _metadata(this, "metadata", Node::ELEMENT, false), _extensions(this, "extensions", Node::ELEMENT, false), _wpts(this, "wpt", Node::ELEMENT, false), _rtes(this, "rte", Node::ELEMENT, false), _trks(this, "trk", Node::ELEMENT, false) { getInterfaces().push_back(&_version); getInterfaces().push_back(&_creator); getInterfaces().push_back(&_metadata); getInterfaces().push_back(&_extensions); getInterfaces().push_back(&_wpts); getInterfaces().push_back(&_rtes); getInterfaces().push_back(&_trks); }
int MprSocketService::start() { Mpr *mpr; char hostName[MPR_MAX_IP_NAME]; char serverName[MPR_MAX_IP_NAME]; char domainName[MPR_MAX_IP_NAME]; char *dp; mpr = mprGetMpr(); serverName[0] = '\0'; domainName[0] = '\0'; hostName[0] = '\0'; if (gethostname(serverName, sizeof(serverName)) < 0) { mprStrcpy(serverName, sizeof(serverName), "localhost"); mprError(MPR_L, MPR_USER, "Can't get host name"); // Keep going } if ((dp = strchr(serverName, '.')) != 0) { mprStrcpy(hostName, sizeof(hostName), serverName); *dp++ = '\0'; mprStrcpy(domainName, sizeof(domainName), dp); } else { mprStrcpy(hostName, sizeof(hostName), serverName); } lock(); mpr->setServerName(serverName); mpr->setDomainName(domainName); mpr->setHostName(hostName); #if DEPRECATED getInterfaces(); #endif unlock(); return 0; }
static long device_ioctl(struct file *file, /* see include/linux/fs.h */ unsigned int ioctl_num, /* number for ioctl */ char* buf, /* bufor od usera, tutaj zapiszemy wiadomosc */ int interface_usr, /* nazwa interfejsu */ int anotherp ) { char bufor2[ROZ]; int len=0; /* * Switch according to the ioctl called */ switch (ioctl_num) { case IOCTL_GET_IFS: { len=0; len=getInterfaces(bufor2); copy_to_user(buf,bufor2,len+1); break; } case IOCTL_GET_INF: { len=0; len=getInfo(bufor2,"enp2s0",1); copy_to_user(buf,bufor2,len+1); break; } } return 0; }
WPT::WPT(Node *parent, const char *name, Node::Type type, bool mandatory) : Node(parent, name, type, mandatory), _lat(this, "lat", Node::ATTRIBUTE, true), _lon(this, "lon", Node::ATTRIBUTE, true), _ele(this, "ele", Node::ELEMENT, false), _time(this, "time", Node::ELEMENT, false), _magvar(this, "magvar", Node::ELEMENT, false), _geoidheight(this, "geoidheight", Node::ELEMENT, false), _name(this, "name", Node::ELEMENT, false), _cmt(this, "cmt", Node::ELEMENT, false), _desc(this, "desc", Node::ELEMENT, false), _src(this, "src", Node::ELEMENT, false), _sym(this, "sym", Node::ELEMENT, false), _type(this, "type", Node::ELEMENT, false), _fix(this, "fix", Node::ELEMENT, false), _sat(this, "sat", Node::ELEMENT, false), _hdop(this, "hdop", Node::ELEMENT, false), _vdop(this, "vdop", Node::ELEMENT, false), _pdop(this, "pdop", Node::ELEMENT, false), _ageofdgpsdata(this, "ageofdgpsdata", Node::ELEMENT, false), _dgpsid(this, "dgpsid", Node::ELEMENT, false), _links(this, "link", Node::ELEMENT, false) { getInterfaces().push_back(&_lat); getInterfaces().push_back(&_lon); getInterfaces().push_back(&_ele); getInterfaces().push_back(&_time); getInterfaces().push_back(&_magvar); getInterfaces().push_back(&_geoidheight); getInterfaces().push_back(&_name); getInterfaces().push_back(&_cmt); getInterfaces().push_back(&_desc); getInterfaces().push_back(&_src); getInterfaces().push_back(&_sym); getInterfaces().push_back(&_type); getInterfaces().push_back(&_fix); getInterfaces().push_back(&_sat); getInterfaces().push_back(&_hdop); getInterfaces().push_back(&_vdop); getInterfaces().push_back(&_pdop); getInterfaces().push_back(&_ageofdgpsdata); getInterfaces().push_back(&_dgpsid); getInterfaces().push_back(&_links); }
//Function to notice the turn of the block. void turn_function(uint8_t neighbor, uint8_t membersInHisNetwork, uint8_t interface, uint8_t hisInterface){ int8_t rotation ; int oldInterface; int hasLeft; //The first interface to notify the change of interfaces will save the interfaces. if(awareOfTurn == NOT_AWARE){ awareOfTurn = AWARE; xSemaphoreGive(turnSemaphore); if(ID_in_interfaces(neighbor)) saveOfMyInterfaces = getInterfaces(); else if(ID_was_in_interfaces(neighbor)){ saveOfMyInterfaces = getSavedInterfaces(); } //Shouldn't be here. else return; } //Two options: //He was in our network few times ago. (really few) if(ID_in_interfaces(neighbor)){ oldInterface = interface_where_is_neighbor(neighbor,1); hasLeft = 0; } //He quitted and then came again. else{ oldInterface = interface_where_is_neighbor(neighbor, 0); hasLeft = 1; } //Changing the old interface if(oldInterface != -1){ setInterface(oldInterface, -1,-1); } //Setting the new parameters to this interface. setInterface(interface, neighbor, hisInterface); //Again, the first interface to notify will calculate the rotation. if(awareOfTurn == AWARE){ awareOfTurn = AWARE_AND_CHECK; //Calculate differences between the interfaces and the saved ones. rotation = interfaces_turn(saveOfMyInterfaces, getInterfaces() ); //The block has left so we decide if we need an election. if(hasLeft){ ping_decision(neighbor, membersInHisNetwork, interface); } if(rotation > 0){ // if it's 180 degre rotation then give the semaphore wich wil be used by the switcher in manager.c if((rotation!=1) && (rotation!=3) ) xSemaphoreGive(turn180Semaphore); else turn_send(rotation); } else if(rotation == 0){ } else{ //Maybe another interface will change in few times //So, we wait and check again. vTaskDelay(3*PING_ACK_TIME); rotation = interfaces_turn(saveOfMyInterfaces, getInterfaces()); if(rotation > 0){ if((rotation!=1) && (rotation!=3) ) xSemaphoreGive(turn180Semaphore); else turn_send(rotation); } } } }
void InstantiationList::add(InstantiateInterface* _interface) { getInterfaces()->push_back(_interface); }
EXPORT int MM_hs_blink(int action, Imodman *mm_, Arena *arena) { if (action == MM_LOAD) { mm = mm_; getInterfaces(); if (!checkInterfaces()) { releaseInterfaces(); return MM_FAIL; } adkey = aman->AllocateArenaData(sizeof(struct ArenaData)); pdkey = pd->AllocatePlayerData(sizeof(struct PlayerData)); if (adkey == -1 || pdkey == -1) //Memory check { if (adkey != -1) //free data if it was allocated aman->FreeArenaData(adkey); if (pdkey != -1) //free data if it was allocated pd->FreePlayerData (pdkey); releaseInterfaces(); return MM_FAIL; } return MM_OK; } else if (action == MM_UNLOAD) { aman->FreeArenaData(adkey); pd->FreePlayerData(pdkey); releaseInterfaces(); return MM_OK; } else if (action == MM_ATTACH) { ArenaData *adata = getArenaData(arena); if (adata->attached) return MM_FAIL; readConfig(arena); //Add Command(s) cmd->AddCommand("blink", Cblink, arena, Cblink_help); //Register Callback(s) mm->RegCallback(CB_PPK, PPKCB, arena); mm->RegCallback(CB_ARENAACTION, arenaActionCB, arena); mm->RegCallback(CB_ITEMS_CHANGED, itemsChangedCB, arena); mm->RegCallback(CB_SHIPFREQCHANGE, shipFreqChangeCB, arena); adata->attached = true; return MM_OK; } else if (action == MM_DETACH) { ArenaData *adata = getArenaData(arena); if (!adata->attached) return MM_FAIL; //Remove Command(s) cmd->RemoveCommand("blink", Cblink, arena); //Unregister Callback(s) mm->UnregCallback(CB_PPK, PPKCB, arena); mm->UnregCallback(CB_ARENAACTION, arenaActionCB, arena); mm->UnregCallback(CB_ITEMS_CHANGED, itemsChangedCB, arena); mm->UnregCallback(CB_SHIPFREQCHANGE, shipFreqChangeCB, arena); adata->attached = false; return MM_OK; } return MM_FAIL; }
void IPv4Handler::handlePacket(unique_ptr<RxPacket> pkt, MacAddress dst, MacAddress src, Cursor cursor) { SwitchStats* stats = sw_->stats(); PortID port = pkt->getSrcPort(); const uint32_t l3Len = pkt->getLength() - (cursor - Cursor(pkt->buf())); stats->port(port)->ipv4Rx(); IPv4Hdr v4Hdr(cursor); VLOG(4) << "Rx IPv4 packet (" << l3Len << " bytes) " << v4Hdr.srcAddr.str() << " --> " << v4Hdr.dstAddr.str() << " proto: 0x" << std::hex << static_cast<int>(v4Hdr.protocol); // retrieve the current switch state auto state = sw_->getState(); // Need to check if the packet is for self or not. We store our IP // in the ARP response table. Use that for now. auto vlan = state->getVlans()->getVlanIf(pkt->getSrcVlan()); if (!vlan) { stats->port(port)->pktDropped(); return; } if (v4Hdr.protocol == IPPROTO_UDP) { Cursor udpCursor(cursor); UDPHeader udpHdr; udpHdr.parse(sw_, port, &udpCursor); VLOG(4) << "UDP packet, Source port :" << udpHdr.srcPort << " destination port: " << udpHdr.dstPort; if (DHCPv4Handler::isDHCPv4Packet(udpHdr)) { DHCPv4Handler::handlePacket(sw_, std::move(pkt), src, dst, v4Hdr, udpHdr, udpCursor); return; } } auto dstIP = v4Hdr.dstAddr; // Handle packets destined for us // TODO: assume vrf 0 now if (state->getInterfaces()->getInterfaceIf(RouterID(0), IPAddress(dstIP))) { // TODO: Also check to see if this is the broadcast address for one of the // interfaces on this VLAN. We should probably build up a more efficient // data structure to look up this information. stats->port(port)->ipv4Mine(); // Anything not handled by the controller, we will forward it to the host, // i.e. ping, ssh, bgp... // FixME: will do another diff to set length in RxPacket, so that it // can be reused here. if (sw_->sendPacketToHost(std::move(pkt))) { stats->port(port)->pktToHost(l3Len); } else { stats->port(port)->pktDropped(); } return; } // if packet is not for us, check the ttl exceed if (v4Hdr.ttl <= 1) { VLOG(4) << "Rx IPv4 Packet with TTL expired"; stats->port(port)->pktDropped(); stats->port(port)->ipv4TtlExceeded(); // Look up cpu mac from platform MacAddress cpuMac = sw_->getPlatform()->getLocalMac(); sendICMPTimeExceeded(pkt->getSrcVlan(), cpuMac, cpuMac, v4Hdr, cursor); return; } // Handle broadcast packets. // TODO: Also check to see if this is the broadcast address for one of the // interfaces on this VLAN. We should probably build up a more efficient // data structure to look up this information. if (dstIP.isLinkLocalBroadcast()) { stats->port(port)->pktDropped(); return; } // TODO: check the reason of punt, for now, assume it is for // resolving the address // We will need to manage the rate somehow. Either from HW // or a SW control here stats->port(port)->ipv4Nexthop(); if (!resolveMac(state.get(), dstIP)) { stats->port(port)->ipv4NoArp(); VLOG(3) << "Cannot find the interface to send out ARP request for " << dstIP.str(); } // TODO: ideally, we need to store this packet until the ARP is done and // then send this pkt out. For now, just drop it. stats->port(port)->pktDropped(); }
EXPORT int MM_suicides(int action, Imodman *mm_, Arena *arena) { Link *link; Player *p; ad_suicides *adata; switch(action) { case MM_LOAD: mm = mm_; getInterfaces(mm); if(!aman || !game || !lm || !wd || !kill || !pd) { releaseInterfaces(mm); return MM_FAIL; } adkey = aman->AllocateArenaData(sizeof(ad_suicides)); return MM_OK; case MM_UNLOAD: releaseInterfaces(mm); return MM_OK; case MM_ATTACH: adata = P_ARENA_DATA(arena, adkey); // Register callbacks for the arena... mm->RegCallback(CB_PLAYERACTION, player_action, arena); mm->RegCallback(CB_PLAYERDAMAGE, player_damaged, arena); // Create killer... if(!adata->killer) adata->killer = kill->LoadKiller(KILLER_NAME, arena, SHIP_SHARK, 9999); // Turn on damage monitoring for everyone in the arena... pd->Lock(); for(link = LLGetHead(&pd->playerlist); link && (p = link->data); link = link->next) { if(p->arena == arena && IS_STANDARD(p)) { wd->ModuleWatch(p, 1); } } pd->Unlock(); // Register adviser for the arena... mm->RegAdviser(&kill_adviser, arena); // Set attached flag... adata->attached = 1; return MM_OK; case MM_DETACH: adata = P_ARENA_DATA(arena, adkey); // Clear attached flag... adata->attached = 0; // Turn off damage monitoring... pd->Lock(); for(link = LLGetHead(&pd->playerlist); link && (p = link->data); link = link->next) { if(p->arena == arena && IS_STANDARD(p)) wd->ModuleWatch(p, 0); } pd->Unlock(); // Remove killer if necessary (again, should be)... if(adata->killer) { kill->UnloadKiller(adata->killer); adata->killer = 0; } // Release callbacks... mm->UnregCallback(CB_PLAYERACTION, player_action, arena); mm->UnregCallback(CB_PLAYERDAMAGE, player_damaged, arena); // Release adviser... mm->UnregAdviser(&kill_adviser, arena); return MM_OK; } return MM_FAIL; }