| version 1.1 | | version 1.2 |
|---|
| | |
| #define leave_priv_setting() | | #define leave_priv_setting() |
| #endif | | #endif |
| | | |
| | | static ipx_socket_t mysock; |
| | | |
| static int ipx_bsd_GetMyAddress( void ) | | static int ipx_bsd_GetMyAddress( void ) |
| { | | { |
| int sock; | | int sock; |
| | |
| return(0); | | return(0); |
| } | | } |
| | | |
| static int ipx_bsd_OpenSocket(ipx_socket_t *sk, int port) | | static int ipx_bsd_OpenSocket(int port) |
| { | | { |
| int sock; /* sock here means Linux socket handle */ | | int sock; /* sock here means Linux socket handle */ |
| int opt; | | int opt; |
| | |
| } | | } |
| } | | } |
| leave_priv_setting(); | | leave_priv_setting(); |
| sk->fd = sock; | | mysock.fd = sock; |
| sk->socket = port; | | mysock.socket = port; |
| | | |
| | | ipx_bsd_GetMyAddress(); |
| | | |
| return 0; | | return 0; |
| } | | } |
| | | |
| static void ipx_bsd_CloseSocket(ipx_socket_t *mysock) { | | static void ipx_bsd_CloseSocket(void) { |
| /* 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); | | n_printf("IPX: closing file descriptor on socket %x\n", mysock.socket); |
| close(mysock->fd); | | close(mysock.fd); |
| } | | } |
| | | |
| static int ipx_bsd_SendPacket(ipx_socket_t *mysock, IPXPacket_t *IPXHeader, | | static int ipx_bsd_SendPacket(IPXPacket_t *IPXHeader, |
| u_char *data, int dataLen) { | | u_char *data, int dataLen) { |
| struct sockaddr_ipx ipxs; | | struct sockaddr_ipx ipxs; |
| | | |
| | |
| /* ipxs.sipx_network = htonl(MyNetwork); */ | | /* ipxs.sipx_network = htonl(MyNetwork); */ |
| } | | } |
| memcpy(&ipxs.sipx_node, IPXHeader->Destination.Node, 6); | | memcpy(&ipxs.sipx_node, IPXHeader->Destination.Node, 6); |
| memcpy(&ipxs.sipx_port, IPXHeader->Destination.Socket, 2); | | //memcpy(&ipxs.sipx_port, IPXHeader->Destination.Socket, 2); |
| | | ipxs.sipx_port=htons(mysock.socket); |
| ipxs.sipx_type = IPXHeader->PacketType; | | ipxs.sipx_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_bsd_ReceivePacket(ipx_socket_t *s, char *buffer, int bufsize, | | static int ipx_bsd_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.sipx_network, 4); | | memcpy(rd->src_network, &ipxs.sipx_network, 4); |
| memcpy(rd->src_node, ipxs.sipx_node, 6); | | memcpy(rd->src_node, ipxs.sipx_node, 6); |
| rd->src_socket = ipxs.sipx_port; | | rd->src_socket = ipxs.sipx_port; |
| 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_bsd_general_PacketReady(void) { |
| | | return ipx_general_PacketReady(mysock.fd); |
| | | } |
| | | |
| struct ipx_driver ipx_bsd = { | | struct ipx_driver ipx_bsd = { |
| ipx_bsd_GetMyAddress, | | // ipx_bsd_GetMyAddress, |
| ipx_bsd_OpenSocket, | | ipx_bsd_OpenSocket, |
| ipx_bsd_CloseSocket, | | ipx_bsd_CloseSocket, |
| ipx_bsd_SendPacket, | | ipx_bsd_SendPacket, |
| ipx_bsd_ReceivePacket, | | ipx_bsd_ReceivePacket, |
| ipx_general_PacketReady | | ipx_bsd_general_PacketReady, |
| | | NULL, |
| | | 1, |
| | | NULL, |
| | | NULL, |
| | | NULL |
| }; | | }; |