Changeset 500
- Timestamp:
- 04/08/06 20:57:15 (3 years ago)
- Files:
-
- nepenthes/trunk/configure.ac (modified) (1 diff)
- nepenthes/trunk/modules/Makefile.am (modified) (1 diff)
- nepenthes/trunk/modules/download-http/HTTPDialogue.cpp (modified) (1 diff)
- nepenthes/trunk/modules/log-irc/log-irc.cpp (modified) (1 diff)
- nepenthes/trunk/modules/shellcode-generic/shellcode-generic.cpp (modified) (1 diff)
- nepenthes/trunk/modules/x-7 (deleted)
- nepenthes/trunk/nepenthes-core/include/Makefile.am (modified) (1 diff)
- nepenthes/trunk/nepenthes-core/include/RAWSocket.hpp (deleted)
- nepenthes/trunk/nepenthes-core/include/SocketManager.hpp (modified) (1 diff)
- nepenthes/trunk/nepenthes-core/src/Makefile.am (modified) (1 diff)
- nepenthes/trunk/nepenthes-core/src/RAWSocket.cpp (deleted)
- nepenthes/trunk/nepenthes-core/src/SocketManager.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nepenthes/trunk/configure.ac
r498 r500 890 890 modules/x-5/Makefile 891 891 modules/x-6/Makefile 892 modules/x-7/Makefile893 892 modules/x-8/Makefile 894 893 modules/geolocation-hostip/Makefile nepenthes/trunk/modules/Makefile.am
r420 r500 15 15 geolocation-hostip geolocation-geoip geolocation-ip2location \ 16 16 dnsresolve-adns \ 17 x-1 x-2 x-3 x-4 x-5 x-6 x- 7 x-8 \17 x-1 x-2 x-3 x-4 x-5 x-6 x-8 \ 18 18 log-surfnet vuln-ftpd \ 19 19 log-prelude shellcode-signatures nepenthes/trunk/modules/download-http/HTTPDialogue.cpp
r339 r500 181 181 { 182 182 end += 2; 183 int headersize = end-start; 183 184 logSpam("FOUND HEADER (size %i)\n",end-start); 184 185 logSpam("%.*s",end-start,start); 185 186 // FIXME PARSE HEADER 186 // HTTPHeader *header = new HTTPHeader(start,(uint32_t)(end-start)); 187 // m_HTTPHeader = header; 187 string httpheader(start,headersize); 188 189 int contentoffsetstart=0; 190 int contentoffsetstopp=0; 191 if ( (contentoffsetstart = httpheader.find("Content-Length:",0)) != -1) 192 { 193 logInfo("FOund Content-Length on offset %i\n",contentoffsetstart); 194 if ((contentoffsetstopp = httpheader.find("\r\n",contentoffsetstart)) != -1) 195 { 196 logInfo("FOund Content-Length End on offset %i\n",contentoffsetstopp); 197 string contentline = httpheader.substr(contentoffsetstart + strlen("Content-Length:") 198 ,contentoffsetstopp - 199 contentoffsetstart - 200 strlen("Content-Length:")); 201 printf("Content-Size = \"%s\" '%i'\n",contentline.c_str(),atoi(contentline.c_str())); 202 203 if (m_Download->getDownloadBuffer()->getSize() - ((end-start)+2) == 204 (uint32_t)atoi(contentline.c_str()) 205 ) 206 { 207 logInfo("perfect day size %i matches\n",atoi(contentline.c_str())); 208 }else 209 { 210 printf("download size %i\n",m_Download->getDownloadBuffer()->getSize()); 211 printf("header size %i\n",((end-start)+2)); 212 printf("body size %i\n",atoi(contentline.c_str())); 213 } 214 } 215 } 216 188 217 } 189 218 m_Download->getDownloadBuffer()->cutFront((uint32_t)(end-start)+2); nepenthes/trunk/modules/log-irc/log-irc.cpp
r378 r500 279 279 280 280 logSpam("LogIrc DNS %s has no ip, resolve error\n", result->getDNS().c_str()); 281 /* char *reply; 282 asprintf(&reply,"DNS '%s' could not resolve\n", result->getDNS().c_str()); 283 m_Socket->doRespond(reply,strlen(reply)); 284 free(reply); 285 */ 281 286 282 return true; 287 283 } nepenthes/trunk/modules/shellcode-generic/shellcode-generic.cpp
r459 r500 83 83 84 84 // m_ShellcodeHandlers.push_back(new GenericXOR(m_Nepenthes->getShellcodeMgr())); 85 m_ShellcodeHandlers.push_back(new GenericCreateProcess(m_Nepenthes->getShellcodeMgr()));85 // m_ShellcodeHandlers.push_back(new GenericCreateProcess(m_Nepenthes->getShellcodeMgr())); 86 86 // m_ShellcodeHandlers.push_back(new GenericUrl(m_Nepenthes->getShellcodeMgr())); 87 87 // m_ShellcodeHandlers.push_back(new LinkXOR(m_Nepenthes->getShellcodeMgr())); nepenthes/trunk/nepenthes-core/include/Makefile.am
r332 r500 18 18 EXTRA_DIST += ModuleManager.hpp Module.hpp 19 19 EXTRA_DIST += Manager.hpp Nepenthes.hpp 20 EXTRA_DIST += SocketManager.hpp Socket.hpp TCPSocket.hpp UDPSocket.hpp POLLSocket.hpp R AWSocket.hpp Responder.hpp UDSSocket.hpp FILESocket.hpp20 EXTRA_DIST += SocketManager.hpp Socket.hpp TCPSocket.hpp UDPSocket.hpp POLLSocket.hpp Responder.hpp UDSSocket.hpp FILESocket.hpp 21 21 EXTRA_DIST += ShellcodeManager.hpp ShellcodeHandler.hpp 22 22 EXTRA_DIST += Packet.hpp nepenthes/trunk/nepenthes-core/include/SocketManager.hpp
r341 r500 67 67 virtual Socket *connectTCPHost(uint32_t localHost, uint32_t remotehost, uint16_t localport, uint16_t remoteport,time_t connecttimeout); 68 68 69 virtual Socket *createRAWSocketUDP(uint16_t localport, uint16_t remoteport,time_t bindtimeout,time_t accepttimeout, DialogueFactory *diaf);70 virtual Socket *createRAWSocketTCP(uint16_t localport, uint16_t remoteport,time_t bindtimeout,time_t accepttimeout, DialogueFactory *diaf);71 72 69 virtual Socket *addPOLLSocket(POLLSocket *sock); 73 70 nepenthes/trunk/nepenthes-core/src/Makefile.am
r341 r500 23 23 nepenthes_SOURCES += Nepenthes.cpp Manager.cpp 24 24 nepenthes_SOURCES += Packet.cpp 25 nepenthes_SOURCES += SocketManager.cpp Socket.cpp TCPSocket.cpp UDPSocket.cpp POLLSocket.cpp RAWSocket.cppFILESocket.cpp25 nepenthes_SOURCES += SocketManager.cpp Socket.cpp TCPSocket.cpp UDPSocket.cpp POLLSocket.cpp FILESocket.cpp 26 26 nepenthes_SOURCES += Responder.cpp 27 27 nepenthes_SOURCES += ShellcodeManager.cpp ShellcodeHandler.cpp nepenthes/trunk/nepenthes-core/src/SocketManager.cpp
r360 r500 52 52 #include "FILESocket.hpp" 53 53 #include "UDPSocket.hpp" 54 #include "RAWSocket.hpp"55 54 #include "POLLSocket.hpp" 56 55 … … 114 113 bool SocketManager::Init() 115 114 { 116 try {117 m_UseRawSockets = m_Nepenthes->getConfig()->getValInt("nepenthes.socketmanager.use_rawsockets");118 if (m_UseRawSockets)119 {120 logInfo("%s","Using Rawsockets\n");121 }122 } catch ( ... ) {123 logCrit("%s","Could not find nepenthes.socketmanager.use_rawsockets in config file, assuming no\n");124 }125 126 127 115 try { 128 116 string bindAddressString = m_Nepenthes->getConfig()->getValString("nepenthes.socketmanager.bind_address"); … … 164 152 } 165 153 166 167 #ifdef WIN32168 WORD wVersionRequested;169 WSADATA wsaData;170 int32_t err;171 172 wVersionRequested = MAKEWORD( 2, 2 );173 174 err = WSAStartup( wVersionRequested, &wsaData );175 if ( err != 0 ) {176 /* Tell the user that we could not find a usable */177 /* WinSock DLL. */178 logCrit("%s\n","Could not find good Windows Socket dll");179 return false;180 }else181 {182 logDebug("%s\n","WSAStartup worked");183 }184 #endif185 186 187 188 if (m_UseRawSockets == true)189 {190 #ifdef WIN32191 // win32 raw socket interface lookup & adding here192 SOCKET sd = WSASocket(AF_INET, SOCK_DGRAM, 0, 0, 0, 0);193 if (sd == SOCKET_ERROR)194 {195 logCrit("Failed to get a socket. Error %i\n", WSAGetLastError());196 return false;197 }198 199 INTERFACE_INFO InterfaceList[20];200 uint32_t nBytesReturned;201 if (WSAIoctl(sd, SIO_GET_INTERFACE_LIST, 0, 0, &InterfaceList,202 sizeof(InterfaceList), &nBytesReturned, 0, 0) == SOCKET_ERROR)203 {204 logCrit("Failed calling WSAIoctl: error %i\n",WSAGetLastError());205 return false;206 }207 208 int32_t nNumInterfaces = nBytesReturned / sizeof(INTERFACE_INFO);209 logDebug("There are %i interfaces \n",nNumInterfaces);210 int32_t i;211 for (i = 0; i < nNumInterfaces; ++i)212 {213 logDebug("Interface %i \n", i);214 215 u_long nFlags = InterfaceList[i].iiFlags;216 if (nFlags & IFF_UP)217 logDebug("Iface is %s\n","up");218 else219 logDebug("Iface is %s\n","down");220 221 222 223 sockaddr_in *pAddress;224 pAddress = (sockaddr_in *) & (InterfaceList[i].iiAddress);225 logDebug("\tip %s\n",inet_ntoa(pAddress->sin_addr));226 227 pAddress = (sockaddr_in *) & (InterfaceList[i].iiBroadcastAddress);228 logDebug("\tbcast %s\n",inet_ntoa(pAddress->sin_addr));229 230 pAddress = (sockaddr_in *) & (InterfaceList[i].iiNetmask);231 logDebug("\tnetmask %s\n",inet_ntoa(pAddress->sin_addr));232 233 if (nFlags & IFF_POINTTOPOINT)234 logDebug("%s\n","\tis point-to-point");235 if (nFlags & IFF_LOOPBACK)236 logDebug("%s\n","\tis a loopback iface");237 238 239 string features = "";240 241 if (nFlags & IFF_BROADCAST)242 features += "bcast ";243 if (nFlags & IFF_MULTICAST)244 features += "multicast ";245 logDebug("\tFeatures: %s \n", features.c_str());246 }247 248 249 for (i = 0; i < nNumInterfaces; ++i)250 {251 252 sockaddr_in *pAddress;253 pAddress = (sockaddr_in *) & (InterfaceList[i].iiAddress);254 255 RAWSocketListener *sock = new RAWSocketListener(m_Nepenthes,*(uint32_t *)&(pAddress->sin_addr));256 if ( sock->Init() == true )257 {258 m_Sockets.push_back(sock);259 } else260 {261 return false;262 }263 264 }265 #else266 FILE *f = fopen(PROC_NET_DEV,"r");267 if (f== NULL)268 {269 logCrit("Could not open %s \n",PROC_NET_DEV);270 return false;271 }272 char line[512];273 memset(line,0,512);274 bool ifaceline=false;275 276 list <string> interfaces;277 278 while (fgets(line,512,f) != NULL)279 {280 if (ifaceline)281 {282 // printf("proc line is '%s' \n",line);283 char *ifacestopp=line;284 char *ifacestart=line;285 while(*ifacestopp != ':')286 ifacestopp++;287 288 while (*ifacestart == ' ')289 ifacestart++;290 291 logSpam("iface %.*s \n",ifacestopp-ifacestart,ifacestart);292 293 interfaces.push_back(string(ifacestart,ifacestopp-ifacestart));294 295 }else296 if (strstr(line,"bytes") != NULL)297 {298 ifaceline = true;299 }300 301 302 303 memset(line,0,512);304 }305 fclose(f);306 307 list<string>::iterator it;308 309 for (it=interfaces.begin();it!= interfaces.end();it++)310 {311 logDebug("Interface %s is availible for sniffing\n",it->c_str());312 }313 314 for ( it=interfaces.begin();it!= interfaces.end();it++ )315 {316 if (strstr(it->c_str(),"eth") == NULL)317 {318 logDebug("No sniffing on %s\n",it->c_str());319 continue;320 }321 322 323 struct ifreq ifr;324 memset(&ifr,0,sizeof(struct ifreq));325 // struct ifconf ifc;326 327 uint32_t localip=0;328 int32_t fd = socket(AF_INET, SOCK_DGRAM, 0);329 if ( fd >= 0 )330 {331 strcpy(ifr.ifr_name, it->c_str());332 ifr.ifr_addr.sa_family = AF_INET;333 if ( ioctl(fd, SIOCGIFADDR, &ifr) == 0 )334 {335 struct sockaddr_in *ssin;336 ssin = (struct sockaddr_in *) &ifr.ifr_addr;337 logSpam("Interface %s has ip %s \n",it->c_str(),inet_ntoa(*(in_addr *)&ssin->sin_addr.s_addr));338 339 localip = ssin->sin_addr.s_addr;340 341 /* logSpam("Interface %s has ip %s \n",it->c_str(),inet_ntoa(*(in_addr *)&ifr.ifr_addr));342 strcpy(ifr.ifr_name, it->c_str());343 if ( ioctl(fd, SIOCGIFDSTADDR, &ifr) >= 0 )344 logSpam("Interface %s has ... %s \n",it->c_str(),inet_ntoa(*(in_addr *)&ifr.ifr_dstaddr));345 346 strcpy(ifr.ifr_name, it->c_str());347 if ( ioctl(fd, SIOCGIFBRDADDR, &ifr) >= 0 )348 logSpam("Interface %s has ... %s \n",it->c_str(),inet_ntoa(*(in_addr *)&ifr.ifr_broadaddr));349 350 strcpy(ifr.ifr_name, it->c_str());351 if ( ioctl(fd, SIOCGIFNETMASK, &ifr) >= 0 )352 logSpam("Interface %s has ... %s \n",it->c_str(),inet_ntoa(*(in_addr *)&ifr.ifr_netmask));353 */354 }355 // else356 // memset(&ife->addr, 0, sizeof(struct sockaddr));357 }358 359 360 RAWSocketListener *sock;361 sock = new RAWSocketListener(m_Nepenthes,(char *)it->c_str(), localip, IPPROTO_TCP);362 if ( sock->Init() == true )363 {364 m_Sockets.push_back(sock);365 } else366 {367 return false;368 }369 370 /* sock = new RAWSocketListener(m_Nepenthes,(char *)it->c_str(), IPPROTO_UDP);371 if ( sock->Init() == true )372 {373 m_Sockets.push_back(sock);374 } else375 {376 return false;377 }378 */379 }380 interfaces.clear();381 #endif382 383 }384 154 return true; 385 155 } … … 406 176 407 177 /** 408 * checks all sockets, and polls, handles the send and receive, socket timeouts, accepting new sockets, deleting deadsockets178 * poll the sockets 409 179 * 410 180 * @param polltimeout 411 * the polltimeout we want to use in milliseconds 412 * 413 * @return returns true if something was polled 414 * else false 181 * the polltimeout 182 * 183 * @return returns true 415 184 */ 416 #ifdef WIN32417 #error "i changed some stuff and found no reason to port it"418 #error "to be precise, the setStatus thing for connected sockets"419 420 185 bool SocketManager::doLoop(uint32_t polltimeout) 421 { // FIXME ..186 { 422 187 list <Socket *>::iterator itSocket; 423 188 … … 450 215 } 451 216 452 fd_set rfds; 453 fd_set wfds; 454 455 FD_ZERO(&rfds); 456 FD_ZERO(&wfds); 457 458 217 pollfd *polls = (pollfd *) malloc( (m_Sockets.size())* sizeof(pollfd)); 218 memset(polls,0,(m_Sockets.size())* sizeof(pollfd)); 459 219 int32_t i=0; 460 220 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++) … … 477 237 { 478 238 case 0: // der socket is soweit okay 479 // logSpam("Socket %s is OK\n",(*itSocket)->getDescription().c_str()); 480 (*itSocket)->setPolled(); 239 case EISCONN: 240 if ((*itSocket)->getStatus() == SS_CONNECTING) 241 { 242 (*itSocket)->setStatus(SS_CONNECTED); 243 } 244 (*itSocket)->setPolled(); // der socket ist am start 481 245 break; 482 246 483 case WSAEINPROGRESS: // der socket versuchts247 case EINPROGRESS: // der socket versuchts 484 248 (*itSocket)->unsetPolled(); 485 249 break; 486 250 487 case WSAEISCONN:488 (*itSocket)->setPolled(); // der socket ist am start489 break;490 491 251 492 252 default: … … 497 257 498 258 i=0; 499 int32_t maxsock=-1;500 259 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++) 501 { 260 { 261 polls[i].events = 0; 502 262 if ((*itSocket)->isPolled() == true ) 503 263 { 504 if ((*itSocket)->getSocket() > maxsock) 505 { 506 maxsock = (*itSocket)->getSocket(); 507 } 508 509 FD_SET((*itSocket)->getSocket(),&rfds); 264 polls[i].fd = (*itSocket)->getSocket(); 265 polls[i].events = POLLIN; 510 266 511 267 if ((*itSocket)->wantSend() == true) 512 268 { 513 FD_SET((*itSocket)->getSocket(),&wfds); 514 }/*else 515 logSpam("polling %s readonly\n",(*itSocket)->getDescription().c_str());*/ 269 polls[i].events |= POLLOUT; 270 } 516 271 i++; 517 272 } 518 273 } 519 274 520 struct timeval tv; 521 tv.tv_sec = 2; 522 tv.tv_usec = 500000; 523 524 int32_t iPollRet = select(maxsock,&rfds,&wfds,NULL,&tv); 275 int32_t iPollRet = poll(polls,i,50); 525 276 526 277 if (iPollRet != 0) … … 537 288 ) 538 289 { 539 if ( FD_ISSET((*itSocket)->getSocket(),&rfds) ) 290 if ( iPollRet == 0 ) 291 continue; 292 293 if ( polls[i].revents & POLLIN && polls[i].events & POLLIN ) 540 294 { 541 295 (*itSocket)->doRecv(); 296 iPollRet--; 542 297 } 543 298 } … … 552 307 if ( (*itSocket)->isPolled() == true ) 553 308 { 554 // logSpam(" COuld write #%i\n",1);555 // doRecv() can close sockets556 // we need a valid way to verify we dont try to send on a closed socket,557 // i think wantSend() is a good option here558 // getStatus i just a cheap fix559 // logInfo("SSS %s \n",(*itSocket)->getDescription().c_str());560 309 if ( 561 310 ( (*itSocket)->getStatus() == SS_CONNECTED || (*itSocket)->getStatus() == SS_CLEANQUIT ) && … … 569 318 ) 570 319 { 571 // if ( iPollRet == 0 )572 // continue;573 // logSpam(" COuld write #%i\n",2);574 if (FD_ISSET((*itSocket)->getSocket(),&wfds))575 {576 // logSpam(" COuld write #%i\n",3);577 (*itSocket)->doSend();578 579 }580 }581 i++;582 }583 }584 585 586 // accept new, non udp clients as udp does not accept()587 i=0;588 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)589 {590 591 592 if ( (*itSocket)->isPolled() == true )593 {594 if ( (*itSocket)->isBind() )595 {596 if ( !((*itSocket)->getType() & ST_UDP) ) // bound udp sockets dont accept, they recvfrom597 {598 if (FD_ISSET((*itSocket)->getSocket(),&rfds))599 {600 logDebug("%s could Accept a Connection\n",(*itSocket)->getDescription().c_str());601 Socket * socket = (*itSocket)->acceptConnection();602 if ( socket == NULL )603 {604 logCrit("%s","Accept returned NULL ptr \n");605 } else606 {607 m_Sockets.push_back(socket);608 logDebug("Accepted Connection %s \n%i Sockets in list\n",socket->getDescription().c_str(), m_Sockets.size());609 }610 }611 }612 }613 i++;614 }615 }616 }617 // free(polls);618 // sleep(1);619 return true;620 }621 #else622 623 /**624 * poll the sockets625 *626 * @param polltimeout627 * the polltimeout628 *629 * @return returns true630 */631 bool SocketManager::doLoop(uint32_t polltimeout)632 {// FIXME ..633 634 635 636 637 list <Socket *>::iterator itSocket;638 639 // check socket timeouts and remove dead sockets640 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)641 {642 (*itSocket)->checkTimeout();643 if ((*itSocket)->getStatus() == SS_TIMEOUT )644 {645 logDebug("Deleting Socket %s due to timeout \n",(*itSocket)->getDescription().c_str());646 Socket *delsocket = *itSocket;647 m_Sockets.erase(itSocket);648 delete delsocket;649 650 itSocket = m_Sockets.begin(); // FIXME ?651 if(m_Sockets.size() == 0)652 return false;653 654 655 }656 657 if ( (*itSocket)->getStatus() == SS_CLOSED )658 {659 logDebug("Deleting %s due to closed connection \n",(*itSocket)->getDescription().c_str());660 Socket *delsocket = *itSocket;661 m_Sockets.erase(itSocket);662 delete delsocket;663 itSocket = m_Sockets.begin(); // FIXME ?664 }665 }666 667 pollfd *polls = (pollfd *) malloc( (m_Sockets.size())* sizeof(pollfd));668 memset(polls,0,(m_Sockets.size())* sizeof(pollfd));669 int32_t i=0;670 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)671 {672 int32_t iError = 0;673 int32_t iSize = sizeof(iError);674 if((*itSocket)->getType() & ST_FILE)675 {676 (*itSocket)->setPolled();677 }else678 if ((*itSocket)->getsockOpt(SOL_SOCKET, SO_ERROR, &iError,(socklen_t *) &iSize) != 0 )679 {680 // socket is dead681 logSpam("Socket %s is Dead\n",(*itSocket)->getDescription().c_str());682 (*itSocket)->unsetPolled();683 684 } else685 {686 switch (iError)687 {688 case 0: // der socket is soweit okay689 case EISCONN:690 // logSpam("EISCONN State %i \n",(*itSocket)->getStatus());691 if ((*itSocket)->getStatus() == SS_CONNECTING)692 {693 (*itSocket)->setStatus(SS_CONNECTED);694 }695 (*itSocket)->setPolled(); // der socket ist am start696 break;697 698 case EINPROGRESS: // der socket versuchts699 (*itSocket)->unsetPolled();700 break;701 702 703 default:704 (*itSocket)->unsetPolled(); // der is defekt705 }706 }707 }708 709 i=0;710 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)711 {712 polls[i].events = 0;713 if ((*itSocket)->isPolled() == true )714 {715 polls[i].fd = (*itSocket)->getSocket();716 717 polls[i].events = POLLIN;718 719 720 721 if ((*itSocket)->wantSend() == true)722 {723 // logSpam("polling %s read|write\n",(*itSocket)->getDescription().c_str());724 725 polls[i].events |= POLLOUT;726 }/*else727 logSpam("polling %s readonly\n",(*itSocket)->getDescription().c_str());*/728 i++;729 }730 }731 732 int32_t iPollRet = poll(polls,i,50);733 734 if (iPollRet != 0)735 {736 // read sockets737 i=0;738 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)739 {740 if ( (*itSocket)->isPolled() == true )741 {742 if (743 ( (*itSocket)->isAccept() || (*itSocket)->isConnect() ) ||744 ( (*itSocket)->isBind() && (*itSocket)->getType() & ST_UDP) // bound udp sockets dont accept, they recvfrom745 )746 {747 if ( iPollRet == 0 )748 continue;749 750 if ( polls[i].revents & POLLIN && polls[i].events & POLLIN )751 {752 (*itSocket)->doRecv();753 iPollRet--;754 }755 }756 i++;757 }758 }759 760 // write sockets761 i=0;762 for (itSocket = m_Sockets.begin();itSocket != m_Sockets.end(); itSocket++)763 {764 if ( (*itSocket)->isPolled() == true )765 {766 // logSpam(" COuld write #%i\n",1);767 // doRecv() can close sockets768 // we need a valid way to verify we dont try to send on a closed socket,769 // i think wantSend() is a good option here770 // getStatus i just a cheap fix771 // logDebug("SSS %s \n",(*itSocket)->getDescription().c_str());772 if (773 ( (*itSocket)->getStatus() == SS_CONNECTED || (*itSocket)->getStatus() == SS_CLEANQUIT ) &&774 (775 (*itSocket)->isAccept() ||776 (*itSocket)->isConnect() ||777 (778 (*itSocket)->isBind() && (*itSocket)->getType() & ST_UDP779 )780 )781 )782 {783 // if ( iPollRet == 0 )784 // continue;785 // logSpam(" COuld write #%i\n",2);786 320 if ( polls[i].revents & POLLOUT && polls[i].events & POLLOUT ) 787 321 { 788 // logSpam(" COuld write #%i\n",3);789 322 (*itSocket)->doSend(); 790 323 iPollRet--; … … 832 365 } 833 366 free(polls); 834 // sleep(1);835 367 return true; 836 368 } 837 #endif 369 838 370 839 371 /** … … 1065 597 } 1066 598 1067 Socket *SocketManager::createRAWSocketUDP(uint16_t localport, uint16_t remoteport, time_t bindtimeout,time_t accepttimeout, DialogueFactory *dialoguefactory) 1068 { 1069 logSpam("createRAWPSocketUDP %i %i %i %i \n",localport,remoteport,bindtimeout,accepttimeout); 1070 //RAWSocketListener *sock = NULL; 1071 1072 list <Socket *>::iterator socket; 1073 for(socket = m_Sockets.begin();socket != m_Sockets.end(); socket++) 1074 { 1075 if((*socket)->getType() & ST_RAW ) 1076 { 1077 ((RAWSocketListener *)(*socket))->addListenFactory(localport,remoteport,IPPROTO_UDP,dialoguefactory); 1078 // return (*socket); 1079 } 1080 } 1081 return NULL; 1082 } 1083 1084 /** 1085 * 1086 * @param localport 1087 * @param remoteport 1088 * @param bindtimeout 1089 * @param accepttimeout 1090 * @param dialoguefactory 1091 * 1092 * @return 1093 */ 1094 Socket *SocketManager::createRAWSocketTCP(uint16_t localport,uint16_t remoteport,time_t bindtimeout,time_t accepttimeout, DialogueFactory *dialoguefactory) 1095 { 1096 logSpam("createRAWPSocketTCP %i %i %i %i \n",localport,remoteport,bindtimeout,accepttimeout); 1097 //RAWSocketListener *sock = NULL; 1098 1099 list <Socket *>::iterator socket; 1100 for(socket = m_Sockets.begin();socket != m_Sockets.end(); socket++) 1101 { 1102 if((*socket)->getType() & ST_RAW ) 1103 { 1104 &nb
