Changeset 609243f4 in mainline for uspace/lib
- Timestamp:
- 2011-10-07T15:46:01Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e2c50e1
- Parents:
- f51b1d3
- Location:
- uspace/lib
- Files:
-
- 5 added
- 4 deleted
- 39 edited
- 1 moved
-
c/Makefile (modified) (1 diff)
-
c/generic/device/nic.c (added)
-
c/generic/net/packet.c (modified) (8 diffs)
-
c/include/device/nic.h (added)
-
c/include/ipc/dev_iface.h (modified) (1 diff)
-
c/include/ipc/devman.h (modified) (1 diff)
-
c/include/ipc/il.h (modified) (1 diff)
-
c/include/ipc/net.h (modified) (3 diffs)
-
c/include/ipc/net_net.h (modified) (1 diff)
-
c/include/ipc/nil.h (modified) (1 diff)
-
c/include/ipc/services.h (modified) (1 diff)
-
c/include/net/device.h (modified) (4 diffs)
-
c/include/net/eth_phys.h (added)
-
c/include/net/packet.h (modified) (2 diffs)
-
c/include/net/packet_header.h (modified) (2 diffs)
-
drv/Makefile (modified) (1 diff)
-
drv/generic/dev_iface.c (modified) (2 diffs)
-
drv/generic/driver.c (modified) (2 diffs)
-
drv/generic/remote_nic.c (added)
-
drv/include/ddf/driver.h (modified) (1 diff)
-
drv/include/ops/nic.h (added)
-
drv/include/remote_nic.h (moved) (moved from uspace/lib/net/include/netif_remote.h ) (2 diffs)
-
net/Makefile (modified) (1 diff)
-
net/generic/generic.c (modified) (8 diffs)
-
net/generic/net_checksum.c (modified) (2 diffs)
-
net/generic/net_remote.c (modified) (4 diffs)
-
net/generic/protocol_map.c (modified) (3 diffs)
-
net/il/arp_remote.c (modified) (4 diffs)
-
net/il/il_remote.c (modified) (4 diffs)
-
net/il/ip_remote.c (modified) (7 diffs)
-
net/include/arp_interface.h (modified) (1 diff)
-
net/include/generic.h (modified) (1 diff)
-
net/include/il_remote.h (modified) (1 diff)
-
net/include/ip_interface.h (modified) (1 diff)
-
net/include/ip_remote.h (modified) (1 diff)
-
net/include/net_checksum.h (modified) (2 diffs)
-
net/include/net_interface.h (modified) (2 diffs)
-
net/include/netif_skel.h (deleted)
-
net/include/nil_remote.h (modified) (2 diffs)
-
net/include/nil_skel.h (modified) (3 diffs)
-
net/include/tl_common.h (modified) (1 diff)
-
net/include/tl_remote.h (modified) (1 diff)
-
net/netif/netif_remote.c (deleted)
-
net/netif/netif_skel.c (deleted)
-
net/nil/nil_remote.c (modified) (2 diffs)
-
net/tl/icmp_client.c (modified) (3 diffs)
-
net/tl/tl_common.c (modified) (4 diffs)
-
net/tl/tl_remote.c (modified) (1 diff)
-
packet/Makefile (deleted)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/Makefile
rf51b1d3 r609243f4 68 68 generic/device/hw_res.c \ 69 69 generic/device/char_dev.c \ 70 generic/device/nic.c \ 70 71 generic/elf/elf_load.c \ 71 72 generic/event.c \ -
uspace/lib/c/generic/net/packet.c
rf51b1d3 r609243f4 36 36 */ 37 37 38 #include <assert.h> 38 39 #include <malloc.h> 39 40 #include <mem.h> … … 44 45 #include <sys/mman.h> 45 46 46 #include <adt/ generic_field.h>47 #include <adt/hash_table.h> 47 48 #include <net/packet.h> 48 49 #include <net/packet_header.h> 49 50 50 /** Packet map page size. */ 51 #define PACKET_MAP_SIZE 100 52 53 /** Returns the packet map page index. 54 * @param[in] packet_id The packet identifier. 55 */ 56 #define PACKET_MAP_PAGE(packet_id) (((packet_id) - 1) / PACKET_MAP_SIZE) 57 58 /** Returns the packet index in the corresponding packet map page. 59 * @param[in] packet_id The packet identifier. 60 */ 61 #define PACKET_MAP_INDEX(packet_id) (((packet_id) - 1) % PACKET_MAP_SIZE) 62 63 /** Type definition of the packet map page. */ 64 typedef packet_t *packet_map_t[PACKET_MAP_SIZE]; 65 66 /** Packet map. 67 * Maps packet identifiers to the packet references. 68 * @see generic_field.h 69 */ 70 GENERIC_FIELD_DECLARE(gpm, packet_map_t); 51 /** Packet hash table size. */ 52 #define PACKET_HASH_TABLE_SIZE 128 71 53 72 54 /** Packet map global data. */ … … 75 57 fibril_rwlock_t lock; 76 58 /** Packet map. */ 77 gpm_t packet_map; 59 hash_table_t packet_map; 60 /** Packet map operations */ 61 hash_table_operations_t operations; 78 62 } pm_globals; 79 63 80 GENERIC_FIELD_IMPLEMENT(gpm, packet_map_t); 64 typedef struct { 65 link_t link; 66 packet_t *packet; 67 } pm_entry_t; 68 69 /** 70 * Hash function for the packet mapping hash table 71 */ 72 static hash_index_t pm_hash(unsigned long key[]) 73 { 74 return (hash_index_t) key[0] % PACKET_HASH_TABLE_SIZE; 75 } 76 77 /** 78 * Key compare function for the packet mapping hash table 79 */ 80 static int pm_compare(unsigned long key[], hash_count_t keys, link_t *link) 81 { 82 pm_entry_t *entry = list_get_instance(link, pm_entry_t, link); 83 return entry->packet->packet_id == key[0]; 84 } 85 86 /** 87 * Remove callback for the packet mapping hash table 88 */ 89 static void pm_remove_callback(link_t *link) 90 { 91 pm_entry_t *entry = list_get_instance(link, pm_entry_t, link); 92 free(entry); 93 } 94 95 /** 96 * Wrapper used when destroying the whole table 97 */ 98 static void pm_free_wrapper(link_t *link, void *ignored) 99 { 100 pm_entry_t *entry = list_get_instance(link, pm_entry_t, link); 101 free(entry); 102 } 103 81 104 82 105 /** Initializes the packet map. … … 87 110 int pm_init(void) 88 111 { 89 int rc ;112 int rc = EOK; 90 113 91 114 fibril_rwlock_initialize(&pm_globals.lock); 92 115 93 116 fibril_rwlock_write_lock(&pm_globals.lock); 94 rc = gpm_initialize(&pm_globals.packet_map); 117 118 pm_globals.operations.hash = pm_hash; 119 pm_globals.operations.compare = pm_compare; 120 pm_globals.operations.remove_callback = pm_remove_callback; 121 122 if (!hash_table_create(&pm_globals.packet_map, PACKET_HASH_TABLE_SIZE, 1, 123 &pm_globals.operations)) 124 rc = ENOMEM; 125 95 126 fibril_rwlock_write_unlock(&pm_globals.lock); 96 127 … … 100 131 /** Finds the packet mapping. 101 132 * 102 * @param[in] packet_id The packet identifier to be found. 103 * @return The found packet reference. 104 * @return NULL if the mapping does not exist. 133 * @param[in] packet_id Packet identifier to be found. 134 * 135 * @return The found packet reference. 136 * @return NULL if the mapping does not exist. 137 * 105 138 */ 106 139 packet_t *pm_find(packet_id_t packet_id) 107 140 { 108 packet_map_t *map;109 141 packet_t *packet; 110 111 142 if (!packet_id) 112 143 return NULL; 113 144 114 145 fibril_rwlock_read_lock(&pm_globals.lock); 115 if (packet_id > PACKET_MAP_SIZE * gpm_count(&pm_globals.packet_map)) { 116 fibril_rwlock_read_unlock(&pm_globals.lock); 117 return NULL; 118 } 119 map = gpm_get_index(&pm_globals.packet_map, PACKET_MAP_PAGE(packet_id)); 120 if (!map) { 121 fibril_rwlock_read_unlock(&pm_globals.lock); 122 return NULL; 123 } 124 packet = (*map) [PACKET_MAP_INDEX(packet_id)]; 146 link_t *link = 147 hash_table_find(&pm_globals.packet_map, &packet_id); 148 if (link != NULL) { 149 pm_entry_t *entry = 150 hash_table_get_instance(link, pm_entry_t, link); 151 packet = entry->packet; 152 } else 153 packet = NULL; 154 125 155 fibril_rwlock_read_unlock(&pm_globals.lock); 126 156 return packet; … … 129 159 /** Adds the packet mapping. 130 160 * 131 * @param[in] packet The packet to be remembered. 132 * @return EOK on success. 133 * @return EINVAL if the packet is not valid. 134 * @return EINVAL if the packet map is not initialized. 135 * @return ENOMEM if there is not enough memory left. 161 * @param[in] packet Packet to be remembered. 162 * 163 * @return EOK on success. 164 * @return EINVAL if the packet is not valid. 165 * @return ENOMEM if there is not enough memory left. 166 * 136 167 */ 137 168 int pm_add(packet_t *packet) 138 169 { 139 packet_map_t *map;140 int rc;141 142 170 if (!packet_is_valid(packet)) 143 171 return EINVAL; 144 172 145 173 fibril_rwlock_write_lock(&pm_globals.lock); 146 147 if (PACKET_MAP_PAGE(packet->packet_id) < 148 gpm_count(&pm_globals.packet_map)) { 149 map = gpm_get_index(&pm_globals.packet_map, 150 PACKET_MAP_PAGE(packet->packet_id)); 151 } else { 152 do { 153 map = (packet_map_t *) malloc(sizeof(packet_map_t)); 154 if (!map) { 155 fibril_rwlock_write_unlock(&pm_globals.lock); 156 return ENOMEM; 157 } 158 bzero(map, sizeof(packet_map_t)); 159 rc = gpm_add(&pm_globals.packet_map, map); 160 if (rc < 0) { 161 fibril_rwlock_write_unlock(&pm_globals.lock); 162 free(map); 163 return rc; 164 } 165 } while (PACKET_MAP_PAGE(packet->packet_id) >= 166 gpm_count(&pm_globals.packet_map)); 174 pm_entry_t *entry = malloc(sizeof (pm_entry_t)); 175 if (entry == NULL) { 176 fibril_rwlock_write_unlock(&pm_globals.lock); 177 return ENOMEM; 167 178 } 168 169 (*map) [PACKET_MAP_INDEX(packet->packet_id)] = packet; 179 180 entry->packet = packet; 181 hash_table_insert(&pm_globals.packet_map, &packet->packet_id, 182 &entry->link); 170 183 fibril_rwlock_write_unlock(&pm_globals.lock); 171 184 return EOK; 172 185 } 173 186 174 /** Releases the packet map. */ 187 /** Remove the packet mapping 188 * 189 * @param[in] packet The packet to be removed 190 * 191 */ 192 void pm_remove(packet_t *packet) 193 { 194 assert(packet_is_valid(packet)); 195 196 fibril_rwlock_write_lock(&pm_globals.lock); 197 hash_table_remove(&pm_globals.packet_map, &packet->packet_id, 1); 198 fibril_rwlock_write_unlock(&pm_globals.lock); 199 } 200 201 /** Release the packet map. */ 175 202 void pm_destroy(void) 176 203 { 177 int count;178 int index;179 packet_map_t *map;180 packet_t *packet;181 182 204 fibril_rwlock_write_lock(&pm_globals.lock); 183 count = gpm_count(&pm_globals.packet_map); 184 while (count > 0) { 185 map = gpm_get_index(&pm_globals.packet_map, count - 1); 186 for (index = PACKET_MAP_SIZE - 1; index >= 0; --index) { 187 packet = (*map)[index]; 188 if (packet_is_valid(packet)) 189 munmap(packet, packet->length); 190 } 191 } 192 gpm_destroy(&pm_globals.packet_map, free); 193 /* leave locked */ 205 hash_table_apply(&pm_globals.packet_map, pm_free_wrapper, NULL); 206 hash_table_destroy(&pm_globals.packet_map); 207 /* Leave locked */ 194 208 } 195 209 … … 199 213 * The packet is inserted right before the packets of the same order value. 200 214 * 201 * @param[in,out] first The first packet of the queue. Sets the first packet of 202 * the queue. The original first packet may be shifted by 203 * the new packet. 204 * @param[in] packet The packet to be added. 205 * @param[in] order The packet order value. 206 * @param[in] metric The metric value of the packet. 207 * @return EOK on success. 208 * @return EINVAL if the first parameter is NULL. 209 * @return EINVAL if the packet is not valid. 215 * @param[in,out] first First packet of the queue. Sets the first 216 * packet of the queue. The original first packet 217 * may be shifted by the new packet. 218 * @param[in] packet Packet to be added. 219 * @param[in] order Packet order value. 220 * @param[in] metric Metric value of the packet. 221 * 222 * @return EOK on success. 223 * @return EINVAL if the first parameter is NULL. 224 * @return EINVAL if the packet is not valid. 225 * 210 226 */ 211 227 int pq_add(packet_t **first, packet_t *packet, size_t order, size_t metric) 212 228 { 213 packet_t *item; 214 215 if (!first || !packet_is_valid(packet)) 229 if ((!first) || (!packet_is_valid(packet))) 216 230 return EINVAL; 217 231 218 232 pq_set_order(packet, order, metric); 219 233 if (packet_is_valid(*first)) { 220 item = * first; 234 packet_t *cur = *first; 235 221 236 do { 222 if (item->order < order) { 223 if (item->next) { 224 item = pm_find(item->next); 225 } else { 226 item->next = packet->packet_id; 227 packet->previous = item->packet_id; 237 if (cur->order < order) { 238 if (cur->next) 239 cur = pm_find(cur->next); 240 else { 241 cur->next = packet->packet_id; 242 packet->previous = cur->packet_id; 243 228 244 return EOK; 229 245 } 230 246 } else { 231 packet->previous = item->previous; 232 packet->next = item->packet_id; 233 item->previous = packet->packet_id; 234 item = pm_find(packet->previous); 235 if (item) 236 item->next = packet->packet_id; 247 packet->previous = cur->previous; 248 packet->next = cur->packet_id; 249 250 cur->previous = packet->packet_id; 251 cur = pm_find(packet->previous); 252 253 if (cur) 254 cur->next = packet->packet_id; 237 255 else 238 256 *first = packet; 257 239 258 return EOK; 240 259 } 241 } while (packet_is_valid( item));260 } while (packet_is_valid(cur)); 242 261 } 262 243 263 *first = packet; 244 264 return EOK; … … 312 332 313 333 next = pm_find(packet->next); 314 if (next) {334 if (next) 315 335 next->previous = packet->previous; 316 previous = pm_find(next->previous); 317 if (previous) 318 previous->next = next->packet_id; 319 } 336 337 previous = pm_find(packet->previous); 338 if (previous) 339 previous->next = packet->next ; 340 320 341 packet->previous = 0; 321 342 packet->next = 0; -
uspace/lib/c/include/ipc/dev_iface.h
rf51b1d3 r609243f4 36 36 typedef enum { 37 37 HW_RES_DEV_IFACE = 0, 38 /** Character device interface */ 38 39 CHAR_DEV_IFACE, 39 40 41 /** Network interface controller interface */ 42 NIC_DEV_IFACE, 43 40 44 /** Interface provided by any PCI device. */ 41 45 PCI_DEV_IFACE, -
uspace/lib/c/include/ipc/devman.h
rf51b1d3 r609243f4 146 146 typedef enum { 147 147 DRIVER_DEV_ADD = IPC_FIRST_USER_METHOD, 148 DRIVER_DEV_ADDED, 148 149 DRIVER_DEV_REMOVE, 149 150 DRIVER_DEV_GONE, -
uspace/lib/c/include/ipc/il.h
rf51b1d3 r609243f4 54 54 NET_IL_MTU_CHANGED, 55 55 56 /** 57 * Device address changed message 58 * @see il_addr_changed_msg() 59 */ 60 NET_IL_ADDR_CHANGED, 61 56 62 /** Packet received message. 57 63 * @see il_received_msg() -
uspace/lib/c/include/ipc/net.h
rf51b1d3 r609243f4 277 277 * 278 278 */ 279 #define IPC_GET_DEVICE(call) (( device_id_t) IPC_GET_ARG1(call))279 #define IPC_GET_DEVICE(call) ((nic_device_id_t) IPC_GET_ARG1(call)) 280 280 281 281 /** Return the packet identifier message argument. … … 298 298 * 299 299 */ 300 #define IPC_GET_STATE(call) ((device_state_t) IPC_GET_ARG2(call)) 300 #define IPC_GET_STATE(call) ((nic_device_state_t) IPC_GET_ARG2(call)) 301 302 /** Return the device handle argument 303 * 304 * @param[in] call Message call structure 305 * 306 */ 307 #define IPC_GET_DEVICE_HANDLE(call) ((devman_handle_t) IPC_GET_ARG2(call)) 308 309 /** Return the device driver service message argument. 310 * 311 * @param[in] call Message call structure. 312 * 313 */ 314 #define IPC_GET_SERVICE(call) ((services_t) IPC_GET_ARG3(call)) 315 316 /** Return the target service message argument. 317 * 318 * @param[in] call Message call structure. 319 * 320 */ 321 #define IPC_GET_TARGET(call) ((services_t) IPC_GET_ARG3(call)) 322 323 /** Return the sender service message argument. 324 * 325 * @param[in] call Message call structure. 326 * 327 */ 328 #define IPC_GET_SENDER(call) ((services_t) IPC_GET_ARG3(call)) 301 329 302 330 /** Return the maximum transmission unit message argument. … … 305 333 * 306 334 */ 307 #define IPC_GET_MTU(call) ((size_t) IPC_GET_ARG2(call)) 308 309 /** Return the device driver service message argument. 310 * 311 * @param[in] call Message call structure. 312 * 313 */ 314 #define IPC_GET_SERVICE(call) ((services_t) IPC_GET_ARG3(call)) 315 316 /** Return the target service message argument. 317 * 318 * @param[in] call Message call structure. 319 * 320 */ 321 #define IPC_GET_TARGET(call) ((services_t) IPC_GET_ARG3(call)) 322 323 /** Return the sender service message argument. 324 * 325 * @param[in] call Message call structure. 326 * 327 */ 328 #define IPC_GET_SENDER(call) ((services_t) IPC_GET_ARG3(call)) 335 #define IPC_GET_MTU(call) ((size_t) IPC_GET_ARG3(call)) 329 336 330 337 /** Return the error service message argument. -
uspace/lib/c/include/ipc/net_net.h
rf51b1d3 r609243f4 43 43 /** Networking subsystem central module messages. */ 44 44 typedef enum { 45 /** Return s thegeneral configuration45 /** Return general configuration 46 46 * @see net_get_conf_req() 47 47 */ 48 48 NET_NET_GET_CONF = NET_FIRST, 49 /** Return s thedevice specific configuration49 /** Return device specific configuration 50 50 * @see net_get_device_conf_req() 51 51 */ 52 52 NET_NET_GET_DEVICE_CONF, 53 /** Starts the networking stack. */ 54 NET_NET_STARTUP, 53 /** Return number of mastered devices */ 54 NET_NET_GET_DEVICES_COUNT, 55 /** Return names and device IDs of all devices */ 56 NET_NET_GET_DEVICES, 57 /** Notify the networking service about a ready device */ 58 NET_NET_DRIVER_READY 55 59 } net_messages; 56 60 -
uspace/lib/c/include/ipc/nil.h
rf51b1d3 r609243f4 70 70 */ 71 71 NET_NIL_BROADCAST_ADDR, 72 /** Device has changed address 73 * @see nil_addr_changed_msg() 74 */ 75 NET_NIL_ADDR_CHANGED 72 76 } nil_messages; 73 77 -
uspace/lib/c/include/ipc/services.h
rf51b1d3 r609243f4 49 49 SERVICE_CLIPBOARD = FOURCC('c', 'l', 'i', 'p'), 50 50 SERVICE_NETWORKING = FOURCC('n', 'e', 't', ' '), 51 SERVICE_LO = FOURCC('l', 'o', ' ', ' '),52 SERVICE_NE2000 = FOURCC('n', 'e', '2', 'k'),53 51 SERVICE_ETHERNET = FOURCC('e', 't', 'h', ' '), 54 52 SERVICE_NILDUMMY = FOURCC('n', 'i', 'l', 'd'), -
uspace/lib/c/include/net/device.h
rf51b1d3 r609243f4 1 1 /* 2 2 * Copyright (c) 2009 Lukas Mejdrech 3 * Copyright (c) 2011 Radim Vansa 3 4 * All rights reserved. 4 5 * … … 39 40 40 41 #include <adt/int_map.h> 42 #include <net/eth_phys.h> 43 44 /** Ethernet address length. */ 45 #define ETH_ADDR 6 46 47 /** MAC printing format */ 48 #define PRIMAC "%02x:%02x:%02x:%02x:%02x:%02x" 49 50 /** MAC arguments */ 51 #define ARGSMAC(__a) \ 52 (__a)[0], (__a)[1], (__a)[2], (__a)[3], (__a)[4], (__a)[5] 41 53 42 54 /** Device identifier to generic type map declaration. */ 43 #define DEVICE_MAP_DECLARE INT_MAP_DECLARE55 #define DEVICE_MAP_DECLARE INT_MAP_DECLARE 44 56 45 57 /** Device identifier to generic type map implementation. */ 46 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 58 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 59 60 /** Max length of any hw nic address (currently only eth) */ 61 #define NIC_MAX_ADDRESS_LENGTH 16 47 62 48 63 /** Invalid device identifier. */ 49 #define DEVICE_INVALID_ID (-1) 64 #define NIC_DEVICE_INVALID_ID (-1) 65 66 #define NIC_VENDOR_MAX_LENGTH 64 67 #define NIC_MODEL_MAX_LENGTH 64 68 #define NIC_PART_NUMBER_MAX_LENGTH 64 69 #define NIC_SERIAL_NUMBER_MAX_LENGTH 64 70 71 /** 72 * The bitmap uses single bit for each of the 2^12 = 4096 possible VLAN tags. 73 * This means its size is 4096/8 = 512 bytes. 74 */ 75 #define NIC_VLAN_BITMAP_SIZE 512 76 77 #define NIC_DEVICE_PRINT_FMT "%x" 50 78 51 79 /** Device identifier type. */ 52 typedef int device_id_t; 53 54 /** Device state type. */ 55 typedef enum device_state device_state_t; 56 57 /** Type definition of the device usage statistics. 58 * @see device_stats 59 */ 60 typedef struct device_stats device_stats_t; 80 typedef int nic_device_id_t; 81 82 /** 83 * Structure covering the MAC address. 84 */ 85 typedef struct nic_address { 86 uint8_t address[ETH_ADDR]; 87 } nic_address_t; 61 88 62 89 /** Device state. */ 63 enum device_state { 64 /** Device not present or not initialized. */ 65 NETIF_NULL = 0, 66 /** Device present and stopped. */ 67 NETIF_STOPPED, 68 /** Device present and active. */ 69 NETIF_ACTIVE, 70 /** Device present but unable to transmit. */ 71 NETIF_CARRIER_LOST 72 }; 90 typedef enum nic_device_state { 91 /** 92 * Device present and stopped. Moving device to this state means to discard 93 * all settings and WOL virtues, rebooting the NIC to state as if the 94 * computer just booted (or the NIC was just inserted in case of removable 95 * NIC). 96 */ 97 NIC_STATE_STOPPED, 98 /** 99 * If the NIC is in this state no packets (frames) are transmitted nor 100 * received. However, the settings are not restarted. You can use this state 101 * to temporarily disable transmition/reception or atomically (with respect 102 * to incoming/outcoming packets) change frames acceptance etc. 103 */ 104 NIC_STATE_DOWN, 105 /** Device is normally operating. */ 106 NIC_STATE_ACTIVE, 107 /** Just a constant to limit the state numbers */ 108 NIC_STATE_MAX, 109 } nic_device_state_t; 110 111 /** 112 * Channel operating mode used on the medium. 113 */ 114 typedef enum { 115 NIC_CM_UNKNOWN, 116 NIC_CM_FULL_DUPLEX, 117 NIC_CM_HALF_DUPLEX, 118 NIC_CM_SIMPLEX 119 } nic_channel_mode_t; 120 121 /** 122 * Role for the device (used e.g. for 1000Gb ethernet) 123 */ 124 typedef enum { 125 NIC_ROLE_UNKNOWN, 126 NIC_ROLE_AUTO, 127 NIC_ROLE_MASTER, 128 NIC_ROLE_SLAVE 129 } nic_role_t; 130 131 /** 132 * Current state of the cable in the device 133 */ 134 typedef enum { 135 NIC_CS_UNKNOWN, 136 NIC_CS_PLUGGED, 137 NIC_CS_UNPLUGGED 138 } nic_cable_state_t; 139 140 /** 141 * Result of the requested operation 142 */ 143 typedef enum { 144 /** Successfully disabled */ 145 NIC_RESULT_DISABLED, 146 /** Successfully enabled */ 147 NIC_RESULT_ENABLED, 148 /** Not supported at all */ 149 NIC_RESULT_NOT_SUPPORTED, 150 /** Temporarily not available */ 151 NIC_RESULT_NOT_AVAILABLE, 152 /** Result extensions */ 153 NIC_RESULT_FIRST_EXTENSION 154 } nic_result_t; 73 155 74 156 /** Device usage statistics. */ 75 structdevice_stats {76 /** Total packets received . */157 typedef struct nic_device_stats { 158 /** Total packets received (accepted). */ 77 159 unsigned long receive_packets; 78 160 /** Total packets transmitted. */ 79 161 unsigned long send_packets; 80 /** Total bytes received . */162 /** Total bytes received (accepted). */ 81 163 unsigned long receive_bytes; 82 164 /** Total bytes transmitted. */ … … 86 168 /** Packet transmition problems counter. */ 87 169 unsigned long send_errors; 88 /** N o space in buffers counter.*/170 /** Number of frames dropped due to insufficient space in RX buffers */ 89 171 unsigned long receive_dropped; 90 /** N o space available counter.*/172 /** Number of frames dropped due to insufficient space in TX buffers */ 91 173 unsigned long send_dropped; 92 /** Total multicast packets received. */ 93 unsigned long multicast; 174 /** Total multicast packets received (accepted). */ 175 unsigned long receive_multicast; 176 /** Total broadcast packets received (accepted). */ 177 unsigned long receive_broadcast; 94 178 /** The number of collisions due to congestion on the medium. */ 95 179 unsigned long collisions; 180 /** Unicast packets received but not accepted (filtered) */ 181 unsigned long receive_filtered_unicast; 182 /** Multicast packets received but not accepted (filtered) */ 183 unsigned long receive_filtered_multicast; 184 /** Broadcast packets received but not accepted (filtered) */ 185 unsigned long receive_filtered_broadcast; 96 186 97 187 /* detailed receive_errors */ … … 129 219 /** Total compressed packet transmitted. */ 130 220 unsigned long send_compressed; 131 }; 221 } nic_device_stats_t; 222 223 /** 224 * Information about the NIC that never changes - name, vendor, model, 225 * capabilites and so on. 226 */ 227 typedef struct nic_device_info { 228 /* Device identification */ 229 char vendor_name[NIC_VENDOR_MAX_LENGTH]; 230 char model_name[NIC_MODEL_MAX_LENGTH]; 231 char part_number[NIC_PART_NUMBER_MAX_LENGTH]; 232 char serial_number[NIC_SERIAL_NUMBER_MAX_LENGTH]; 233 uint16_t vendor_id; 234 uint16_t device_id; 235 uint16_t subsystem_vendor_id; 236 uint16_t subsystem_id; 237 /* Device capabilities */ 238 uint16_t ethernet_support[ETH_PHYS_LAYERS]; 239 240 /** The mask of all modes which the device can advertise 241 * 242 * see ETH_AUTONEG_ macros in net/eth_phys.h of libc 243 */ 244 uint32_t autoneg_support; 245 } nic_device_info_t; 246 247 /** 248 * Specifies which unicast frames is the NIC receiving. 249 */ 250 typedef enum nic_unicast_mode { 251 NIC_UNICAST_UNKNOWN, 252 /** No unicast frames are received */ 253 NIC_UNICAST_BLOCKED, 254 /** Only the frames with this NIC's MAC as destination are received */ 255 NIC_UNICAST_DEFAULT, 256 /** 257 * Both frames with this NIC's MAC and those specified in the list are 258 * received 259 */ 260 NIC_UNICAST_LIST, 261 /** All unicast frames are received */ 262 NIC_UNICAST_PROMISC 263 } nic_unicast_mode_t; 264 265 typedef enum nic_multicast_mode { 266 NIC_MULTICAST_UNKNOWN, 267 /** No multicast frames are received */ 268 NIC_MULTICAST_BLOCKED, 269 /** Frames with multicast addresses specified in this list are received */ 270 NIC_MULTICAST_LIST, 271 /** All multicast frames are received */ 272 NIC_MULTICAST_PROMISC 273 } nic_multicast_mode_t; 274 275 typedef enum nic_broadcast_mode { 276 NIC_BROADCAST_UNKNOWN, 277 /** Broadcast frames are dropped */ 278 NIC_BROADCAST_BLOCKED, 279 /** Broadcast frames are received */ 280 NIC_BROADCAST_ACCEPTED 281 } nic_broadcast_mode_t; 282 283 /** 284 * Structure covering the bitmap with VLAN tags. 285 */ 286 typedef struct nic_vlan_mask { 287 uint8_t bitmap[NIC_VLAN_BITMAP_SIZE]; 288 } nic_vlan_mask_t; 289 290 /* WOL virtue identifier */ 291 typedef unsigned int nic_wv_id_t; 292 293 /** 294 * WOL virtue types defining the interpretation of data passed to the virtue. 295 * Those tagged with S can have only single virtue active at one moment, those 296 * tagged with M can have multiple ones. 297 */ 298 typedef enum nic_wv_type { 299 /** 300 * Used for deletion of the virtue - in this case the mask, data and length 301 * arguments are ignored. 302 */ 303 NIC_WV_NONE, 304 /** S 305 * Enabled <=> wakeup upon link change 306 */ 307 NIC_WV_LINK_CHANGE, 308 /** S 309 * If this virtue is set up, wakeup can be issued by a magic packet frame. 310 * If the data argument is not NULL, it must contain 311 * nic_wv_magic_packet_data structure with the SecureOn password. 312 */ 313 NIC_WV_MAGIC_PACKET, 314 /** M 315 * If the virtue is set up, wakeup can be issued by a frame targeted to 316 * device with MAC address specified in data. The data must contain 317 * nic_address_t structure. 318 */ 319 NIC_WV_DESTINATION, 320 /** S 321 * Enabled <=> wakeup upon receiving broadcast frame 322 */ 323 NIC_WV_BROADCAST, 324 /** S 325 * Enabled <=> wakeup upon receiving ARP Request 326 */ 327 NIC_WV_ARP_REQUEST, 328 /** M 329 * If enabled, the wakeup is issued upon receiving frame with an IPv4 packet 330 * with IPv4 address specified in data. The data must contain 331 * nic_wv_ipv4_data structure. 332 */ 333 NIC_WV_DIRECTED_IPV4, 334 /** M 335 * If enabled, the wakeup is issued upon receiving frame with an IPv4 packet 336 * with IPv6 address specified in data. The data must contain 337 * nic_wv_ipv6_data structure. 338 */ 339 NIC_WV_DIRECTED_IPV6, 340 /** M 341 * First length/2 bytes in the argument are interpreted as mask, second 342 * length/2 bytes are interpreted as content. 343 * If enabled, the wakeup is issued upon receiving frame where the bytes 344 * with non-zero value in the mask equal to those in the content. 345 */ 346 NIC_WV_FULL_MATCH, 347 /** 348 * Dummy value, do not use. 349 */ 350 NIC_WV_MAX 351 } nic_wv_type_t; 352 353 /** 354 * Specifies the interrupt/polling mode used by the driver and NIC 355 */ 356 typedef enum nic_poll_mode { 357 /** 358 * NIC issues interrupts upon events. 359 */ 360 NIC_POLL_IMMEDIATE, 361 /** 362 * Some uspace app calls nic_poll_now(...) in order to check the NIC state 363 * - no interrupts are received from the NIC. 364 */ 365 NIC_POLL_ON_DEMAND, 366 /** 367 * The driver itself issues a poll request in a periodic manner. It is 368 * allowed to use hardware timer if the NIC supports it. 369 */ 370 NIC_POLL_PERIODIC, 371 /** 372 * The driver itself issued a poll request in a periodic manner. The driver 373 * must create software timer, internal hardware timer of NIC must not be 374 * used even if the NIC supports it. 375 */ 376 NIC_POLL_SOFTWARE_PERIODIC 377 } nic_poll_mode_t; 378 379 static inline const char *nic_device_state_to_string(nic_device_state_t state) 380 { 381 switch (state) { 382 case NIC_STATE_STOPPED: 383 return "stopped"; 384 case NIC_STATE_DOWN: 385 return "down"; 386 case NIC_STATE_ACTIVE: 387 return "active"; 388 default: 389 return "undefined"; 390 } 391 } 132 392 133 393 #endif -
uspace/lib/c/include/net/packet.h
rf51b1d3 r609243f4 41 41 * Value zero is used as an invalid identifier. 42 42 */ 43 typedef intpacket_id_t;43 typedef unsigned long packet_id_t; 44 44 45 45 /** Type definition of the packet. … … 71 71 extern packet_t *pm_find(packet_id_t); 72 72 extern int pm_add(packet_t *); 73 extern void pm_remove(packet_t *); 73 74 extern int pm_init(void); 74 75 extern void pm_destroy(void); -
uspace/lib/c/include/net/packet_header.h
rf51b1d3 r609243f4 61 61 #define PACKET_MAGIC_VALUE 0x11227788 62 62 63 /** Maximum total length of the packet */ 64 #define PACKET_MAX_LENGTH 65536 65 63 66 /** Packet header. */ 64 67 struct packet { … … 85 88 */ 86 89 size_t length; 90 91 /** Offload info provided by the NIC */ 92 uint32_t offload_info; 93 94 /** Mask which bits in offload info are valid */ 95 uint32_t offload_mask; 87 96 88 97 /** Stored source and destination addresses length. */ -
uspace/lib/drv/Makefile
rf51b1d3 r609243f4 39 39 generic/remote_hw_res.c \ 40 40 generic/remote_char_dev.c \ 41 generic/remote_nic.c \ 41 42 generic/remote_usb.c \ 42 43 generic/remote_pci.c \ -
uspace/lib/drv/generic/dev_iface.c
rf51b1d3 r609243f4 41 41 #include "remote_hw_res.h" 42 42 #include "remote_char_dev.h" 43 #include "remote_nic.h" 43 44 #include "remote_usb.h" 44 45 #include "remote_usbhc.h" … … 50 51 &remote_hw_res_iface, 51 52 &remote_char_dev_iface, 53 &remote_nic_iface, 52 54 &remote_pci_iface, 53 55 &remote_usb_iface, -
uspace/lib/drv/generic/driver.c
rf51b1d3 r609243f4 303 303 } 304 304 305 static void driver_dev_added(ipc_callid_t iid, ipc_call_t *icall) 306 { 307 fibril_mutex_lock(&devices_mutex); 308 ddf_dev_t *dev = driver_get_device(IPC_GET_ARG1(*icall)); 309 fibril_mutex_unlock(&devices_mutex); 310 311 if (dev != NULL && driver->driver_ops->device_added != NULL) 312 driver->driver_ops->device_added(dev); 313 } 314 305 315 static void driver_dev_remove(ipc_callid_t iid, ipc_call_t *icall) 306 316 { … … 450 460 case DRIVER_DEV_ADD: 451 461 driver_dev_add(callid, &call); 462 break; 463 case DRIVER_DEV_ADDED: 464 async_answer_0(callid, EOK); 465 driver_dev_added(callid, &call); 452 466 break; 453 467 case DRIVER_DEV_REMOVE: -
uspace/lib/drv/include/ddf/driver.h
rf51b1d3 r609243f4 137 137 /** Callback method for passing a new device to the device driver */ 138 138 int (*add_device)(ddf_dev_t *); 139 /** 140 * Notification that the device was succesfully added. 141 * The driver can do any blocking operation without 142 * blocking the device manager. 143 */ 144 void (*device_added)(ddf_dev_t *dev); 139 145 /** Ask driver to remove a device */ 140 146 int (*dev_remove)(ddf_dev_t *); -
uspace/lib/drv/include/remote_nic.h
rf51b1d3 r609243f4 1 1 /* 2 * Copyright (c) 20 09 Lukas Mejdrech2 * Copyright (c) 2011 Radim Vansa 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup lib net29 /** @addtogroup libdrv 30 30 * @{ 31 31 */ 32 /** @file 33 */ 32 34 33 #ifndef LIB NET_NETIF_REMOTE_H_34 #define LIB NET_NETIF_REMOTE_H_35 #ifndef LIBDRV_REMOTE_NIC_H_ 36 #define LIBDRV_REMOTE_NIC_H_ 35 37 36 #include <ipc/services.h> 37 #include <adt/measured_strings.h> 38 #include <net/device.h> 39 #include <net/packet.h> 40 #include <async.h> 41 42 extern int netif_get_addr_req(async_sess_t *, device_id_t, measured_string_t **, 43 uint8_t **); 44 extern int netif_probe_req(async_sess_t *, device_id_t, int, void *); 45 extern int netif_send_msg(async_sess_t *, device_id_t, packet_t *, services_t); 46 extern int netif_start_req(async_sess_t *, device_id_t); 47 extern int netif_stop_req(async_sess_t *, device_id_t); 48 extern int netif_stats_req(async_sess_t *, device_id_t, device_stats_t *); 49 extern async_sess_t *netif_bind_service(services_t, device_id_t, services_t, 50 async_client_conn_t); 38 extern remote_iface_t remote_nic_iface; 51 39 52 40 #endif 53 41 54 /** @} 42 /** 43 * @} 55 44 */ -
uspace/lib/net/Makefile
rf51b1d3 r609243f4 40 40 generic/protocol_map.c \ 41 41 adt/module_map.c \ 42 netif/netif_remote.c \43 netif/netif_skel.c \44 42 nil/nil_remote.c \ 45 43 nil/nil_skel.c \ -
uspace/lib/net/generic/generic.c
rf51b1d3 r609243f4 54 54 */ 55 55 int generic_device_state_msg_remote(async_sess_t *sess, sysarg_t message, 56 device_id_t device_id, sysarg_t state, services_t target)56 nic_device_id_t device_id, sysarg_t state, services_t target) 57 57 { 58 58 async_exch_t *exch = async_exchange_begin(sess); … … 68 68 * @param[in] message Service specific message. 69 69 * @param[in] device_id Device identifier. 70 * @param[in] arg2 Second argument of the message.71 70 * @param[in] service Device module service. 72 71 * … … 77 76 */ 78 77 int generic_device_req_remote(async_sess_t *sess, sysarg_t message, 79 device_id_t device_id, sysarg_t arg2, services_t service)80 { 81 async_exch_t *exch = async_exchange_begin(sess); 82 int rc = async_req_ 3_0(exch, message, (sysarg_t) device_id,83 arg2,(sysarg_t) service);78 nic_device_id_t device_id, services_t service) 79 { 80 async_exch_t *exch = async_exchange_begin(sess); 81 int rc = async_req_2_0(exch, message, (sysarg_t) device_id, 82 (sysarg_t) service); 84 83 async_exchange_end(exch); 85 84 … … 103 102 */ 104 103 int generic_get_addr_req(async_sess_t *sess, sysarg_t message, 105 device_id_t device_id, measured_string_t **address, uint8_t **data)106 { 107 if ( (!address) || (!data))104 nic_device_id_t device_id, uint8_t *address, size_t max_len) 105 { 106 if (!address) 108 107 return EBADMEM; 109 108 110 109 /* Request the address */ 111 110 async_exch_t *exch = async_exchange_begin(sess); 112 aid_t message_id = async_send_1(exch, message, (sysarg_t) device_id,111 aid_t aid = async_send_1(exch, message, (sysarg_t) device_id, 113 112 NULL); 114 int rc = measured_strings_return(exch, address, data, 1);113 int rc = async_data_read_start(exch, address, max_len); 115 114 async_exchange_end(exch); 116 115 117 116 sysarg_t result; 118 async_wait_for(message_id, &result); 119 120 /* If not successful */ 121 if ((rc == EOK) && (result != EOK)) { 122 /* Clear the data */ 123 free(*address); 124 free(*data); 125 } 117 async_wait_for(aid, &result); 118 119 if (rc != EOK) 120 return rc; 126 121 127 122 return (int) result; … … 142 137 */ 143 138 int generic_packet_size_req_remote(async_sess_t *sess, sysarg_t message, 144 device_id_t device_id, packet_dimension_t *packet_dimension)139 nic_device_id_t device_id, packet_dimension_t *packet_dimension) 145 140 { 146 141 if (!packet_dimension) … … 179 174 */ 180 175 int generic_received_msg_remote(async_sess_t *sess, sysarg_t message, 181 device_id_t device_id, packet_id_t packet_id, services_t target,176 nic_device_id_t device_id, packet_id_t packet_id, services_t target, 182 177 services_t error) 183 178 { … … 210 205 */ 211 206 int generic_send_msg_remote(async_sess_t *sess, sysarg_t message, 212 device_id_t device_id, packet_id_t packet_id, services_t sender,207 nic_device_id_t device_id, packet_id_t packet_id, services_t sender, 213 208 services_t error) 214 209 { … … 251 246 */ 252 247 int generic_translate_req(async_sess_t *sess, sysarg_t message, 253 device_id_t device_id, services_t service,248 nic_device_id_t device_id, services_t service, 254 249 measured_string_t *configuration, size_t count, 255 250 measured_string_t **translation, uint8_t **data) -
uspace/lib/net/generic/net_checksum.c
rf51b1d3 r609243f4 40 40 41 41 /** Big-endian encoding CRC divider. */ 42 #define CRC_DIVIDER_BE 0x04c11db742 #define CRC_DIVIDER_BE 0x04c11db7 43 43 44 44 /** Little-endian encoding CRC divider. */ 45 #define CRC_DIVIDER_LE 0xedb8832045 #define CRC_DIVIDER_LE 0xedb88320 46 46 47 47 /** Compacts the computed checksum to the 16 bit number adding the carries. … … 203 203 } 204 204 205 /** Compute s the ipheader checksum.205 /** Compute the IP header checksum. 206 206 * 207 207 * To compute the checksum of a new packet, the checksum header field must be -
uspace/lib/net/generic/net_remote.c
rf51b1d3 r609243f4 38 38 #include <ipc/services.h> 39 39 #include <ipc/net_net.h> 40 41 40 #include <malloc.h> 42 41 #include <async.h> 42 #include <devman.h> 43 43 #include <generic.h> 44 44 #include <net/modules.h> … … 98 98 size_t count, uint8_t **data) 99 99 { 100 return generic_translate_req(sess, NET_NET_GET_ DEVICE_CONF, 0, 0,100 return generic_translate_req(sess, NET_NET_GET_CONF, 0, 0, 101 101 *configuration, count, configuration, data); 102 102 } … … 124 124 * 125 125 */ 126 int net_get_device_conf_req(async_sess_t *sess, device_id_t device_id,126 int net_get_device_conf_req(async_sess_t *sess, nic_device_id_t device_id, 127 127 measured_string_t **configuration, size_t count, uint8_t **data) 128 128 { … … 131 131 } 132 132 133 int net_get_devices_req(async_sess_t *sess, measured_string_t **devices, 134 size_t *count, uint8_t **data) 135 { 136 if ((!devices) || (!count)) 137 return EBADMEM; 138 139 async_exch_t *exch = async_exchange_begin(sess); 140 141 int rc = async_req_0_1(exch, NET_NET_GET_DEVICES_COUNT, count); 142 if (rc != EOK) { 143 async_exchange_end(exch); 144 return rc; 145 } 146 147 if (*count == 0) { 148 async_exchange_end(exch); 149 *data = NULL; 150 return EOK; 151 } 152 153 aid_t message_id = async_send_0(exch, NET_NET_GET_DEVICES, NULL); 154 rc = measured_strings_return(exch, devices, data, *count); 155 156 async_exchange_end(exch); 157 158 sysarg_t result; 159 async_wait_for(message_id, &result); 160 161 if ((rc == EOK) && (result != EOK)) { 162 free(*devices); 163 free(*data); 164 } 165 166 return (int) result; 167 } 168 169 int net_driver_ready(async_sess_t *sess, devman_handle_t handle) 170 { 171 async_exch_t *exch = async_exchange_begin(sess); 172 int rc = async_req_1_0(exch, NET_NET_DRIVER_READY, handle); 173 async_exchange_end(exch); 174 175 return rc; 176 } 177 133 178 /** @} 134 179 */ -
uspace/lib/net/generic/protocol_map.c
rf51b1d3 r609243f4 50 50 switch (nil) { 51 51 case SERVICE_ETHERNET: 52 case SERVICE_N E2000:52 case SERVICE_NILDUMMY: 53 53 switch (il) { 54 54 case SERVICE_IP: … … 76 76 switch (nil) { 77 77 case SERVICE_ETHERNET: 78 case SERVICE_N E2000:78 case SERVICE_NILDUMMY: 79 79 switch (protocol) { 80 80 case ETH_P_IP: … … 139 139 switch (nil) { 140 140 case SERVICE_ETHERNET: 141 case SERVICE_NE2000:142 141 return HW_ETHER; 143 142 default: -
uspace/lib/net/il/arp_remote.c
rf51b1d3 r609243f4 84 84 * 85 85 */ 86 int arp_clear_address_req(async_sess_t *sess, device_id_t device_id,86 int arp_clear_address_req(async_sess_t *sess, nic_device_id_t device_id, 87 87 services_t protocol, measured_string_t *address) 88 88 { … … 108 108 * 109 109 */ 110 int arp_clear_device_req(async_sess_t *sess, device_id_t device_id)110 int arp_clear_device_req(async_sess_t *sess, nic_device_id_t device_id) 111 111 { 112 112 async_exch_t *exch = async_exchange_begin(sess); … … 143 143 * 144 144 */ 145 int arp_device_req(async_sess_t *sess, device_id_t device_id,145 int arp_device_req(async_sess_t *sess, nic_device_id_t device_id, 146 146 services_t protocol, services_t netif, measured_string_t *address) 147 147 { … … 177 177 * 178 178 */ 179 int arp_translate_req(async_sess_t *sess, device_id_t device_id,179 int arp_translate_req(async_sess_t *sess, nic_device_id_t device_id, 180 180 services_t protocol, measured_string_t *address, 181 181 measured_string_t **translation, uint8_t **data) -
uspace/lib/net/il/il_remote.c
rf51b1d3 r609243f4 55 55 * 56 56 */ 57 int il_device_state_msg(async_sess_t *sess, device_id_t device_id,58 device_state_t state, services_t target)57 int il_device_state_msg(async_sess_t *sess, nic_device_id_t device_id, 58 nic_device_state_t state, services_t target) 59 59 { 60 60 return generic_device_state_msg_remote(sess, NET_IL_DEVICE_STATE, … … 73 73 * 74 74 */ 75 int il_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,76 services_t target)75 int il_received_msg(async_sess_t *sess, nic_device_id_t device_id, 76 packet_t *packet, services_t target) 77 77 { 78 78 return generic_received_msg_remote(sess, NET_IL_RECEIVED, device_id, … … 91 91 * 92 92 */ 93 int il_mtu_changed_msg(async_sess_t *sess, device_id_t device_id, size_t mtu,93 int il_mtu_changed_msg(async_sess_t *sess, nic_device_id_t device_id, size_t mtu, 94 94 services_t target) 95 95 { … … 98 98 } 99 99 100 /** Notify IL layer modules about address change (implemented by ARP) 101 * 102 */ 103 int il_addr_changed_msg(async_sess_t *sess, nic_device_id_t device_id, 104 size_t addr_len, const uint8_t *address) 105 { 106 async_exch_t *exch = async_exchange_begin(sess); 107 108 aid_t message_id = async_send_1(exch, NET_IL_ADDR_CHANGED, 109 (sysarg_t) device_id, NULL); 110 int rc = async_data_write_start(exch, address, addr_len); 111 112 async_exchange_end(exch); 113 114 sysarg_t res; 115 async_wait_for(message_id, &res); 116 if (rc != EOK) 117 return rc; 118 119 return (int) res; 120 } 121 100 122 /** @} 101 123 */ -
uspace/lib/net/il/ip_remote.c
rf51b1d3 r609243f4 62 62 * 63 63 */ 64 int ip_add_route_req_remote(async_sess_t *sess, device_id_t device_id,64 int ip_add_route_req_remote(async_sess_t *sess, nic_device_id_t device_id, 65 65 in_addr_t address, in_addr_t netmask, in_addr_t gateway) 66 66 { … … 123 123 * 124 124 */ 125 int ip_device_req_remote(async_sess_t *sess, device_id_t device_id,125 int ip_device_req_remote(async_sess_t *sess, nic_device_id_t device_id, 126 126 services_t service) 127 127 { 128 return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 0,128 return generic_device_req_remote(sess, NET_IP_DEVICE, device_id, 129 129 service); 130 130 } … … 144 144 int ip_get_route_req_remote(async_sess_t *sess, ip_protocol_t protocol, 145 145 const struct sockaddr *destination, socklen_t addrlen, 146 device_id_t *device_id, void **header, size_t *headerlen)146 nic_device_id_t *device_id, void **header, size_t *headerlen) 147 147 { 148 148 if ((!destination) || (addrlen == 0)) … … 196 196 * 197 197 */ 198 int ip_packet_size_req_remote(async_sess_t *sess, device_id_t device_id,198 int ip_packet_size_req_remote(async_sess_t *sess, nic_device_id_t device_id, 199 199 packet_dimension_t *packet_dimension) 200 200 { … … 216 216 * 217 217 */ 218 int ip_received_error_msg_remote(async_sess_t *sess, device_id_t device_id,218 int ip_received_error_msg_remote(async_sess_t *sess, nic_device_id_t device_id, 219 219 packet_t *packet, services_t target, services_t error) 220 220 { … … 240 240 * 241 241 */ 242 int ip_send_msg_remote(async_sess_t *sess, device_id_t device_id,242 int ip_send_msg_remote(async_sess_t *sess, nic_device_id_t device_id, 243 243 packet_t *packet, services_t sender, services_t error) 244 244 { … … 256 256 * 257 257 */ 258 int ip_set_gateway_req_remote(async_sess_t *sess, device_id_t device_id,258 int ip_set_gateway_req_remote(async_sess_t *sess, nic_device_id_t device_id, 259 259 in_addr_t gateway) 260 260 { -
uspace/lib/net/include/arp_interface.h
rf51b1d3 r609243f4 46 46 /*@{*/ 47 47 48 extern int arp_device_req(async_sess_t *, device_id_t, services_t, services_t,48 extern int arp_device_req(async_sess_t *, nic_device_id_t, services_t, services_t, 49 49 measured_string_t *); 50 extern int arp_translate_req(async_sess_t *, device_id_t, services_t,50 extern int arp_translate_req(async_sess_t *, nic_device_id_t, services_t, 51 51 measured_string_t *, measured_string_t **, uint8_t **); 52 extern int arp_clear_device_req(async_sess_t *, device_id_t);53 extern int arp_clear_address_req(async_sess_t *, device_id_t, services_t,52 extern int arp_clear_device_req(async_sess_t *, nic_device_id_t); 53 extern int arp_clear_address_req(async_sess_t *, nic_device_id_t, services_t, 54 54 measured_string_t *); 55 55 extern int arp_clean_cache_req(async_sess_t *); -
uspace/lib/net/include/generic.h
rf51b1d3 r609243f4 45 45 46 46 extern int generic_device_state_msg_remote(async_sess_t *, sysarg_t, 47 device_id_t, sysarg_t, services_t); 48 extern int generic_device_req_remote(async_sess_t *, sysarg_t, device_id_t, 49 sysarg_t, services_t); 50 extern int generic_get_addr_req(async_sess_t *, sysarg_t, device_id_t, 51 measured_string_t **, uint8_t **); 52 extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t, device_id_t, 53 packet_dimension_t *); 54 extern int generic_received_msg_remote(async_sess_t *, sysarg_t, device_id_t, 47 nic_device_id_t, sysarg_t, services_t); 48 extern int generic_device_req_remote(async_sess_t *, sysarg_t, nic_device_id_t, 49 services_t); 50 extern int generic_get_addr_req(async_sess_t *, sysarg_t, nic_device_id_t, 51 uint8_t *address, size_t max_length); 52 extern int generic_packet_size_req_remote(async_sess_t *, sysarg_t, 53 nic_device_id_t, packet_dimension_t *); 54 extern int generic_received_msg_remote(async_sess_t *, sysarg_t, 55 nic_device_id_t, packet_id_t, services_t, services_t); 56 extern int generic_send_msg_remote(async_sess_t *, sysarg_t, nic_device_id_t, 55 57 packet_id_t, services_t, services_t); 56 extern int generic_send_msg_remote(async_sess_t *, sysarg_t, device_id_t, 57 packet_id_t, services_t, services_t); 58 extern int generic_translate_req(async_sess_t *, sysarg_t, device_id_t, 58 extern int generic_translate_req(async_sess_t *, sysarg_t, nic_device_id_t, 59 59 services_t, measured_string_t *, size_t, measured_string_t **, uint8_t **); 60 60 -
uspace/lib/net/include/il_remote.h
rf51b1d3 r609243f4 50 50 /*@{*/ 51 51 52 extern int il_device_state_msg(async_sess_t *, device_id_t, device_state_t, 52 extern int il_device_state_msg(async_sess_t *, nic_device_id_t, 53 nic_device_state_t, services_t); 54 extern int il_received_msg(async_sess_t *, nic_device_id_t, packet_t *, 53 55 services_t); 54 extern int il_received_msg(async_sess_t *, device_id_t, packet_t *, services_t); 55 extern int il_mtu_changed_msg(async_sess_t *, device_id_t, size_t, services_t); 56 extern int il_mtu_changed_msg(async_sess_t *, nic_device_id_t, size_t, 57 services_t); 58 extern int il_addr_changed_msg(async_sess_t *, nic_device_id_t, size_t, 59 const uint8_t *); 56 60 57 61 /*@}*/ -
uspace/lib/net/include/ip_interface.h
rf51b1d3 r609243f4 69 69 * 70 70 */ 71 typedef int (*tl_received_msg_t)( device_id_t device_id, packet_t *packet,71 typedef int (*tl_received_msg_t)(nic_device_id_t device_id, packet_t *packet, 72 72 services_t receiver, services_t error); 73 73 -
uspace/lib/net/include/ip_remote.h
rf51b1d3 r609243f4 43 43 #include <async.h> 44 44 45 extern int ip_set_gateway_req_remote(async_sess_t *, device_id_t, in_addr_t);46 extern int ip_packet_size_req_remote(async_sess_t *, device_id_t,45 extern int ip_set_gateway_req_remote(async_sess_t *, nic_device_id_t, in_addr_t); 46 extern int ip_packet_size_req_remote(async_sess_t *, nic_device_id_t, 47 47 packet_dimension_t *); 48 extern int ip_received_error_msg_remote(async_sess_t *, device_id_t, packet_t *,48 extern int ip_received_error_msg_remote(async_sess_t *, nic_device_id_t, packet_t *, 49 49 services_t, services_t); 50 extern int ip_device_req_remote(async_sess_t *, device_id_t, services_t);51 extern int ip_add_route_req_remote(async_sess_t *, device_id_t, in_addr_t,50 extern int ip_device_req_remote(async_sess_t *, nic_device_id_t, services_t); 51 extern int ip_add_route_req_remote(async_sess_t *, nic_device_id_t, in_addr_t, 52 52 in_addr_t, in_addr_t); 53 extern int ip_send_msg_remote(async_sess_t *, device_id_t, packet_t *,53 extern int ip_send_msg_remote(async_sess_t *, nic_device_id_t, packet_t *, 54 54 services_t, services_t); 55 55 extern int ip_get_route_req_remote(async_sess_t *, ip_protocol_t, 56 const struct sockaddr *, socklen_t, device_id_t *, void **, size_t *);56 const struct sockaddr *, socklen_t, nic_device_id_t *, void **, size_t *); 57 57 58 58 #endif -
uspace/lib/net/include/net_checksum.h
rf51b1d3 r609243f4 30 30 * @{ 31 31 */ 32 33 32 /** @file 34 33 * General CRC and checksum computation. … … 42 41 43 42 /** IP checksum value for computed zero checksum. 43 * 44 44 * Zero is returned as 0xFFFF (not flipped) 45 * 45 46 */ 46 #define IP_CHECKSUM_ZERO 0xffffU47 #define IP_CHECKSUM_ZERO 0xffffU 47 48 48 #ifdef ARCH_IS_BIG_ENDIAN 49 #ifdef __BE__ 50 49 51 #define compute_crc32(seed, data, length) \ 50 52 compute_crc32_be(seed, (uint8_t *) data, length) 51 #else 53 54 #endif 55 56 #ifdef __LE__ 57 52 58 #define compute_crc32(seed, data, length) \ 53 59 compute_crc32_le(seed, (uint8_t *) data, length) 60 54 61 #endif 55 62 -
uspace/lib/net/include/net_interface.h
rf51b1d3 r609243f4 35 35 36 36 #include <ipc/services.h> 37 38 37 #include <net/device.h> 39 38 #include <adt/measured_strings.h> 40 39 #include <async.h> 40 #include <devman.h> 41 41 42 42 /** @name Networking module interface … … 45 45 /*@{*/ 46 46 47 extern int net_get_device_conf_req(async_sess_t *, device_id_t,47 extern int net_get_device_conf_req(async_sess_t *, nic_device_id_t, 48 48 measured_string_t **, size_t, uint8_t **); 49 49 extern int net_get_conf_req(async_sess_t *, measured_string_t **, size_t, 50 50 uint8_t **); 51 51 extern void net_free_settings(measured_string_t *, uint8_t *); 52 extern int net_get_devices_req(async_sess_t *, measured_string_t **, size_t *, 53 uint8_t **); 54 extern int net_driver_ready(async_sess_t *, devman_handle_t); 52 55 extern async_sess_t *net_connect_module(void); 53 56 -
uspace/lib/net/include/nil_remote.h
rf51b1d3 r609243f4 34 34 #define __NET_NIL_REMOTE_H__ 35 35 36 #include <ipc/services.h>37 36 #include <net/device.h> 38 37 #include <net/packet.h> 38 #include <devman.h> 39 39 #include <generic.h> 40 40 #include <async.h> … … 58 58 packet_get_id(packet), sender, 0) 59 59 60 #define nil_device_req(sess, device_id, mtu, netif_service) \ 61 generic_device_req_remote(sess, NET_NIL_DEVICE, device_id, mtu, \ 62 netif_service) 63 64 extern int nil_device_state_msg(async_sess_t *, device_id_t, sysarg_t); 65 extern int nil_received_msg(async_sess_t *, device_id_t, packet_t *, 66 services_t); 60 extern int nil_device_req(async_sess_t *, nic_device_id_t, devman_handle_t, 61 size_t); 62 extern int nil_device_state_msg(async_sess_t *, nic_device_id_t, sysarg_t); 63 extern int nil_received_msg(async_sess_t *, nic_device_id_t, packet_id_t); 64 extern int nil_addr_changed_msg(async_sess_t *, nic_device_id_t, 65 const nic_address_t *); 67 66 68 67 #endif -
uspace/lib/net/include/nil_skel.h
rf51b1d3 r609243f4 70 70 * 71 71 */ 72 extern int nil_device_state_msg_local( device_id_t device_id, sysarg_t state);72 extern int nil_device_state_msg_local(nic_device_id_t device_id, sysarg_t state); 73 73 74 74 /** Pass the packet queue to the network interface layer. … … 81 81 * @param[in] device_id Source device identifier. 82 82 * @param[in] packet Received packet or the received packet queue. 83 * @param[in] target Target service. Ignored parameter.84 83 * 85 84 * @return EOK on success. … … 88 87 * 89 88 */ 90 extern int nil_received_msg_local(device_id_t device_id, packet_t *packet, 91 services_t target); 89 extern int nil_received_msg_local(nic_device_id_t device_id, packet_t *packet); 92 90 93 91 /** Message processing function. -
uspace/lib/net/include/tl_common.h
rf51b1d3 r609243f4 52 52 53 53 extern int tl_get_ip_packet_dimension(async_sess_t *, packet_dimensions_t *, 54 device_id_t, packet_dimension_t **);54 nic_device_id_t, packet_dimension_t **); 55 55 extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *); 56 extern int tl_update_ip_packet_dimension(packet_dimensions_t *, device_id_t,56 extern int tl_update_ip_packet_dimension(packet_dimensions_t *, nic_device_id_t, 57 57 size_t); 58 58 extern int tl_set_address_port(struct sockaddr *, int, uint16_t); -
uspace/lib/net/include/tl_remote.h
rf51b1d3 r609243f4 51 51 /*@{*/ 52 52 53 extern int tl_received_msg(async_sess_t *, device_id_t, packet_t *, services_t,54 services_t );53 extern int tl_received_msg(async_sess_t *, nic_device_id_t, packet_t *, 54 services_t, services_t); 55 55 56 56 /*@}*/ -
uspace/lib/net/nil/nil_remote.c
rf51b1d3 r609243f4 54 54 * 55 55 */ 56 int nil_device_state_msg(async_sess_t *sess, device_id_t device_id,56 int nil_device_state_msg(async_sess_t *sess, nic_device_id_t device_id, 57 57 sysarg_t state) 58 58 { … … 76 76 * 77 77 */ 78 int nil_received_msg(async_sess_t *sess, device_id_t device_id,79 packet_ t *packet, services_t target)78 int nil_received_msg(async_sess_t *sess, nic_device_id_t device_id, 79 packet_id_t packet_id) 80 80 { 81 81 return generic_received_msg_remote(sess, NET_NIL_RECEIVED, 82 device_id, packet_get_id(packet), target, 0); 82 device_id, packet_id, 0, 0); 83 } 84 85 /** Notify upper layers that device address has changed 86 * 87 */ 88 int nil_addr_changed_msg(async_sess_t *sess, nic_device_id_t device_id, 89 const nic_address_t *address) 90 { 91 assert(sess); 92 93 async_exch_t *exch = async_exchange_begin(sess); 94 95 aid_t message_id = async_send_1(exch, NET_NIL_ADDR_CHANGED, 96 (sysarg_t) device_id, NULL); 97 int rc = async_data_write_start(exch, address, sizeof (nic_address_t)); 98 99 async_exchange_end(exch); 100 101 sysarg_t res; 102 async_wait_for(message_id, &res); 103 104 if (rc != EOK) 105 return rc; 106 107 return (int) res; 108 } 109 110 int nil_device_req(async_sess_t *sess, nic_device_id_t device_id, 111 devman_handle_t handle, size_t mtu) 112 { 113 async_exch_t *exch = async_exchange_begin(sess); 114 int rc = async_req_3_0(exch, NET_NIL_DEVICE, (sysarg_t) device_id, 115 (sysarg_t) handle, (sysarg_t) mtu); 116 async_exchange_end(exch); 117 return rc; 83 118 } 84 119 -
uspace/lib/net/tl/icmp_client.c
rf51b1d3 r609243f4 39 39 #include <icmp_header.h> 40 40 #include <packet_client.h> 41 42 #ifdef CONFIG_DEBUG43 #include <stdio.h>44 #endif45 46 41 #include <errno.h> 47 42 #include <sys/types.h> 48 49 43 #include <net/icmp_codes.h> 50 44 #include <net/packet.h> … … 60 54 * @return Zero if the packet contains no data. 61 55 */ 62 int 63 icmp_client_process_packet(packet_t *packet, icmp_type_t *type, 56 int icmp_client_process_packet(packet_t *packet, icmp_type_t *type, 64 57 icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu) 65 58 { … … 81 74 *mtu = header->un.frag.mtu; 82 75 83 /* Remove debug dump */84 #ifdef CONFIG_DEBUG85 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,86 packet_get_id(packet));87 #endif88 76 return sizeof(icmp_header_t); 89 77 } -
uspace/lib/net/tl/tl_common.c
rf51b1d3 r609243f4 119 119 */ 120 120 int tl_get_ip_packet_dimension(async_sess_t *sess, 121 packet_dimensions_t *packet_dimensions, device_id_t device_id,121 packet_dimensions_t *packet_dimensions, nic_device_id_t device_id, 122 122 packet_dimension_t **packet_dimension) 123 123 { … … 160 160 int 161 161 tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions, 162 device_id_t device_id, size_t content)162 nic_device_id_t device_id, size_t content) 163 163 { 164 164 packet_dimension_t *packet_dimension; … … 170 170 packet_dimension->content = content; 171 171 172 if (device_id != DEVICE_INVALID_ID) {172 if (device_id != NIC_DEVICE_INVALID_ID) { 173 173 packet_dimension = packet_dimensions_find(packet_dimensions, 174 DEVICE_INVALID_ID);174 NIC_DEVICE_INVALID_ID); 175 175 176 176 if (packet_dimension) { … … 179 179 else 180 180 packet_dimensions_exclude(packet_dimensions, 181 DEVICE_INVALID_ID, free);181 NIC_DEVICE_INVALID_ID, free); 182 182 } 183 183 } -
uspace/lib/net/tl/tl_remote.c
rf51b1d3 r609243f4 56 56 * 57 57 */ 58 int tl_received_msg(async_sess_t *sess, device_id_t device_id, packet_t *packet,58 int tl_received_msg(async_sess_t *sess, nic_device_id_t device_id, packet_t *packet, 59 59 services_t target, services_t error) 60 60 {
Note:
See TracChangeset
for help on using the changeset viewer.
