~ubuntu-branches/ubuntu/feisty/basilisk2/feisty

« back to all changes in this revision

Viewing changes to src/BeOS/ether_beos.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2005-07-30 20:42:20 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050730204220-1nl1cg2jkjvy63ry
Tags: 0.9.20050730-1
* New upstream CVS snapshot.
* Build-depend on virtual libsdl-dev (not libsdl1.2-dev).
* Invoke init rules also on clean (to separate better from official
  builds).
* Update URL of upstream source in debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  ether_beos.cpp - Ethernet device driver, BeOS specific stuff
3
3
 *
4
 
 *  Basilisk II (C) 1997-2002 Christian Bauer
 
4
 *  Basilisk II (C) 1997-2005 Christian Bauer
5
5
 *  Portions written by Marc Hellwig
6
6
 *
7
7
 *  This program is free software; you can redistribute it and/or modify
461
461
void EtherInterrupt(void)
462
462
{
463
463
        D(bug("EtherIRQ\n"));
 
464
        EthernetPacket ether_packet;
 
465
        uint32 packet = ether_packet.addr();
464
466
 
465
467
        if (udp_tunnel) {
466
468
 
467
 
                uint8 packet[1514];
468
469
                ssize_t length;
469
470
 
470
471
                // Read packets from socket and hand to ether_udp_read() for processing
471
472
                while (true) {
472
473
                        struct sockaddr_in from;
473
474
                        socklen_t from_len = sizeof(from);
474
 
                        length = recvfrom(fd, packet, 1514, 0, (struct sockaddr *)&from, &from_len);
 
475
                        length = recvfrom(fd, Mac2HostAddr(packet), 1514, 0, (struct sockaddr *)&from, &from_len);
475
476
                        if (length < 14)
476
477
                                break;
477
478
                        ether_udp_read(packet, length, &from);
483
484
                net_packet *p = &net_buffer_ptr->read[rd_pos];
484
485
                while (p->cmd & IN_USE) {
485
486
                        if ((p->cmd >> 8) == SHEEP_PACKET) {
 
487
                                Host2Mac_memcpy(packet, p->data, p->length);
486
488
#if MONITOR
487
489
                                bug("Receiving Ethernet packet:\n");
488
490
                                for (int i=0; i<p->length; i++) {
489
 
                                        bug("%02x ", p->data[i]);
 
491
                                        bug("%02x ", ReadMacInt8(packet + i));
490
492
                                }
491
493
                                bug("\n");
492
494
#endif
493
495
                                // Get packet type
494
 
                                uint16 type = ntohs(*(uint16 *)(p->data + 12));
 
496
                                uint16 type = ReadMacInt16(packet + 12);
495
497
 
496
498
                                // Look for protocol
497
499
                                NetProtocol *prot = find_protocol(type);
503
505
                                        goto next;
504
506
 
505
507
                                // Copy header to RHA
506
 
                                Host2Mac_memcpy(ether_data + ed_RHA, p->data, 14);
 
508
                                Mac2Mac_memcpy(ether_data + ed_RHA, packet, 14);
507
509
                                D(bug(" header %08lx%04lx %08lx%04lx %04lx\n", ReadMacInt32(ether_data + ed_RHA), ReadMacInt16(ether_data + ed_RHA + 4), ReadMacInt32(ether_data + ed_RHA + 6), ReadMacInt16(ether_data + ed_RHA + 10), ReadMacInt16(ether_data + ed_RHA + 12)));
508
510
 
509
511
                                // Call protocol handler
510
512
                                M68kRegisters r;
511
513
                                r.d[0] = type;                                                                  // Packet type
512
514
                                r.d[1] = p->length - 14;                                                // Remaining packet length (without header, for ReadPacket)
513
 
                                r.a[0] = (uint32)p->data + 14;                                  // Pointer to packet (host address, for ReadPacket)
 
515
                                r.a[0] = packet + 14;                                                   // Pointer to packet (Mac address, for ReadPacket)
514
516
                                r.a[3] = ether_data + ed_RHA + 14;                              // Pointer behind header in RHA
515
517
                                r.a[4] = ether_data + ed_ReadPacket;                    // Pointer to ReadPacket/ReadRest routines
516
518
                                D(bug(" calling protocol handler %08lx, type %08lx, length %08lx, data %08lx, rha %08lx, read_packet %08lx\n", prot->handler, r.d[0], r.d[1], r.a[0], r.a[3], r.a[4]));