Difference for arch/win32/ipx_win.c from version 1.3 to 1.4


version 1.3 version 1.4
Line 4
 
Line 4
 #include <stdlib.h>  #include <stdlib.h>
 #include <winsock.h>  #include <winsock.h>
 #include <wsipx.h>  #include <wsipx.h>
 #include <errno.h>  //#include <errno.h>
   
 #include "ipx_drv.h"  #include "ipx_drv.h"
   
 #include "mono.h"  #include "mono.h"
   
   static ipx_socket_t mysock;
   
 //#define n_printf(format, args...) mprintf((1, format, ## args))  //#define n_printf(format, args...) mprintf((1, format, ## args))
   
 static int ipx_win_GetMyAddress( void )  static int ipx_win_GetMyAddress( void )
Line 66
 
Line 68
   return(0);    return(0);
 }  }
   
 static int ipx_win_OpenSocket(ipx_socket_t *sk, int port)  static int ipx_win_OpenSocket(int port)
 {  {
   int sock; /* sock here means Linux socket handle */    int sock; /* sock here means Linux socket handle */
   int opt;    int opt;
Line 74
 
Line 76
   int len;    int len;
   struct sockaddr_ipx ipxs2;    struct sockaddr_ipx ipxs2;
   
           WORD wVersionRequested;
           WSADATA wsaData;
   
           wVersionRequested = MAKEWORD(2, 0);
           if (WSAStartup( wVersionRequested, &wsaData))
           {
             return -1;
           }
   #if 0
           if ( LOBYTE( wsaData.wVersion ) != 2 ||
             HIBYTE( wsaData.wVersion ) != 0 ) {
              /* We couldn't find a usable WinSock DLL. */
              WSACleanup( );
              return -2;
           }
   #endif
   
   
   /* DANG_FIXTHIS - kludge to support broken linux IPX stack */    /* DANG_FIXTHIS - kludge to support broken linux IPX stack */
   /* need to convert dynamic socket open into a real socket number */    /* need to convert dynamic socket open into a real socket number */
 /*  if (port == 0) {  /*  if (port == 0) {
Line 137
 
Line 157
   memcpy(ipx_MyAddress, ipxs2.sa_netnum, 4);    memcpy(ipx_MyAddress, ipxs2.sa_netnum, 4);
   memcpy(ipx_MyAddress + 4, ipxs2.sa_nodenum, 6);    memcpy(ipx_MyAddress + 4, ipxs2.sa_nodenum, 6);
   
   sk->fd = sock;    mysock.fd = sock;
   sk->socket = port;    mysock.socket = port;
   
     ipx_win_GetMyAddress();
   
   return 0;    return 0;
 }  }
   
 static void ipx_win_CloseSocket(ipx_socket_t *mysock) {  static void ipx_win_CloseSocket(void) {
   /* now close the file descriptor for the socket, and free it */    /* now close the file descriptor for the socket, and free it */
   mprintf((1,"IPX: closing file descriptor on socket %x\n", mysock->socket));    mprintf((1,"IPX: closing file descriptor on socket %x\n", mysock.socket));
   closesocket(mysock->fd);    closesocket(mysock.fd);
     WSACleanup();
 }  }
   
 static int ipx_win_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader,  static int ipx_win_SendPacket(IPXPacket_t *IPXHeader,
  u_char *data, int dataLen) {   ubyte *data, int dataLen) {
   struct sockaddr_ipx ipxs;    struct sockaddr_ipx ipxs;
    
   ipxs.sa_family = AF_IPX;    ipxs.sa_family = AF_IPX;
Line 161
 
Line 185
 /*  ipxs.sa_netnum = htonl(MyNetwork); */  /*  ipxs.sa_netnum = htonl(MyNetwork); */
   }    }
   memcpy(&ipxs.sa_nodenum, IPXHeader->Destination.Node, 6);    memcpy(&ipxs.sa_nodenum, IPXHeader->Destination.Node, 6);
   memcpy(&ipxs.sa_socket, IPXHeader->Destination.Socket, 2);  //  memcpy(&ipxs.sa_socket, IPXHeader->Destination.Socket, 2);
     ipxs.sa_socket=htons(mysock.socket);
 //  ipxs.sa_type = IPXHeader->PacketType;  //  ipxs.sa_type = IPXHeader->PacketType;
   /* ipxs.sipx_port=htons(0x452); */    /* ipxs.sipx_port=htons(0x452); */
   return sendto(mysock->fd, data, dataLen, 0,    return sendto(mysock.fd, data, dataLen, 0,
       (struct sockaddr *) &ipxs, sizeof(ipxs));        (struct sockaddr *) &ipxs, sizeof(ipxs));
 }  }
   
 static int ipx_win_ReceivePacket(ipx_socket_t *s, char *buffer, int bufsize,   static int ipx_win_ReceivePacket(char *buffer, int bufsize,
  struct ipx_recv_data *rd) {   struct ipx_recv_data *rd) {
  int sz, size;   int sz, size;
  struct sockaddr_ipx ipxs;   struct sockaddr_ipx ipxs;
    
  sz = sizeof(ipxs);   sz = sizeof(ipxs);
  if ((size = recvfrom(s->fd, buffer, bufsize, 0,   if ((size = recvfrom(mysock.fd, buffer, bufsize, 0,
       (struct sockaddr *) &ipxs, &sz)) <= 0)        (struct sockaddr *) &ipxs, &sz)) <= 0)
       return size;        return size;
         memcpy(rd->src_network, ipxs.sa_netnum, 4);          memcpy(rd->src_network, ipxs.sa_netnum, 4);
  memcpy(rd->src_node, ipxs.sa_nodenum, 6);   memcpy(rd->src_node, ipxs.sa_nodenum, 6);
  rd->src_socket = ipxs.sa_socket;   rd->src_socket = ipxs.sa_socket;
  rd->dst_socket = s->socket;   rd->dst_socket = mysock.socket;
 // rd->pkt_type = ipxs.sipx_type;  // rd->pkt_type = ipxs.sipx_type;
      
  return size;   return size;
 }  }
   
   static int ipx_win_general_PacketReady(void) {
    return ipx_general_PacketReady(mysock.fd);
   }
   
 struct ipx_driver ipx_win = {  struct ipx_driver ipx_win = {
  ipx_win_GetMyAddress,  // ipx_win_GetMyAddress,
  ipx_win_OpenSocket,   ipx_win_OpenSocket,
  ipx_win_CloseSocket,   ipx_win_CloseSocket,
  ipx_win_SendPacket,   ipx_win_SendPacket,
  ipx_win_ReceivePacket,   ipx_win_ReceivePacket,
  ipx_general_PacketReady   ipx_win_general_PacketReady,
    NULL,
    1,
    NULL,
    NULL,
    NULL
 };  };

Legend:
line(s) removed in v.1.3 
line(s) changed
 line(s) added in v.1.4