--- BasiliskII/src/AmigaOS/ether_amiga.cpp 2000/08/20 14:08:41 1.5 +++ BasiliskII/src/AmigaOS/ether_amiga.cpp 2002/01/15 14:58:34 1.11 @@ -1,7 +1,7 @@ /* * ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2002 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,11 +116,11 @@ static int16 send_to_proc(uint32 what, u * Initialization */ -void EtherInit(void) +bool ether_init(void) { // Do nothing if no Ethernet device specified if (PrefsFindString("ether") == NULL) - return; + return false; // Initialize protocol list NewList(&prot_list); @@ -151,8 +151,7 @@ void EtherInit(void) goto open_error; // Everything OK - net_open = true; - return; + return true; open_error: net_proc = NULL; @@ -160,6 +159,7 @@ open_error: DeleteMsgPort(reply_port); reply_port = NULL; } + return false; } @@ -167,7 +167,7 @@ open_error: * Deinitialization */ -void EtherExit(void) +void ether_exit(void) { // Stop process if (net_proc) { @@ -188,10 +188,10 @@ void EtherExit(void) * Reset */ -void EtherReset(void) +void ether_reset(void) { // Remove all protocols - if (net_open) + if (net_proc) send_to_proc(MSG_CLEANUP); } @@ -392,13 +392,12 @@ static __saveds void net_func(void) ULONG dev_unit; str = PrefsFindString("ether"); - if (str) - { + if (str) { const char *FirstSlash = strchr(str, '/'); const char *LastSlash = strrchr(str, '/'); - if (FirstSlash && FirstSlash && FirstSlash != LastSlash) - { + if (FirstSlash && FirstSlash && FirstSlash != LastSlash) { + // Device name contains path, i.e. "Networks/xyzzy.device" const char *lp = str; char *dp = dev_name; @@ -410,28 +409,22 @@ static __saveds void net_func(void) if (strlen(dev_name) < 1) goto quit; - if (1 != sscanf(LastSlash, "/%ld", &dev_unit)) + if (sscanf(LastSlash, "/%ld", &dev_unit) != 1) goto quit; - -// printf("dev=<%s> unit=%d\n", dev_name, dev_unit); - } - else - { - if (2 != sscanf(str, "%[^/]/%ld", dev_name, &dev_unit)) + } else { + if (sscanf(str, "%[^/]/%ld", dev_name, &dev_unit) != 2) goto quit; - } } - else + } else goto quit; // Open device control_io->ios2_BufferManagement = buffer_tags; od_error = OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0); - if (0 != od_error || control_io->ios2_Req.io_Device == 0) - { + if (od_error != 0 || control_io->ios2_Req.io_Device == 0) { printf("WARNING: OpenDevice(<%s>, unit=%d) returned error %d)\n", (UBYTE *)dev_name, dev_unit, od_error); goto quit; - } + } opened = true; // Is it Ethernet? @@ -585,10 +578,9 @@ static __saveds void net_func(void) } write_io->ios2_DataLength = len; - // Get destination address, set source address + // Get destination address uint32 hdr = ReadMacInt32(wds + 2); Mac2Host_memcpy(write_io->ios2_DstAddr, hdr, 6); - Host2Mac_memcpy(hdr + 6, ether_addr, 6); // Get packet type uint32 type = ReadMacInt16(hdr + 12);