2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
15 * $Source: /cvs/cvsroot/d2x/arch/dos_ipx.c,v $
18 * $Date: 2001-01-29 13:35:08 $
20 * Routines for IPX communications.
22 * $Log: not supported by cvs2svn $
23 * Revision 1.1.1.1 2001/01/19 03:30:15 bradleyb
26 * Revision 1.1.1.1 1999/06/14 21:58:22 donut
27 * Import of d1x 1.37 source.
29 * Revision 2.10 1995/03/29 17:27:55 john
30 * Added code to not duplicate broadcasts.
32 * Revision 2.9 1995/03/29 15:32:07 john
35 * Revision 2.8 1995/03/29 15:07:31 john
36 * Added network support.
38 * Revision 2.7 1995/03/29 11:22:27 john
39 * Added broadcasting over a net.
41 * Revision 2.6 1995/03/28 20:05:03 john
42 * Took away alternate server stuff.
44 * Revision 2.5 1995/03/23 19:14:29 john
45 * Added better MAX_USERS message.
47 * Revision 2.4 1995/03/23 19:00:02 john
48 * Added user list capabitly.
50 * Revision 2.3 1995/03/23 12:27:05 john
51 * Move IPX into bios lib.
53 * Revision 2.2 1995/03/22 19:08:15 john
54 * Added code to fix sending packets over router... now
55 * we just need to make broadcasts go over router!!
57 * Revision 2.1 1995/03/21 08:40:16 john
58 * Ifdef'd out the NETWORK code.
60 * Revision 2.0 1995/02/27 11:30:45 john
61 * New version 2.0, which has no anonymous unions, builds with
62 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
64 * Revision 1.31 1995/02/16 17:35:03 john
65 * Added code to allow dynamic socket changing.
67 * Revision 1.30 1995/02/01 21:03:45 john
70 * Revision 1.29 1995/01/22 14:31:05 john
73 * Revision 1.28 1995/01/22 14:29:26 john
74 * Added code to bypass broadcast messages.
76 * Revision 1.27 1995/01/03 13:46:16 john
77 * Added code that should make ipx work over different servers,
78 * but ifdef'd it out with SHAREWARE in ipx.c. I haven't tested
79 * this, and I hope it doesn't introduce net bugs.
81 * Revision 1.26 1994/12/14 11:54:37 rob
82 * Reduce # of ipx packets.
84 * Revision 1.25 1994/12/11 00:43:28 john
85 * Locked down DOS ipx buffers... probably not necessary, tho.
87 * Revision 1.24 1994/12/08 15:49:58 rob
88 * Bumped up the # of ipx packets.
90 * Revision 1.23 1994/12/04 15:23:54 rob
91 * Reduced packet # constants.
93 * Revision 1.22 1994/11/27 23:12:39 matt
94 * Made changes for new mprintf calling convention
96 * Revision 1.21 1994/11/19 15:15:19 mike
97 * remove unused code and data
99 * Revision 1.20 1994/11/10 11:06:07 rob
100 * Raised number of ipx packets to 64 and buffers to 128 (for 8-way games)
101 * Removed (commented out) all the spx support stuff.
103 * Revision 1.19 1994/11/07 17:50:12 rob
104 * Bumped up max_packets and ipx_num_packets to double their previous
107 * Revision 1.18 1994/11/07 15:39:01 rob
108 * Removed temporary hacked ipx_send_object function.
109 * Replaced with a more general thing.
111 * Revision 1.17 1994/11/05 16:08:40 rob
112 * Made a change necessary for object syncing on rejoin.
114 * Revision 1.16 1994/11/01 15:57:12 rob
115 * Added support for SPX sockets for critical messages.
117 * Revision 1.15 1994/10/31 19:21:01 rob
118 * Added a routine for sending objects via ipx. Its a hack and shoukld
119 * be replaced by something more general time permitting.
121 * Revision 1.14 1994/10/20 14:57:42 john
124 * Revision 1.13 1994/10/20 11:22:45 john
125 * Tweaked the number of waiting packets. Added code to print
126 * total packets missed, and to limit the packet send rate to
127 * 10 packets per second unless firing.
129 * Revision 1.12 1994/10/03 20:50:11 john
130 * Started adding sound pause functions.
132 * Revision 1.11 1994/09/15 08:54:24 mike
133 * comment out a mprintf.
135 * Revision 1.10 1994/09/12 19:38:20 john
136 * Made some stuff that prints to the DOS screen go to the
137 * mono instead, since it really is debugging info.
139 * Revision 1.9 1994/09/07 13:32:03 john
140 * Made ipx_close explicitly close the socket we were using,
141 * because it seems that VLM's don't automatically close them
142 * like the older NETX stuff did (Going from Novell 3.11 driver
145 * Revision 1.8 1994/09/06 19:29:20 john
146 * Added trial version of rejoin function.
148 * Revision 1.7 1994/08/09 19:31:50 john
149 * Networking changes.
151 * Revision 1.6 1994/08/05 16:11:41 john
152 * Psuedo working version of networking.
154 * Revision 1.5 1994/08/04 19:17:21 john
155 * Inbetween version of network stuff.
157 * Revision 1.4 1994/07/29 16:08:57 john
158 * *** empty log message ***
160 * Revision 1.3 1994/07/25 12:33:31 john
161 * Network "pinging" in.
163 * Revision 1.2 1994/07/20 15:58:28 john
164 * First installment of ipx stuff.
166 * Revision 1.1 1994/07/19 15:42:00 john
177 static char rcsid[] = "$Id: dos_ipx.c,v 1.2 2001-01-29 13:35:08 bradleyb Exp $";
181 #define _BORLAND_DOS_REGS 1
199 typedef unsigned char BYTE;
200 typedef unsigned short WORD;
201 typedef unsigned long DWORD;
203 typedef struct local_address {
205 } __pack__ local_address;
207 typedef struct net_address {
209 local_address node_id;
211 } __pack__ net_address;
213 typedef struct ipx_header {
216 BYTE transport_control;
218 net_address destination;
220 } __pack__ ipx_header;
222 typedef struct ecb_header {
226 BYTE completion_code;
228 BYTE ipx_reserved[14];
230 local_address immediate_address;
232 WORD fragment_pointer[2];
234 } __pack__ ecb_header;
236 typedef struct packet_data {
238 byte data[IPX_MAX_DATA_SIZE];
239 } __pack__ packet_data;
241 typedef struct ipx_packet {
245 } __pack__ ipx_packet;
247 typedef struct user_address {
251 } __pack__ user_address;
254 int Ipx_num_users = 0;
255 user_address Ipx_users[MAX_USERS];
257 #define MAX_NETWORKS 64
258 int Ipx_num_networks = 0;
259 uint Ipx_networks[MAX_NETWORKS];
261 int ipx_packetnum = 0;
263 #define MAX_PACKETS 64
265 static packet_data packet_buffers[MAX_PACKETS];
266 static short packet_free_list[MAX_PACKETS];
267 static int num_packets = 0;
268 static int largest_packet_index = 0;
269 static short packet_size[MAX_PACKETS];
272 ubyte ipx_installed=0;
273 WORD ipx_vector_segment;
274 WORD ipx_vector_offset;
275 ubyte ipx_socket_life = 0; // 0=closed at prog termination, 0xff=closed when requested.
276 DWORD ipx_network = 0;
277 local_address ipx_my_node;
278 WORD ipx_num_packets=32; // 32 Ipx packets
279 ipx_packet * packets;
281 ushort ipx_packets_selector;
283 ecb_header * last_ecb=NULL;
286 void got_new_packet( ecb_header * ecb );
287 void ipx_listen_for_packet(ecb_header * ecb );
289 void free_packet( int id )
291 packet_buffers[id].packetnum = -1;
292 packet_free_list[ --num_packets ] = id;
293 if (largest_packet_index==id)
294 while ((--largest_packet_index>0) && (packet_buffers[largest_packet_index].packetnum == -1 ));
297 int ipx_get_packet_data( ubyte * data )
299 int i, n, best, best_id, size;
301 for (i=1; i<ipx_num_packets; i++ ) {
302 if ( !packets[i].ecb.in_use ) {
303 got_new_packet( &packets[i].ecb );
304 packets[i].ecb.in_use = 0;
305 ipx_listen_for_packet(&packets[i].ecb);
313 for (i=0; i<=largest_packet_index; i++ ) {
314 if ( packet_buffers[i].packetnum > -1 ) {
316 if ( best == -1 || (packet_buffers[i].packetnum<best) ) {
317 best = packet_buffers[i].packetnum;
323 //mprintf( (0, "Best id = %d, pn = %d, last_ecb = %x, len=%x, ne = %d\n", best_id, best, last_ecb, lastlen, neterrors ));
324 //mprintf( (1, "<%d> ", neterrors ));
326 if ( best_id < 0 ) return 0;
328 size = packet_size[best_id];
329 memcpy( data, packet_buffers[best_id].data, size );
330 free_packet(best_id);
336 unsigned int swap_short( unsigned int short )
337 #pragma aux swap_short parm [eax] = "xchg al,ah";
339 static inline unsigned int swap_short( unsigned int sshort ) {
341 asm("xchg %%ah,%%al" : "=a" (__retval) : "a" (sshort));
346 void got_new_packet( ecb_header * ecb )
350 unsigned short datasize;
354 p = (ipx_packet *)ecb;
356 if ( p->ecb.in_use ) { neterrors++; return; }
357 if ( p->ecb.completion_code ) { neterrors++; return; }
359 // Error( "Recieve error %d for completion code", p->ecb.completion_code );
361 if ( memcmp( &p->ipx.source.node_id, &ipx_my_node, 6 ) ) {
362 datasize=swap_short(p->ipx.length);
364 datasize -= sizeof(ipx_header);
365 // Find slot to put packet in...
366 if ( datasize > 0 && datasize <= sizeof(packet_data) ) {
367 if ( num_packets >= MAX_PACKETS ) {
368 //printf( 1, "IPX: Packet buffer overrun!!!\n" );
372 id = packet_free_list[ num_packets++ ];
373 if (id > largest_packet_index ) largest_packet_index = id;
374 packet_size[id] = datasize-sizeof(int);
375 packet_buffers[id].packetnum = p->pd.packetnum;
376 if ( packet_buffers[id].packetnum < 0 ) { neterrors++; return; }
377 memcpy( packet_buffers[id].data, p->pd.data, packet_size[id] );
384 //ipx_listen_for_packet(&p->ecb);
387 ubyte * ipx_get_my_local_address()
389 return ipx_my_node.address;
392 ubyte * ipx_get_my_server_address()
394 return (ubyte *)&ipx_network;
397 void ipx_listen_for_packet(ecb_header * ecb )
399 dpmi_real_regs rregs;
401 memset(&rregs,0,sizeof(dpmi_real_regs));
402 rregs.ebx = 4; // Listen For Packet function
403 rregs.esi = DPMI_real_offset(ecb);
404 rregs.es = DPMI_real_segment(ecb);
405 dpmi_real_int386x( 0x7A, &rregs );
408 void ipx_cancel_listen_for_packet(ecb_header * ecb )
410 dpmi_real_regs rregs;
411 memset(&rregs,0,sizeof(dpmi_real_regs));
412 rregs.ebx = 6; // IPX Cancel event
413 rregs.esi = DPMI_real_offset(ecb);
414 rregs.es = DPMI_real_segment(ecb);
415 dpmi_real_int386x( 0x7A, &rregs );
419 void ipx_send_packet(ecb_header * ecb )
421 dpmi_real_regs rregs;
422 memset(&rregs,0,sizeof(dpmi_real_regs));
423 rregs.ebx = 3; // Send Packet function
424 rregs.esi = DPMI_real_offset(ecb);
425 rregs.es = DPMI_real_segment(ecb);
426 dpmi_real_int386x( 0x7A, &rregs );
432 ubyte local_target[6];
433 } __pack__ net_xlat_info;
435 void ipx_get_local_target( ubyte * server, ubyte * node, ubyte * local_target )
437 net_xlat_info * info;
438 dpmi_real_regs rregs;
440 // Get dos memory for call...
441 info = (net_xlat_info *)dpmi_get_temp_low_buffer( sizeof(net_xlat_info) );
442 assert( info != NULL );
443 memcpy( info->network, server, 4 );
444 memcpy( info->node, node, 6 );
446 memset(&rregs,0,sizeof(dpmi_real_regs));
448 rregs.ebx = 2; // Get Local Target
449 rregs.es = DPMI_real_segment(info);
450 rregs.esi = DPMI_real_offset(info->network);
451 rregs.edi = DPMI_real_offset(info->local_target);
453 dpmi_real_int386x( 0x7A, &rregs );
455 // Save the local target...
456 memcpy( local_target, info->local_target, 6 );
461 dpmi_real_regs rregs;
462 if ( ipx_installed ) {
463 // When using VLM's instead of NETX, the sockets don't
464 // seem to automatically get closed, so we must explicitly
465 // close them at program termination.
467 memset(&rregs,0,sizeof(dpmi_real_regs));
468 rregs.edx = ipx_socket;
469 rregs.ebx = 1; // Close socket
470 dpmi_real_int386x( 0x7A, &rregs );
475 //---------------------------------------------------------------
476 // Initializes all IPX internals.
477 // If socket_number==0, then opens next available socket.
478 // Returns: 0 if successful.
479 // -1 if socket already open.
480 // -2 if socket table full.
481 // -3 if IPX not installed.
482 // -4 if couldn't allocate low dos memory
483 // -5 if error with getting internetwork address
485 int ipx_init( int socket_number, int show_address )
487 dpmi_real_regs rregs;
488 ubyte *ipx_real_buffer;
495 // init packet buffers.
496 for (i=0; i<MAX_PACKETS; i++ ) {
497 packet_buffers[i].packetnum = -1;
498 packet_free_list[i] = i;
501 largest_packet_index = 0;
503 // Get the IPX vector
504 memset(&rregs,0,sizeof(dpmi_real_regs));
505 rregs.eax=0x00007a00;
506 dpmi_real_int386x( 0x2f, &rregs );
508 if ( (rregs.eax & 0xFF) != 0xFF ) {
511 ipx_vector_offset = rregs.edi & 0xFFFF;
512 ipx_vector_segment = rregs.es;
513 //printf( "IPX entry point at %.4x:%.4x\n", ipx_vector_segment, ipx_vector_offset );
515 // Open a socket for IPX
517 memset(&rregs,0,sizeof(dpmi_real_regs));
518 swab( (char *)&socket_number,(char *)&ipx_socket, 2 );
519 rregs.edx = ipx_socket;
520 rregs.eax = ipx_socket_life;
521 rregs.ebx = 0; // Open socket
522 dpmi_real_int386x( 0x7A, &rregs );
524 ipx_socket = rregs.edx & 0xFFFF;
526 if ( rregs.eax & 0xFF ) {
527 //mprintf( (1, "IPX error opening channel %d\n", socket_number-IPX_DEFAULT_SOCKET ));
533 // Find our internetwork address
534 ipx_real_buffer = dpmi_get_temp_low_buffer( 1024 ); // 1k block
535 if ( ipx_real_buffer == NULL ) {
536 //printf( "Error allocation realmode memory\n" );
540 memset(&rregs,0,sizeof(dpmi_real_regs));
541 rregs.ebx = 9; // Get internetwork address
542 rregs.esi = DPMI_real_offset(ipx_real_buffer);
543 rregs.es = DPMI_real_segment(ipx_real_buffer);
544 dpmi_real_int386x( 0x7A, &rregs );
546 if ( rregs.eax & 0xFF ) {
547 //printf( "Error getting internetwork address!\n" );
551 memcpy( &ipx_network, ipx_real_buffer, 4 );
552 memcpy( &ipx_my_node, &ipx_real_buffer[4], 6 );
554 Ipx_num_networks = 0;
555 memcpy( &Ipx_networks[Ipx_num_networks++], &ipx_network, 4 );
557 if ( show_address ) {
558 printf( "My IPX addresss is " );
559 printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] );
560 printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] );
564 packets = dpmi_real_malloc( sizeof(ipx_packet)*ipx_num_packets, &ipx_packets_selector );
565 if ( packets == NULL ) {
566 //printf( "Couldn't allocate real memory for %d packets\n", ipx_num_packets );
569 #if 0 /* adb: not needed, fails with cwsdpmi */
570 if (!dpmi_lock_region( packets, sizeof(ipx_packet)*ipx_num_packets )) {
571 //printf( "Couldn't lock real memory for %d packets\n", ipx_num_packets );
575 memset( packets, 0, sizeof(ipx_packet)*ipx_num_packets );
577 for (i=1; i<ipx_num_packets; i++ ) {
578 packets[i].ecb.in_use = 0x1d;
579 //packets[i].ecb.in_use = 0;
580 packets[i].ecb.socket_id = ipx_socket;
581 packets[i].ecb.fragment_count = 1;
582 packets[i].ecb.fragment_pointer[0] = DPMI_real_offset(&packets[i].ipx);
583 packets[i].ecb.fragment_pointer[1] = DPMI_real_segment(&packets[i].ipx);
584 packets[i].ecb.fragment_size = sizeof(ipx_packet)-sizeof(ecb_header); //-sizeof(ecb_header);
586 ipx_listen_for_packet(&packets[i].ecb);
589 packets[0].ecb.socket_id = ipx_socket;
590 packets[0].ecb.fragment_count = 1;
591 packets[0].ecb.fragment_pointer[0] = DPMI_real_offset(&packets[0].ipx);
592 packets[0].ecb.fragment_pointer[1] = DPMI_real_segment(&packets[0].ipx);
593 packets[0].ipx.packet_type = 4; // IPX packet
594 packets[0].ipx.destination.socket_id = ipx_socket;
595 // memcpy( packets[0].ipx.destination.network_id, &ipx_network, 4 );
596 memset( packets[0].ipx.destination.network_id, 0, 4 );
601 void ipx_send_packet_data( ubyte * data, int datasize, ubyte *network, ubyte *address, ubyte *immediate_address )
603 assert(ipx_installed);
605 if ( datasize >= IPX_MAX_DATA_SIZE ) {
606 printf( "Data too big\n" );
607 //added/replaced on 11/8/98 by Victor Rachels to stop crappage
610 //end this section replacement - VR
613 // Make sure no one is already sending something
614 while( packets[0].ecb.in_use )
618 if (packets[0].ecb.completion_code) {
619 // printf( "Send error %d for completion code\n", packets[0].ecb.completion_code );
620 //added/replaced on 11/8/98 by Victor Rachels to stop crappage
623 //end this section replacement - VR
627 // Fill in destination address
628 if ( memcmp( network, &ipx_network, 4 ) )
629 memcpy( packets[0].ipx.destination.network_id, network, 4 );
631 memset( packets[0].ipx.destination.network_id, 0, 4 );
632 memcpy( packets[0].ipx.destination.node_id.address, address, 6 );
633 memcpy( packets[0].ecb.immediate_address.address, immediate_address, 6 );
634 packets[0].pd.packetnum = ipx_packetnum++;
636 // Fill in data to send
637 packets[0].ecb.fragment_size = sizeof(ipx_header) + sizeof(int) + datasize;
639 assert( datasize > 1 );
640 assert( packets[0].ecb.fragment_size <= 576 );
642 memcpy( packets[0].pd.data, data, datasize );
645 ipx_send_packet( &packets[0].ecb );
649 void ipx_send_broadcast_packet_data( ubyte * data, int datasize )
652 ubyte broadcast[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
653 ubyte local_address[6];
655 // Set to all networks besides mine
656 for (i=0; i<Ipx_num_networks; i++ ) {
657 if ( memcmp( &Ipx_networks[i], &ipx_network, 4 ) ) {
658 ipx_get_local_target( (ubyte *)&Ipx_networks[i], broadcast, local_address );
659 ipx_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast, local_address );
661 ipx_send_packet_data( data, datasize, (ubyte *)&Ipx_networks[i], broadcast, broadcast );
665 //OLDipx_send_packet_data( data, datasize, (ubyte *)&ipx_network, broadcast, broadcast );
667 // Send directly to all users not on my network or in the network list.
668 for (i=0; i<Ipx_num_users; i++ ) {
669 if ( memcmp( Ipx_users[i].network, &ipx_network, 4 ) ) {
670 for (j=0; j<Ipx_num_networks; j++ ) {
671 if (!memcmp( Ipx_users[i].network, &Ipx_networks[j], 4 ))
674 ipx_send_packet_data( data, datasize, Ipx_users[i].network, Ipx_users[i].node, Ipx_users[i].address );
681 // Sends a non-localized packet... needs 4 byte server, 6 byte address
682 void ipx_send_internetwork_packet_data( ubyte * data, int datasize, ubyte * server, ubyte *address )
684 ubyte local_address[6];
686 if ( (*(uint *)server) != 0 ) {
687 ipx_get_local_target( server, address, local_address );
688 ipx_send_packet_data( data, datasize, server, address, local_address );
690 // Old method, no server info.
691 ipx_send_packet_data( data, datasize, server, address, address );
695 int ipx_change_default_socket( ushort socket_number )
699 dpmi_real_regs rregs;
701 if ( !ipx_installed ) return -3;
704 memset(&rregs,0,sizeof(dpmi_real_regs));
705 swab( (char *)&socket_number,(char *)&new_ipx_socket, 2 );
706 rregs.edx = new_ipx_socket;
707 rregs.eax = ipx_socket_life;
708 rregs.ebx = 0; // Open socket
709 dpmi_real_int386x( 0x7A, &rregs );
711 new_ipx_socket = rregs.edx & 0xFFFF;
713 if ( rregs.eax & 0xFF ) {
714 //printf( (1, "IPX error opening channel %d\n", socket_number-IPX_DEFAULT_SOCKET ));
718 for (i=1; i<ipx_num_packets; i++ ) {
719 ipx_cancel_listen_for_packet(&packets[i].ecb);
722 // Close existing socket...
723 memset(&rregs,0,sizeof(dpmi_real_regs));
724 rregs.edx = ipx_socket;
725 rregs.ebx = 1; // Close socket
726 dpmi_real_int386x( 0x7A, &rregs );
728 ipx_socket = new_ipx_socket;
730 // Repost all listen requests on the new socket...
731 for (i=1; i<ipx_num_packets; i++ ) {
732 packets[i].ecb.in_use = 0;
733 packets[i].ecb.socket_id = ipx_socket;
734 ipx_listen_for_packet(&packets[i].ecb);
737 packets[0].ecb.socket_id = ipx_socket;
738 packets[0].ipx.destination.socket_id = ipx_socket;
741 // init packet buffers.
742 for (i=0; i<MAX_PACKETS; i++ ) {
743 packet_buffers[i].packetnum = -1;
744 packet_free_list[i] = i;
747 largest_packet_index = 0;
752 void ipx_read_user_file(char * filename)
756 char temp_line[132], *p1;
759 if (!filename) return;
763 fp = fopen( filename, "rt" );
766 printf( "Broadcast Users:\n" );
768 while (fgets(temp_line, 132, fp)) {
770 p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0';
771 p1 = strchr(temp_line,';'); if (p1) *p1 = '\0';
772 n = sscanf( temp_line, "%2x%2x%2x%2x/%2x%2x%2x%2x%2x%2x",(unsigned int *)&tmp.network[0],(unsigned int *) &tmp.network[1],(unsigned int *) &tmp.network[2],(unsigned int *) &tmp.network[3],(unsigned int *) &tmp.node[0],(unsigned int *) &tmp.node[1],(unsigned int *) &tmp.node[2],(unsigned int *)&tmp.node[3],(unsigned int *) &tmp.node[4],(unsigned int *) &tmp.node[5] );
773 if ( n != 10 ) continue;
774 if ( Ipx_num_users < MAX_USERS ) {
775 ubyte * ipx_real_buffer = (ubyte *)&tmp;
776 ipx_get_local_target( tmp.network, tmp.node, tmp.address );
777 Ipx_users[Ipx_num_users++] = tmp;
778 printf( "%02X%02X%02X%02X/", ipx_real_buffer[0],ipx_real_buffer[1],ipx_real_buffer[2],ipx_real_buffer[3] );
779 printf( "%02X%02X%02X%02X%02X%02X\n", ipx_real_buffer[4],ipx_real_buffer[5],ipx_real_buffer[6],ipx_real_buffer[7],ipx_real_buffer[8],ipx_real_buffer[9] );
781 printf( "Too many addresses in %s! (Limit of %d)\n", filename, MAX_USERS );
790 void ipx_read_network_file(char * filename)
794 char temp_line[132], *p1;
797 if (!filename) return;
799 fp = fopen( filename, "rt" );
802 printf( "Using Networks:\n" );
803 for (i=0; i<Ipx_num_networks; i++ ) {
804 ubyte * n1 = (ubyte *)&Ipx_networks[i];
805 printf("* %02x%02x%02x%02x\n", n1[0], n1[1], n1[2], n1[3] );
808 while (fgets(temp_line, 132, fp)) {
810 p1 = strchr(temp_line,'\n'); if (p1) *p1 = '\0';
811 p1 = strchr(temp_line,';'); if (p1) *p1 = '\0';
812 n = sscanf( temp_line, "%2x%2x%2x%2x",(unsigned int *) &tmp.network[0],(unsigned int *) &tmp.network[1],(unsigned int *) &tmp.network[2],(unsigned int *) &tmp.network[3] );
813 if ( n != 4 ) continue;
814 if ( Ipx_num_networks < MAX_NETWORKS ) {
816 for (j=0; j<Ipx_num_networks; j++ )
817 if ( !memcmp( &Ipx_networks[j], tmp.network, 4 ) )
819 if ( j >= Ipx_num_networks ) {
820 memcpy( &Ipx_networks[Ipx_num_networks++], tmp.network, 4 );
821 printf(" %02x%02x%02x%02x\n", tmp.network[0], tmp.network[1], tmp.network[2], tmp.network[3] );
824 printf( "Too many networks in %s! (Limit of %d)\n", filename, MAX_NETWORKS );
833 //---typedef struct rip_entry {
839 //---typedef struct rip_packet {
840 //--- ushort operation; //1=request, 2=response
841 //--- rip_entry rip[50];
845 //---void ipx_find_all_servers()
848 //--- rip_packet * rp;
849 //--- assert(ipx_installed);
851 //--- ipx_change_default_socket( 0x0453 );
852 //--- // ipx_change_default_socket( 0x5304 );
854 //--- // Make sure no one is already sending something
855 //--- while( packets[0].ecb.in_use )
859 //--- if (packets[0].ecb.completion_code) {
860 //--- printf( "AAAA:Send error %d for completion code\n", packets[0].ecb.completion_code );
864 //--- rp = (rip_packet *)&packets[0].pd;
866 //--- // Fill in destination address
868 //--- char mzero1[] = {0,0,0,1};
869 //--- char mzero[] = {0,0,0,0,0,1};
870 //--- char immediate[6];
871 //--- //memcpy( packets[0].ipx.destination.network_id, &ipx_network, 4 );
872 //--- //memcpy( packets[0].ipx.destination.node_id.address, ipx_my_node.address, 6 );
874 //--- memcpy( packets[0].ipx.destination.network_id, mzero1, 4 );
875 //--- memcpy( packets[0].ipx.destination.node_id.address, mzero, 6 );
877 //--- memcpy( packets[0].ipx.destination.socket_id, &ipx_socket, 2 );
878 //--- memcpy( packets[0].ipx.source.network_id, &ipx_network, 4 );
879 //--- memcpy( packets[0].ipx.source.node_id.address, ipx_my_node.address, 6 );
880 //--- memcpy( packets[0].ipx.source.socket_id, &ipx_socket, 2 );
881 //--- //memcpy( packets[0].ecb.immediate_address.address, ipx_my_node.address, 6 );
882 //--- //mzero1[3] = 1;
883 //--- //memcpy( packets[0].ipx.destination.network_id, mzero1, 4 );
884 //--- //mzero[5] = 1;
885 //--- //memcpy( packets[0].ipx.destination.node_id.address, mzero, 6 );
886 //--- //ipx_get_local_target( mzero1, mzero, immediate );
887 //--- //memcpy( packets[0].ecb.immediate_address.address, mzero, 6 );
888 //--- //memcpy( packets[0].ecb.immediate_address.address, immediate, 6 );
889 //--- //mzero[5] = 0;
892 //--- packets[0].ipx.packet_type = 1; // RIP packet
894 //--- // Fill in data to send
895 //--- packets[0].ecb.fragment_size = sizeof(ipx_header) + sizeof(rip_packet);
896 //--- assert( packets[0].ecb.fragment_size <= 576 );
898 //--- rp->operation = 0; // Request
899 //--- for (i=0;i<50; i++) {
900 //--- rp->rip[i].network = 0xFFFFFFFF;
901 //--- rp->rip[i].nhops = 0;
902 //--- rp->rip[i].nticks = 0;
906 //--- ipx_send_packet( &packets[0].ecb );
908 //--- for (i=0;i<50; i++) {
909 //--- if ( rp->rip[i].network != 0xFFFFFFFF )
910 //--- printf( "Network = %8x, Hops=%d, Ticks=%d\n", rp->rip[i].network, rp->rip[i].nhops, rp->rip[i].nticks );