static int lua_lwip_init(lua_State * L) { struct ip_addr ip; struct ip_addr mask; struct ip_addr gw; int res = -1; /* IP4_ADDR(&ip, 192, 168, 1, 9); */ /* IP4_ADDR(&mask, 255, 255, 255, 0); */ /* IP4_ADDR(&gw, 192, 168, 1, 2); */ if ( lua_tostring(L, 1)==NULL || dns(lua_tostring(L, 1), &ip) || lua_tostring(L, 2)==NULL || dns(lua_tostring(L, 2), &mask) || lua_tostring(L, 3)==NULL || dns(lua_tostring(L, 3), &gw) ) { printf("Syntax error : try net_lwip_init your.ip.add.ress 255.255.255.0 your.gate.way.ip\n"); lua_pushstring(L, "Syntax error : try net_lwip_init your.ip.add.ress 255.255.255.0 your.gate.way.ip\n"); return 1; } if (!lwipinit) { //lwip_init_mac(); res = lwip_init_all_static(&ip, &mask, &gw); //lwip_init_common("test"); //lwip_init_all(); lwip_cb = net_input_target; net_input_set_target(rx_callback); tcpfs_init() || httpfs_init(); lwipinit = 1; } else { struct netif *netif; // just change ip configuration of interface netif = netif_find("kn0"); if (!netif) return 0; printf("resetting IP of kn0 interface\n"); memcpy(&netif->ip_addr, &ip, sizeof(ip)); memcpy(&netif->netmask, &mask, sizeof(ip)); memcpy(&netif->gw, &gw, sizeof(ip)); } return 0; }
void Quad1MindlinShell3D :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui) { FloatArray n, ns; FloatMatrix dn, dns; const FloatArray &localCoords = * gp->giveNaturalCoordinates(); this->interp.evaldNdx( dn, localCoords, FEIVertexListGeometryWrapper(lnodes) ); this->interp.evalN( n, localCoords, FEIVoidCellGeometry() ); answer.resize(8, 4 * 5); answer.zero(); // enforce one-point reduced integration if requested if ( this->reducedIntegrationFlag ) { FloatArray lc(2); lc.zero(); // set to element center coordinates this->interp.evaldNdx( dns, lc, FEIVertexListGeometryWrapper(lnodes) ); this->interp.evalN( ns, lc, FEIVoidCellGeometry() ); } else { dns = dn; ns = n; } // Note: This is just 5 dofs (sixth column is all zero, torsional stiffness handled separately.) for ( int i = 0; i < 4; ++i ) { ///@todo Check the rows for both parts here, to be consistent with _3dShell material definition // Part related to the membrane (columns represent coefficients for D_u, D_v) answer(0, 0 + i * 5) = dn(i, 0);//eps_x = du/dx answer(1, 1 + i * 5) = dn(i, 1);//eps_y = dv/dy answer(2, 0 + i * 5) = dn(i, 1);//gamma_xy = du/dy+dv/dx answer(2, 1 + i * 5) = dn(i, 0); // Part related to the plate (columns represent the dofs D_w, R_u, R_v) ///@todo Check sign here answer(3 + 0, 2 + 2 + i * 5) = dn(i, 0);// kappa_x = d(fi_y)/dx answer(3 + 1, 2 + 1 + i * 5) =-dn(i, 1);// kappa_y = -d(fi_x)/dy answer(3 + 2, 2 + 2 + i * 5) = dn(i, 1);// kappa_xy=d(fi_y)/dy-d(fi_x)/dx answer(3 + 2, 2 + 1 + i * 5) =-dn(i, 0); // shear strains answer(3 + 3, 2 + 0 + i * 5) = dns(i, 0);// gamma_xz = fi_y+dw/dx answer(3 + 3, 2 + 2 + i * 5) = ns(i); answer(3 + 4, 2 + 0 + i * 5) = dns(i, 1);// gamma_yz = -fi_x+dw/dy answer(3 + 4, 2 + 1 + i * 5) = -ns(i); } }
void tst_QDnsLookup_Appless::destroyApplicationDuringLookup() { int argc = 0; char **argv = 0; for (int i = 0; i < 10; ++i) { QCoreApplication app(argc, argv); QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.info"); dns.lookup(); } }
/* return zero if error */ static uint32 open(const char *uri, int flags, int udp) { char hostname[128]; char options[128]; int port; TCPContext *s; int sock = -1; struct sockaddr_in sa; int res; //h->is_streamed = 1; if (flags & O_DIR) return 0; s = malloc(sizeof(TCPContext)); if (!s) { return 0; } /* fill the dest addr */ /* needed in any case to build the host string */ url_split(NULL, 0, hostname, sizeof(hostname), &port, options, sizeof(options), uri); if (port < 0) port = 80; // printf("TCP : addr '%s' port %d\n", hostname, port); sa.sin_family = AF_INET; sa.sin_port = htons(port); if (dns(hostname, &sa.sin_addr.s_addr)) goto fail; sock = socket(PF_INET, udp? SOCK_DGRAM:SOCK_STREAM, 0); if (sock < 0) goto fail; res = connect(sock, &sa, sizeof(sa)); //printf("connect --> %d\n", res); if (res) goto fail; s->socket = sock; s->pos = 0; s->stream = strstr(options, "<stream>"); return (uint32) s; fail: if (sock >= 0) close(sock); free(s); return 0; }
boost::asio::ip::tcp::endpoint dns(boost::asio::yield_context yc, boost::system::error_code& ec, boost::asio::ip::tcp::resolver& resolver, std::string address, std::string port) { auto it = dns(yc[ec], resolver, address, port); if (ec) return boost::asio::ip::tcp::endpoint(); return *it; }
void start_http_client(sp_uint32 _port, sp_uint64 _requests, sp_uint32 _nkeys) { port = _port; ntotal = _requests; nkeys = _nkeys; EventLoopImpl ss; AsyncDNS dns(&ss); HTTPClient client(&ss, &dns); SendRequest(&client); ss.loop(); }
void Quad1Mindlin :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui) // Returns the [5x9] strain-displacement matrix {B} of the receiver, // evaluated at gp. { FloatArray n, ns; FloatMatrix dn, dns; this->interp_lin.evaldNdx( dn, * gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(this) ); this->interp_lin.evalN( n, * gp->giveNaturalCoordinates(), FEIElementGeometryWrapper(this) ); answer.resize(5, 12); answer.zero(); // enforce one-point reduced integration if requested if ( this->reducedIntegrationFlag ) { FloatArray lc(2); lc.zero(); // set to element center coordinates this->interp_lin.evaldNdx( dns, lc, FEIElementGeometryWrapper(this)); this->interp_lin.evalN( ns, lc, FEIElementGeometryWrapper(this)); } else { dns = dn; ns = n; } ///@todo Check sign here for ( int i = 0; i < 4; ++i ) { answer(0, 2 + i * 3) = dn(i, 0); // kappa_x = d(fi_y)/dx answer(1, 1 + i * 3) = -dn(i, 1); // kappa_y = -d(fi_x)/dy answer(2, 2 + i * 3) = dn(i, 1); // kappa_xy=d(fi_y)/dy-d(fi_x)/dx answer(2, 1 + i * 3) = -dn(i, 0); answer(3, 0 + i * 3) = dns(i, 0); // gamma_xz = fi_y+dw/dx answer(3, 2 + i * 3) = ns(i); answer(4, 0 + i * 3) = dns(i, 1);// gamma_yz = -fi_x+dw/dy answer(4, 1 + i * 3) = -ns(i); } }
static int lua_resolv(lua_State * L) { dnssrv.sin_port = 0; if (dns(lua_tostring(L, 1), &dnssrv.sin_addr.s_addr)) { printf("Syntax error : try net_resolv your.dns.add.ress\n"); return 0; } dnssrv.sin_family = AF_INET; dnssrv.sin_port = htons(53); printf("DNS server address set to '%s'\n", lua_tostring(L, 1)); return 0; }
void tst_Q3Dns::simpleLookup() { // Stuff int c = 0; char **v = 0; QCoreApplication a(c, v); Q3Dns dns("qt.nokia.com"); QSignalSpy spy(&dns, SIGNAL(resultsReady())); connect(&dns, SIGNAL(resultsReady()), this, SLOT(simpleLookupDone())); QTestEventLoop::instance().enterLoop(5); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); QCOMPARE(spy.count(), 1); }
Net::Net(){ // Initialize Ethernet byte mac[]={ 0x90, 0xA2, 0xDA, 0x0D, 0x02, 0xD0 }; IPAddress ip(192,168,1, 77); IPAddress dns(192,168,1, 1); IPAddress gateway(192,168,1, 1); IPAddress subnet(255,255,255,0); Ethernet.begin(mac, ip, dns, gateway, subnet); // Processors processor=NULL; processorCount=0; // Enable interrupts EthernetInterrupt::begin(0); }
void tst_QDnsLookup_Appless::recreateApplication() { int argc = 0; char **argv = 0; for (int i = 0; i < 10; ++i) { QCoreApplication app(argc, argv); QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); dns.lookup(); if (!dns.isFinished()) { QObject::connect(&dns, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(10); } QVERIFY(dns.isFinished()); } }
void ControlTopology(sp_string topology_id, sp_int32 port, bool activate) { EventLoopImpl ss; AsyncDNS dns(&ss); HTTPClient* client = new HTTPClient(&ss, &dns); HTTPKeyValuePairs kvs; kvs.push_back(make_pair("topologyid", topology_id)); sp_string requesturl = activate ? "/activate" : "/deactivate"; OutgoingHTTPRequest* request = new OutgoingHTTPRequest(LOCALHOST, port, requesturl, BaseHTTPRequest::GET, kvs); auto cb = [client](IncomingHTTPResponse* response) { ControlTopologyDone(client, response); }; if (client->SendRequest(request, std::move(cb)) != SP_OK) { FAIL() << "Unable to send the request\n"; } ss.loop(); }
bool GetFromDnsCache(const std::string& name, NetworkAddr& addr) { ScopedReadLock lock(nlSystemUseChangeLock); if(dnsCache == NULL) return false; ThreadVar<dnsCacheT>::Writer dns( *dnsCache ); dnsCacheT::iterator it = dns.get().find(name); if(it != dns.get().end()) { if( it->second.second < tLX->currentTime ) { dns.get().erase(it); return false; } *getNLaddr(addr) = it->second.first; return true; } else return false; }
static void io(dns_name_t *name, int id, int alg, int type, isc_mem_t *mctx) { dst_key_t *key = NULL; isc_result_t ret; ret = dst_key_fromfile(name, id, alg, type, current, mctx, &key); printf("read(%d) returned: %s\n", alg, isc_result_totext(ret)); if (ret != 0) return; ret = dst_key_tofile(key, type, tmp); printf("write(%d) returned: %s\n", alg, isc_result_totext(ret)); if (ret != 0) return; use(key, mctx); dns(key, mctx); dst_key_free(&key); }
void Configurator_config(Dict* config, struct Sockaddr* sockAddr, String* adminPassword, struct EventBase* eventBase, struct Log* logger, struct Allocator* alloc) { struct Except* eh = NULL; struct Allocator* tempAlloc = Allocator_child(alloc); struct AdminClient* client = AdminClient_new(sockAddr, adminPassword, eventBase, logger, tempAlloc); struct Context ctx = { .logger = logger, .alloc = tempAlloc, .client = client, .base = eventBase, }; List* authedPasswords = Dict_getList(config, String_CONST("authorizedPasswords")); if (authedPasswords) { authorizedPasswords(authedPasswords, &ctx); } Dict* ifaces = Dict_getDict(config, String_CONST("interfaces")); udpInterface(ifaces, &ctx); #ifdef HAS_ETH_INTERFACE ethInterface(ifaces, &ctx); #endif Dict* routerConf = Dict_getDict(config, String_CONST("router")); routerConfig(routerConf, tempAlloc, &ctx); List* securityList = Dict_getList(config, String_CONST("security")); security(securityList, tempAlloc, &ctx); Dict* dnsConf = Dict_getDict(config, String_CONST("dns")); dns(dnsConf, &ctx, eh); Allocator_free(tempAlloc); }
void tst_Q3Dns::longTxtRecord() { QSKIP("Long TXT records in Q3Dns don't work.", SkipSingle); int c = 0; char **v = 0; QCoreApplication a(c, v); Q3Dns dns(QString::fromLatin1("andreas.hanssen.name"), Q3Dns::Txt); QObject::connect(&dns, SIGNAL(resultsReady()), this, SLOT(longTxtRecordAnswer())); QTestEventLoop::instance().enterLoop(30); if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); QStringList list = dns.texts(); QCOMPARE(list.count(), 1); QCOMPARE(list[0], QString::fromLatin1("I have a remarkable solution to Fermat's last theorem, but it doesn't fit into this TXT record")); }
void tst_Q3Dns::txtRecords() { QSKIP("TXT record support is broken.", SkipAll); int argc = 0; char **argv = 0; QCoreApplication qapp(argc, argv); Q3Dns dns("Sales._ipp._tcp.dns-sd.org", Q3Dns::Txt); connect(&dns, SIGNAL(resultsReady()), SLOT(txtRecordAnswer())); QTestEventLoop::instance().enterLoop(10); if (QTestEventLoop::instance().timeout()) QFAIL("Timed out while looking up TXT record for Sales._ipp._tcp.dns-sd.org"); QStringList texts = dns.texts(); #if defined Q_OS_DARWIN QSKIP("TXT records in Q3Dns don't work for Mac OS X.", SkipSingle); #endif QVERIFY(!texts.isEmpty()); QCOMPARE(texts.at(0), QString("rp=lpt1")); }
//............................................................................... // start STA //............................................................................... void WIFI::startSTA() { String ssid = ffs.cfg.readItem("wifi_ssid"); String psk = ffs.cfg.readItem("wifi_password"); staMode = ffs.cfg.readItem("wifi"); // off, dhcp, manual apMode = ffs.cfg.readItem("ap"); // on, off, auto IPAddress address(0, 0, 0, 0); IPAddress gateway(0, 0, 0, 0); IPAddress netmask(0, 0, 0, 0); IPAddress dns(0, 0, 0, 0); //if (ssid != "") validSSID = true; else validSSID = false; validSSID = ssid != "" ? true : false; WiFi.softAPdisconnect(true); WiFi.mode(WIFI_STA); if (staMode == "dhcp") { logging.info("WiFi staMode=dhcp"); } else { // switch to static mode address.fromString(ffs.cfg.readItem("wifi_ip")); gateway.fromString(ffs.cfg.readItem("wifi_gateway")); netmask.fromString(ffs.cfg.readItem("wifi_netmask")); dns.fromString(ffs.cfg.readItem("wifi_dns")); logging.info("WiFi staMode=manual"); logging.debug(" IP address: " + address.toString()); logging.debug(" gateway: " + gateway.toString()); logging.debug(" netmask: " + netmask.toString()); logging.debug(" DNS server: " + dns.toString()); if (WiFi.config(address, gateway, netmask, dns)) { logging.debug("WiFi configuration applied"); // logging.info("local IP address switched to: " + // WiFi.localIP().toString()); } else { logging.error("could not apply WiFi configuration"); } } logging.info("try to connect to SSID: " + ssid); WiFi.begin(ssid.c_str(), psk.c_str()); }
static int lua_gethostbyname(lua_State * L) { struct sockaddr_in dnssrv; uint8 ip[4]; /* dnssrv.sin_family = AF_INET; */ /* dnssrv.sin_port = htons(53); */ /* if (dns("212.198.2.51", &dnssrv.sin_addr.s_addr)) */ /* return 0; */ /* //dnssrv.sin_addr.s_addr = ntohl(dnssrv.sin_addr.s_addr); */ /* printf("server ip %x\n", dnssrv.sin_addr.s_addr); */ //if (lwip_gethostbyname(&dnssrv, lua_tostring(L, 1), ip) < 0) //if (lwip_gethostbyname2("212.198.2.51", lua_tostring(L, 1), ip) < 0) if (dns(lua_tostring(L, 1), ip)) printf("Can't look up name"); else { printf("ip of '%s' is %d.%d.%d.%d\n", lua_tostring(L, 1), ip[0], ip[1], ip[2], ip[3]); } return 0; }
void tst_QDnsLookup_Appless::noApplication() { QTest::ignoreMessage(QtWarningMsg, "QDnsLookup requires a QCoreApplication"); QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); dns.lookup(); }
int main(int argc, const char* argv[]) { if (argc != 2) { printf("Usage: DNSResolver <hostname>\n"); return 1; } #ifdef BUILD_WIN32 // HAAX WSADATA WsaDat; WSAStartup(MAKEWORD(2, 2), &WsaDat); #endif // Start stopwatch auto time_start = std::chrono::high_resolution_clock::now(); // Create our socket and connect to the NS auto sock = socket(AF_INET, SOCK_DGRAM, 0); struct sockaddr_in ns_addr; ns_addr.sin_family = AF_INET; ns_addr.sin_port = htons(PORT); ns_addr.sin_addr.s_addr = inet_addr(NAMESERVER); if (connect(sock, (const sockaddr*)&ns_addr, sizeof(ns_addr)) != 0) { printf("Connection error!\n"); return 2; } // Create our buffer size_t length = 0; uint8_t buf[MAX_PACKET_LENGTH]; DNSPacket dns(argv[1]); dns.WriteQuestion(buf, length); // Send that stuff to the NS send(sock, (const char*)buf, length, 0); // Wait for the answer and overwrite our buffer recv(sock, (char*)buf, MAX_PACKET_LENGTH, 0); // Read what we got dns.ReadAnswer(buf); // Hooray, now let's print out our answers const auto& answers = dns.GetAnswers(); for (uint32_t i = 0; i < answers.size(); i++) { printf("%u - %s: %hhu.%hhu.%hhu.%hhu, TTL: %us\n", i + 1, answers[i]->host, answers[i]->addr[0], answers[i]->addr[1], answers[i]->addr[2], answers[i]->addr[3], answers[i]->ttl); } if (!answers.size()) printf("Could not resolve host!\n"); // Close our socket close(sock); // Stop stopwatch auto time_end = std::chrono::high_resolution_clock::now(); auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_end - time_start); printf("Time: %ums\n", ms); #ifdef BUILD_WIN32 // Even moar haxxes WSACleanup(); #endif return 0; }
int main(int argc, char* argv[], char* envp[]){ //silence warnings (void)envp; if(argc != 4){ printf("Wrong number of arguments. Usage %s <local port> <remote host> <remote port> \n", argv[0]); return 1; } int listenPort = atoi(argv[1]); //timing synchronization //apps will signal when they're all done pthread_mutex_init(&count_mutex, NULL); pthread_cond_init (&count_threshold_cv, NULL); struct timeval t1; struct timeval t2; // set up network ppETH eth(1, listenPort, argv[3], argv[2]); ppIP ip(2); ppTCP tcp(3); ppUDP udp(4); ppFTP ftp(5); ppTEL tel(6); ppRDP rdp(7); ppDNS dns(8); ftpAPP ftpApplication(5, true); telAPP telApplication(6, true); rdpAPP rdpApplication(7, true); dnsAPP dnsApplication(8, true); eth.registerHLP(ip); ip.registerHLP(tcp); ip.registerHLP(udp); tcp.registerHLP(ftp); tcp.registerHLP(tel); udp.registerHLP(rdp); udp.registerHLP(dns); dns.registerHLP(dnsApplication); ftp.registerHLP(ftpApplication); rdp.registerHLP(rdpApplication); tel.registerHLP(telApplication); ftp.registerLLP(tcp); tel.registerLLP(tcp); rdp.registerLLP(udp); dns.registerLLP(udp); tcp.registerLLP(ip); udp.registerLLP(ip); ip.registerLLP(eth); dnsApplication.registerLLP(dns); ftpApplication.registerLLP(ftp); rdpApplication.registerLLP(rdp); telApplication.registerLLP(tel); ip.start(); tcp.start(); udp.start(); ftp.start(); tel.start(); rdp.start(); dns.start(); //make sure everything is set before we start timing sleep(5); gettimeofday(&t1, NULL); // dnsApplication.startListen(); // ftpApplication.startListen(); // rdpApplication.startListen(); // telApplication.startListen(); dnsApplication.startApplication(); ftpApplication.startApplication(); rdpApplication.startApplication(); telApplication.startApplication(); //wait for apps to finish and then stop timing or whatever pthread_mutex_lock(&count_mutex); while (count<numApps*2) { pthread_cond_wait(&count_threshold_cv, &count_mutex); } pthread_mutex_unlock(&count_mutex); gettimeofday(&t2, NULL); printf("Listening on %d took %f ms\n", listenPort, diffms(t2,t1)); }
void mssql_database::on_open(const std::string &connection) { // parse user[:passwd]@host/db ([Drivername]) std::string con = connection; std::string::size_type pos = con.find('@'); std::string user, passwd; std::string driver; // bool has_pwd = true; if (pos == std::string::npos) { throw_error("mssql:open", "invalid dsn: " + connection); } else { // try to find colon (:) std::string credentials = con.substr(0, pos); std::string::size_type colpos = credentials.find(':'); if (colpos != std::string::npos) { // found colon, extract user and passwd user = credentials.substr(0, colpos); passwd = credentials.substr(colpos + 1, pos); } else { // only user name given user = credentials.substr(0, pos); } } // get connection part con = con.substr(pos + 1); pos = con.find('/'); std::string host = con.substr(0, pos); std::string db = con.substr(pos + 1); // get driver pos = db.find('('); if (pos != std::string::npos) { driver = db.substr(pos+1); db = db.substr(0, pos); db = trim(db); pos = driver.find(')'); driver = driver.substr(0, pos); } else { driver = "SQL Server"; } SQLRETURN ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &odbc_); if (ret != SQL_SUCCESS) { SQLFreeHandle(SQL_HANDLE_ENV, odbc_); throw_error(ret, SQL_HANDLE_ENV, odbc_, "mssql", "couldn't get odbc handle"); } ret = SQLSetEnvAttr(odbc_, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, 0); if (ret != SQL_SUCCESS) { SQLFreeHandle(SQL_HANDLE_ENV, odbc_); throw_error(ret, SQL_HANDLE_ENV, odbc_, "mssql", "couldn't set odbc driver version"); } ret = SQLAllocHandle(SQL_HANDLE_DBC, odbc_, &connection_); if (ret != SQL_SUCCESS) { SQLFreeHandle(SQL_HANDLE_ENV, odbc_); throw_error(ret, SQL_HANDLE_DBC, connection_, "mssql", "couldn't get connection handle"); } SQLSetConnectAttr(connection_, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0); std::string dns("DRIVER={" + driver + "};SERVER=" + host + "\\" + db + ";DATABASE=test;UID=" + user + ";PWD=sascha;"); SQLCHAR retconstring[1024]; ret = SQLDriverConnect(connection_, 0, (SQLCHAR*)dns.c_str(), SQL_NTS, retconstring, 1024, NULL,SQL_DRIVER_NOPROMPT); throw_error(ret, SQL_HANDLE_DBC, connection_, "mssql", "error on connect"); is_open_ = true; }
void Quad1MindlinShell3D :: computeBmatrixAt(GaussPoint *gp, FloatMatrix &answer, int li, int ui) { FloatArray n, ns; FloatMatrix dn, dns; const FloatArray &localCoords = gp->giveNaturalCoordinates(); this->interp.evaldNdx( dn, localCoords, FEIVertexListGeometryWrapper(lnodes) ); this->interp.evalN( n, localCoords, FEIVoidCellGeometry() ); answer.resize(8, 4 * 5); answer.zero(); // enforce one-point reduced integration if requested if ( this->reducedIntegrationFlag ) { FloatArray lc(2); lc.zero(); // set to element center coordinates this->interp.evaldNdx( dns, lc, FEIVertexListGeometryWrapper(lnodes) ); this->interp.evalN( ns, lc, FEIVoidCellGeometry() ); } else { dns = dn; ns = n; } // Note: This is just 5 dofs (sixth column is all zero, torsional stiffness handled separately.) for ( int i = 0; i < 4; ++i ) { ///@todo Check the rows for both parts here, to be consistent with _3dShell material definition // Part related to the membrane (columns represent coefficients for D_u, D_v) answer(0, 0 + i * 5) = dn(i, 0);//eps_x = du/dx answer(1, 1 + i * 5) = dn(i, 1);//eps_y = dv/dy answer(2, 0 + i * 5) = dn(i, 1);//gamma_xy = du/dy+dv/dx answer(2, 1 + i * 5) = dn(i, 0); // Part related to the plate (columns represent the dofs D_w, R_u, R_v) ///@todo Check sign here answer(3 + 0, 2 + 2 + i * 5) = dn(i, 0);// kappa_x = d(fi_y)/dx answer(3 + 1, 2 + 1 + i * 5) =-dn(i, 1);// kappa_y = -d(fi_x)/dy answer(3 + 2, 2 + 2 + i * 5) = dn(i, 1);// kappa_xy=d(fi_y)/dy-d(fi_x)/dx answer(3 + 2, 2 + 1 + i * 5) =-dn(i, 0); // shear strains answer(3 + 3, 2 + 0 + i * 5) = dns(i, 0);// gamma_xz = fi_y+dw/dx answer(3 + 3, 2 + 2 + i * 5) = ns(i); answer(3 + 4, 2 + 0 + i * 5) = dns(i, 1);// gamma_yz = -fi_x+dw/dy answer(3 + 4, 2 + 1 + i * 5) = -ns(i); } #if 0 // Experimental MITC4 support. // Based on "Short communication A four-node plate bending element based on mindling/reissner plate theory and a mixed interpolation" // KJ Bathe, E Dvorkin double x1, x2, x3, x4; double y1, y2, y3, y4; double Ax, Bx, Cx, Ay, By, Cy; double r = localCoords[0]; double s = localCoords[1]; x1 = lnodes[0][0]; x2 = lnodes[1][0]; x3 = lnodes[2][0]; x4 = lnodes[3][0]; y1 = lnodes[0][1]; y2 = lnodes[1][1]; y3 = lnodes[2][1]; y4 = lnodes[3][1]; Ax = x1 - x2 - x3 + x4; Bx = x1 - x2 + x3 - x4; Cx = x1 + x2 - x3 - x4; Ay = y1 - y2 - y3 + y4; By = y1 - y2 + y3 - y4; Cy = y1 + y2 - y3 - y4; FloatMatrix jac; this->interp.giveJacobianMatrixAt(jac, localCoords, FEIVertexListGeometryWrapper(lnodes) ); double detJ = jac.giveDeterminant(); double rz = sqrt( sqr(Cx + r*Bx) + sqr(Cy + r*By)) / ( 16 * detJ ); double sz = sqrt( sqr(Ax + s*Bx) + sqr(Ay + s*By)) / ( 16 * detJ ); // TODO: Not sure about this part (the reference is not explicit about these angles. / Mikael // Not sure about the transpose either. OOFEM_WARNING("The MITC4 implementation isn't verified yet. Highly experimental"); FloatArray dxdr = {jac(0,0), jac(0,1)}; dxdr.normalize(); FloatArray dxds = {jac(1,0), jac(1,1)}; dxds.normalize(); double c_b = dxdr(0); //cos(beta); double s_b = dxdr(1); //sin(beta); double c_a = dxds(0); //cos(alpha); double s_a = dxds(1); //sin(alpha); // gamma_xz = "fi_y+dw/dx" in standard formulation answer(6, 2 + 5*0) = rz * s_b * ( (1+s)) - sz * s_a * ( (1+r)); answer(6, 2 + 5*1) = rz * s_b * (-(1+s)) - sz * s_a * ( (1-r)); answer(6, 2 + 5*2) = rz * s_b * (-(1-s)) - sz * s_a * (-(1-r)); answer(6, 2 + 5*3) = rz * s_b * ( (1-s)) - sz * s_a * (-(1+r)); answer(6, 3 + 5*0) = rz * s_b * (y2-y1) * 0.5 * (1+s) - sz * s_a * (y4-y1) * 0.5 * (1+r); // tx1 answer(6, 4 + 5*0) = rz * s_b * (x1-x2) * 0.5 * (1+s) - sz * s_a * (x1-x4) * 0.5 * (1+r); // ty1 answer(6, 3 + 5*1) = rz * s_b * (y2-y1) * 0.5 * (1+s) - sz * s_a * (y3-x2) * 0.5 * (1+r); // tx2 answer(6, 4 + 5*1) = rz * s_b * (x1-x2) * 0.5 * (1+s) - sz * s_a * (x2-x3) * 0.5 * (1+r); // ty2 answer(6, 3 + 5*2) = rz * s_b * (y3-y4) * 0.5 * (1-s) - sz * s_a * (y3-y2) * 0.5 * (1-r); // tx3 answer(6, 4 + 5*2) = rz * s_b * (x4-x3) * 0.5 * (1-s) - sz * s_a * (x2-x3) * 0.5 * (1-r); // ty3 answer(6, 3 + 5*3) = rz * s_b * (y3-y4) * 0.5 * (1-s) - sz * s_a * (y4-y1) * 0.5 * (1-r); // tx4 answer(6, 4 + 5*3) = rz * s_b * (x4-x3) * 0.5 * (1-s) - sz * s_a * (x1-x4) * 0.5 * (1-r); // ty4 // gamma_yz = -fi_x+dw/dy in standard formulation answer(7, 2 + 5*0) = - rz * c_b * ( (1+s)) + sz * c_a * ( (1+r)); answer(7, 2 + 5*1) = - rz * c_b * (-(1+s)) + sz * c_a * ( (1-r)); answer(7, 2 + 5*2) = - rz * c_b * (-(1-s)) + sz * c_a * (-(1-r)); answer(7, 2 + 5*3) = - rz * c_b * ( (1-s)) + sz * c_a * (-(1+r)); answer(7, 3 + 5*0) = - rz * c_b * (y2-y1) * 0.5 * (1+s) + sz * c_a * (y4-y1) * 0.5 * (1+r); // tx1 answer(7, 4 + 5*0) = - rz * c_b * (x1-x2) * 0.5 * (1+s) + sz * c_a * (x1-x4) * 0.5 * (1+r); // ty1 answer(7, 3 + 5*1) = - rz * c_b * (y2-y1) * 0.5 * (1+s) + sz * c_a * (y3-x2) * 0.5 * (1+r); // tx2 answer(7, 4 + 5*1) = - rz * c_b * (x1-x2) * 0.5 * (1+s) + sz * c_a * (x2-x3) * 0.5 * (1+r); // ty2 answer(7, 3 + 5*2) = - rz * c_b * (y3-y4) * 0.5 * (1-s) + sz * c_a * (y3-y2) * 0.5 * (1-r); // tx3 answer(7, 4 + 5*2) = - rz * c_b * (x4-x3) * 0.5 * (1-s) + sz * c_a * (x2-x3) * 0.5 * (1-r); // ty3 answer(7, 3 + 5*3) = - rz * c_b * (y3-y4) * 0.5 * (1-s) + sz * c_a * (y4-y1) * 0.5 * (1-r); // tx4 answer(7, 4 + 5*3) = - rz * c_b * (x4-x3) * 0.5 * (1-s) + sz * c_a * (x1-x4) * 0.5 * (1-r); // ty4 #endif }
void AddToDnsCache(const std::string& name, const NetworkAddr& addr, TimeDiff expireTime ) { ScopedReadLock lock(nlSystemUseChangeLock); if(dnsCache == NULL) return; ThreadVar<dnsCacheT>::Writer dns( *dnsCache ); dns.get()[name] = std::make_pair( *getNLaddr(addr), GetTime() + expireTime ); }
static int lua_net_connect(lua_State * L) { int res = -1; struct netif_list * listhead; uint8 ip[4]; dbglog_set_level(7); if (lua_tostring(L, 1) == NULL || dns(lua_tostring(L, 1), ip)) { printf("Syntax error : try net_connect your.ip.add.ress\n"); return 0; } if (netinit) { if (memcmp(ip, "\0\0\0\0", 4)) { /* hack so that we keep dcload connection alive during DHCP re-negotiation */ printf("Set IP : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); eth_setip(ip[0], ip[1], ip[2], ip[3]); } return 0; } printf("calling eth_init\n"); if (!netinit) { //net_init(); old_printk_func = 0; if (find_adaptator(lua_tostring(L, 2))) { lua_settop(L, 0); lua_pushstring(L, "No adaptator recognised"); return 1; } net_init(); } netinit = 1; // Find a device for us listhead = net_get_if_list(); LIST_FOREACH(netif, listhead, if_list) { if (netif->flags & NETIF_RUNNING) break; } if (netif == NULL) { printf("can't find an active KOS network device\n"); lua_settop(L, 0); lua_pushstring(L, "Can't find an active KOS network device"); return 1; } if (netif) { uint8 mac[6]; int i; printf("Ethernet adapter initialized succesfully !\n"); res = 0; memcpy(eth_mac, netif->mac_addr, sizeof(eth_mac)); printf("MAC address : "); for (i=0; i<6; i++) printf("%x ", (int) eth_mac[i]); printf("\n"); printf("Set IP : %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); eth_setip(ip[0], ip[1], ip[2], ip[3]); net_input_set_target(rx_callback); if (!fs_init()) printf("nfs, httpfs, tcpfs and udpfs initialized succesfully\n"); } return 0; }