OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [kernel/] [netutil.c] - Diff between revs 352 and 354

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 352 Rev 354
Line 72... Line 72...
   do
   do
   {
   {
      bytes = IPRead(socket, buf, sizeof(buf));
      bytes = IPRead(socket, buf, sizeof(buf));
      fwrite(buf, 1, bytes, info->file);
      fwrite(buf, 1, bytes, info->file);
   } while(bytes);
   } while(bytes);
 
 
   if(state > IP_TCP)
   if(state > IP_TCP)
   {
   {
      fclose(info->file);
      fclose(info->file);
      IPClose(socket);
 
      info->done = 1;
      info->done = 1;
      IPPrintf(info->socket, "226 Done\r\n");
      IPPrintf(info->socket, "226 Done\r\n");
 
      IPClose(socket);
      return;
      return;
   }
   }
}
}
 
 
 
 
Line 107... Line 108...
      socket->userPtr = info;
      socket->userPtr = info;
      info->socket = socket;
      info->socket = socket;
      socket->timeoutReset = 60;
      socket->timeoutReset = 60;
      IPPrintf(socket, "220 Connected to Plasma\r\n");
      IPPrintf(socket, "220 Connected to Plasma\r\n");
   }
   }
 
   else if(socket->userPtr == (void*)-1)
 
   {
 
      return;
 
   }
   else if(strstr((char*)buf, "USER"))
   else if(strstr((char*)buf, "USER"))
   {
   {
      if(strstr((char*)buf, "PlasmaSend"))
      if(strstr((char*)buf, "PlasmaSend"))
         info->canReceive = 1;
         info->canReceive = 1;
      IPPrintf(socket, "331 Password?\r\n");
      IPPrintf(socket, "331 Password?\r\n");
Line 119... Line 124...
   {
   {
      IPPrintf(socket, "230 Logged in\r\n");
      IPPrintf(socket, "230 Logged in\r\n");
   }
   }
   else if(strstr((char*)buf, "PORT"))
   else if(strstr((char*)buf, "PORT"))
   {
   {
      if(info == NULL)
 
         return;
 
      sscanf((char*)buf + 5, "%d,%d,%d,%d,%d,%d", &ip0, &ip1, &ip2, &ip3, &port0, &port1);
      sscanf((char*)buf + 5, "%d,%d,%d,%d,%d,%d", &ip0, &ip1, &ip2, &ip3, &port0, &port1);
      info->ip = (ip0 << 24) | (ip1 << 16) | (ip2 << 8) | ip3;
      info->ip = (ip0 << 24) | (ip1 << 16) | (ip2 << 8) | ip3;
      info->port = (port0 << 8) | port1;
      info->port = (port0 << 8) | port1;
      //printf("ip=0x%x port=%d\n", info->ip, info->port);
      //printf("ip=0x%x port=%d\n", info->ip, info->port);
      IPPrintf(socket, "200 OK\r\n");
      IPPrintf(socket, "200 OK\r\n");
Line 132... Line 135...
   else if(strstr((char*)buf, "RETR") || strstr((char*)buf, "STOR"))
   else if(strstr((char*)buf, "RETR") || strstr((char*)buf, "STOR"))
   {
   {
      char *ptr = strstr((char*)buf, "\r");
      char *ptr = strstr((char*)buf, "\r");
      if(ptr)
      if(ptr)
         *ptr = 0;
         *ptr = 0;
      if(info == NULL)
 
         return;
 
      info->file = NULL;
      info->file = NULL;
      info->bytes = 0;
      info->bytes = 0;
      info->done = 0;
      info->done = 0;
      if(strstr((char*)buf, "RETR"))
      if(strstr((char*)buf, "RETR"))
         info->file = fopen((char*)buf + 5, "rb");
         info->file = fopen((char*)buf + 5, "rb");
Line 160... Line 161...
   }
   }
   else if(strstr((char*)buf, "QUIT"))
   else if(strstr((char*)buf, "QUIT"))
   {
   {
      if(socket->userPtr)
      if(socket->userPtr)
         free(socket->userPtr);
         free(socket->userPtr);
 
      socket->userPtr = (void*)-1;
      IPPrintf(socket, "221 Bye\r\n");
      IPPrintf(socket, "221 Bye\r\n");
      IPClose(socket);
      IPClose(socket);
   }
   }
   else if(bytes)
   else if(bytes)
   {
   {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.