1 |
|
/* |
2 |
|
* ether_amiga.cpp - Ethernet device driver, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
188 |
|
* Reset |
189 |
|
*/ |
190 |
|
|
191 |
< |
void EtherReset(void) |
191 |
> |
void ether_reset(void) |
192 |
|
{ |
193 |
|
// Remove all protocols |
194 |
|
if (net_proc) |
392 |
|
ULONG dev_unit; |
393 |
|
|
394 |
|
str = PrefsFindString("ether"); |
395 |
< |
if (str) |
396 |
< |
{ |
395 |
> |
if (str) { |
396 |
|
const char *FirstSlash = strchr(str, '/'); |
397 |
|
const char *LastSlash = strrchr(str, '/'); |
398 |
|
|
399 |
< |
if (FirstSlash && FirstSlash && FirstSlash != LastSlash) |
400 |
< |
{ |
399 |
> |
if (FirstSlash && FirstSlash && FirstSlash != LastSlash) { |
400 |
> |
|
401 |
|
// Device name contains path, i.e. "Networks/xyzzy.device" |
402 |
|
const char *lp = str; |
403 |
|
char *dp = dev_name; |
409 |
|
if (strlen(dev_name) < 1) |
410 |
|
goto quit; |
411 |
|
|
412 |
< |
if (1 != sscanf(LastSlash, "/%ld", &dev_unit)) |
412 |
> |
if (sscanf(LastSlash, "/%ld", &dev_unit) != 1) |
413 |
|
goto quit; |
414 |
< |
|
415 |
< |
// printf("dev=<%s> unit=%d\n", dev_name, dev_unit); |
417 |
< |
} |
418 |
< |
else |
419 |
< |
{ |
420 |
< |
if (2 != sscanf(str, "%[^/]/%ld", dev_name, &dev_unit)) |
414 |
> |
} else { |
415 |
> |
if (sscanf(str, "%[^/]/%ld", dev_name, &dev_unit) != 2) |
416 |
|
goto quit; |
422 |
– |
} |
417 |
|
} |
418 |
< |
else |
418 |
> |
} else |
419 |
|
goto quit; |
420 |
|
|
421 |
|
// Open device |
422 |
|
control_io->ios2_BufferManagement = buffer_tags; |
423 |
|
od_error = OpenDevice((UBYTE *)dev_name, dev_unit, (struct IORequest *)control_io, 0); |
424 |
< |
if (0 != od_error || control_io->ios2_Req.io_Device == 0) |
431 |
< |
{ |
424 |
> |
if (od_error != 0 || control_io->ios2_Req.io_Device == 0) { |
425 |
|
printf("WARNING: OpenDevice(<%s>, unit=%d) returned error %d)\n", (UBYTE *)dev_name, dev_unit, od_error); |
426 |
|
goto quit; |
427 |
< |
} |
427 |
> |
} |
428 |
|
opened = true; |
429 |
|
|
430 |
|
// Is it Ethernet? |
578 |
|
} |
579 |
|
write_io->ios2_DataLength = len; |
580 |
|
|
581 |
< |
// Get destination address, set source address |
581 |
> |
// Get destination address |
582 |
|
uint32 hdr = ReadMacInt32(wds + 2); |
583 |
|
Mac2Host_memcpy(write_io->ios2_DstAddr, hdr, 6); |
591 |
– |
Host2Mac_memcpy(hdr + 6, ether_addr, 6); |
584 |
|
|
585 |
|
// Get packet type |
586 |
|
uint32 type = ReadMacInt16(hdr + 12); |