| version 1.1 | | version 1.2 |
|---|
| | |
| | | |
| #include "mono.h" | | #include "mono.h" |
| | | |
| #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 ) |
| { | | { |
| | |
| | | |
| if(sock==-1) | | if(sock==-1) |
| { | | { |
| n_printf("IPX: could not open socket in GetMyAddress\n"); | | mprintf((1,"IPX: could not open socket in GetMyAddress\n")); |
| return(-1); | | return(-1); |
| } | | } |
| | | |
| | |
| | | |
| if(bind(sock,(struct sockaddr *)&ipxs,sizeof(ipxs))==-1) | | if(bind(sock,(struct sockaddr *)&ipxs,sizeof(ipxs))==-1) |
| { | | { |
| n_printf("IPX: could bind to network 0 in GetMyAddress\n"); | | mprintf((1,"IPX: could bind to network 0 in GetMyAddress\n")); |
| closesocket( sock ); | | closesocket( sock ); |
| return(-1); | | return(-1); |
| } | | } |
| | | |
| len = sizeof(ipxs2); | | len = sizeof(ipxs2); |
| if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { | | if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { |
| n_printf("IPX: could not get socket name in GetMyAddress\n"); | | mprintf((1,"IPX: could not get socket name in GetMyAddress\n")); |
| closesocket( sock ); | | closesocket( sock ); |
| return(-1); | | return(-1); |
| } | | } |
| | |
| /* 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) { |
| n_printf("IPX: using socket %x\n", nextDynamicSocket); | | mprintf((1,"IPX: using socket %x\n", nextDynamicSocket)); |
| port = nextDynamicSocket++; | | port = nextDynamicSocket++; |
| } | | } |
| */ | | */ |
| | |
| // sock = socket(AF_IPX, SOCK_DGRAM, PF_IPX); | | // sock = socket(AF_IPX, SOCK_DGRAM, PF_IPX); |
| sock = socket(AF_IPX, SOCK_DGRAM, 0); | | sock = socket(AF_IPX, SOCK_DGRAM, 0); |
| if (sock == -1) { | | if (sock == -1) { |
| n_printf("IPX: could not open IPX socket.\n"); | | mprintf((1,"IPX: could not open IPX socket.\n")); |
| return -1; | | return -1; |
| } | | } |
| | | |
| | |
| /* Permit broadcast output */ | | /* Permit broadcast output */ |
| if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, | | if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, |
| (const char *)&opt, sizeof(opt)) == -1) { | | (const char *)&opt, sizeof(opt)) == -1) { |
| n_printf("IPX: could not set socket option for broadcast.\n"); | | mprintf((1,"IPX: could not set socket option for broadcast.\n")); |
| return -1; | | return -1; |
| } | | } |
| ipxs.sa_family = AF_IPX; | | ipxs.sa_family = AF_IPX; |
| | |
| | | |
| /* now bind to this port */ | | /* now bind to this port */ |
| if (bind(sock, (struct sockaddr *) &ipxs, sizeof(ipxs)) == -1) { | | if (bind(sock, (struct sockaddr *) &ipxs, sizeof(ipxs)) == -1) { |
| n_printf("IPX: could not bind socket to address\n"); | | mprintf((1,"IPX: could not bind socket to address\n")); |
| closesocket( sock ); | | closesocket( sock ); |
| return -1; | | return -1; |
| } | | } |
| | |
| // } | | // } |
| len = sizeof(ipxs2); | | len = sizeof(ipxs2); |
| if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { | | if (getsockname(sock,(struct sockaddr *)&ipxs2,&len) < 0) { |
| n_printf("IPX: could not get socket name in IPXOpenSocket\n"); | | mprintf((1,"IPX: could not get socket name in IPXOpenSocket\n")); |
| closesocket( sock ); | | closesocket( sock ); |
| return -1; | | return -1; |
| } | | } |
| if (port == 0) { | | if (port == 0) { |
| port = htons(ipxs2.sa_socket); | | port = htons(ipxs2.sa_socket); |
| n_printf("IPX: opened dynamic socket %04x\n", port); | | mprintf((1,"IPX: opened dynamic socket %04x\n", port)); |
| } | | } |
| | | |
| memcpy(ipx_MyAddress, ipxs2.sa_netnum, 4); | | memcpy(ipx_MyAddress, ipxs2.sa_netnum, 4); |
| | |
| | | |
| static void ipx_win_CloseSocket(ipx_socket_t *mysock) { | | static void ipx_win_CloseSocket(ipx_socket_t *mysock) { |
| /* now close the file descriptor for the socket, and free it */ | | /* now close the file descriptor for the socket, and free it */ |
| n_printf("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); |
| } | | } |
| | | |