A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
link/nicmac.c@94:e2973a2c488e, 2018-12-05 (annotated)
- Committer:
- andrewboyson
- Date:
- Wed Dec 05 18:30:37 2018 +0000
- Revision:
- 94:e2973a2c488e
- Parent:
- 61:aad055f1b0d1
Fixed bug - incorrect MSS being sent from a polled sync: expected 1440 but had -60. Traced to buffer datalength in EthPollForPacketToSend being set to zero instead of being calculated from the buffer length - headersize.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 60:1d8c7a1e7483 | 1 | #include <stdint.h> |
andrewboyson | 60:1d8c7a1e7483 | 2 | #include <stdio.h> |
andrewboyson | 60:1d8c7a1e7483 | 3 | #include "log.h" |
andrewboyson | 60:1d8c7a1e7483 | 4 | |
andrewboyson | 60:1d8c7a1e7483 | 5 | #define USR_UID 0x101 |
andrewboyson | 60:1d8c7a1e7483 | 6 | #define DEVICE_ID_LENGTH 32 |
andrewboyson | 60:1d8c7a1e7483 | 7 | #define DEVICE_MAC_OFFSET 20 |
andrewboyson | 60:1d8c7a1e7483 | 8 | |
andrewboyson | 60:1d8c7a1e7483 | 9 | void NicMac(char *mac) //Do not call this outwith of an initialisation phase - the semihost call blocks interrupts. |
andrewboyson | 60:1d8c7a1e7483 | 10 | { |
andrewboyson | 60:1d8c7a1e7483 | 11 | char uid[DEVICE_ID_LENGTH + 1]; |
andrewboyson | 60:1d8c7a1e7483 | 12 | uint32_t args[2]; |
andrewboyson | 60:1d8c7a1e7483 | 13 | args[0] = (uint32_t)uid; |
andrewboyson | 60:1d8c7a1e7483 | 14 | args[1] = DEVICE_ID_LENGTH + 1; |
andrewboyson | 60:1d8c7a1e7483 | 15 | |
andrewboyson | 60:1d8c7a1e7483 | 16 | __semihost(USR_UID, &args); |
andrewboyson | 60:1d8c7a1e7483 | 17 | |
andrewboyson | 60:1d8c7a1e7483 | 18 | char *p = uid; |
andrewboyson | 60:1d8c7a1e7483 | 19 | p += DEVICE_MAC_OFFSET; |
andrewboyson | 60:1d8c7a1e7483 | 20 | for (int i=0; i<6; i++) |
andrewboyson | 60:1d8c7a1e7483 | 21 | { |
andrewboyson | 60:1d8c7a1e7483 | 22 | int byte; |
andrewboyson | 60:1d8c7a1e7483 | 23 | sscanf(p, "%2x", &byte); |
andrewboyson | 60:1d8c7a1e7483 | 24 | mac[i] = byte; |
andrewboyson | 60:1d8c7a1e7483 | 25 | p += 2; |
andrewboyson | 60:1d8c7a1e7483 | 26 | } |
andrewboyson | 60:1d8c7a1e7483 | 27 | mac[0] &= ~0x01; // reset the IG bit in the address; see IEE 802.3-2002, Section 3.2.3(b) |
andrewboyson | 60:1d8c7a1e7483 | 28 | } |