Changeset 3e6bca8 in mainline for uspace/lib/inet/include/inet/eth_addr.h
- Timestamp:
- 2021-08-08T17:30:29Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a7f7b9c3
- Parents:
- b4edc96
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/inet/include/inet/eth_addr.h
rb4edc96 r3e6bca8 41 41 42 42 #define ETH_ADDR_SIZE 6 43 #define ETH_ADDR_STR_SIZE (6 * 2 + 5) 43 44 45 #define ETH_ADDR_INITIALIZER(aa, bb, cc, dd, ee, ff) \ 46 { .a = ((uint64_t)(aa) << 40) | ((uint64_t)(bb) << 32) | \ 47 ((uint64_t)(cc) << 24) | ((uint64_t)(dd) << 16) | \ 48 ((uint64_t)(ee) << 8) | (ff) } 49 50 /** Ethernet address. 51 * 52 * Defined as a structure. This provides strong type checking. 53 * 54 * Since the structure is not opaque, this allows eth_addr_t to be 55 * allocated statically and copied around using the assignment operator. 56 * 57 * It is stored in the lower 48 bits of a 64-bit integer. This is an internal 58 * representation that allows simple and efficient operation. Most CPUs 59 * will be much faster (and we will need less instructions) operating 60 * on a single 64-bit integer than on six individual 8-bit integers. 61 * 62 * Kind reader will appreciate the cleverness and elegance of this 63 * representation. 64 */ 44 65 typedef struct { 45 uint 8_t b[ETH_ADDR_SIZE];66 uint64_t a; 46 67 } eth_addr_t; 68 69 /** Ethernet address in the form of a string */ 70 typedef struct { 71 char str[ETH_ADDR_STR_SIZE + 1]; 72 } eth_addr_str_t; 47 73 48 74 extern const eth_addr_t eth_addr_broadcast; … … 52 78 53 79 extern int eth_addr_compare(const eth_addr_t *, const eth_addr_t *); 80 extern void eth_addr_format(eth_addr_t *, eth_addr_str_t *); 54 81 55 82 #endif
Note:
See TracChangeset
for help on using the changeset viewer.