Changeset 0b749a3 in mainline for uspace/lib
- Timestamp:
- 2010-11-22T15:39:53Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eddb76, aae339e9
- Parents:
- 9a1d8ab (diff), 8cd1aa5e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib
- Files:
-
- 82 added
- 41 deleted
- 89 edited
- 28 moved
-
block/libblock.c (modified) (31 diffs)
-
block/libblock.h (modified) (2 diffs)
-
c/Makefile (modified) (3 diffs)
-
c/arch/abs32le/include/fibril.h (modified) (2 diffs)
-
c/arch/abs32le/include/istate.h (modified) (1 diff)
-
c/arch/abs32le/src/stacktrace.c (modified) (1 diff)
-
c/arch/abs32le/src/tls.c (modified) (1 diff)
-
c/arch/amd64/include/fibril.h (modified) (1 diff)
-
c/arch/amd64/include/istate.h (modified) (1 diff)
-
c/arch/amd64/src/entry.s (modified) (1 diff)
-
c/arch/amd64/src/fibril.S (modified) (2 diffs)
-
c/arch/arm32/include/fibril.h (modified) (1 diff)
-
c/arch/arm32/include/istate.h (modified) (1 diff)
-
c/arch/ia32/include/fibril.h (modified) (1 diff)
-
c/arch/ia32/include/istate.h (modified) (1 diff)
-
c/arch/ia64/include/fibril.h (modified) (1 diff)
-
c/arch/ia64/include/istate.h (modified) (1 diff)
-
c/arch/mips32/include/fibril.h (modified) (1 diff)
-
c/arch/mips32/include/istate.h (modified) (1 diff)
-
c/arch/ppc32/include/fibril.h (modified) (1 diff)
-
c/arch/sparc64/include/fibril.h (modified) (1 diff)
-
c/arch/sparc64/include/istate.h (modified) (1 diff)
-
c/generic/adt/char_map.c (added)
-
c/generic/adt/dynamic_fifo.c (added)
-
c/generic/adt/measured_strings.c (added)
-
c/generic/async.c (modified) (2 diffs)
-
c/generic/async_rel.c (added)
-
c/generic/ddi.c (modified) (1 diff)
-
c/generic/device/char.c (added)
-
c/generic/device/hw_res.c (added)
-
c/generic/devman.c (added)
-
c/generic/devmap.c (modified) (8 diffs)
-
c/generic/fibril.c (modified) (1 diff)
-
c/generic/fibril_synch.c (modified) (17 diffs)
-
c/generic/io/klog.c (modified) (1 diff)
-
c/generic/libc.c (modified) (2 diffs)
-
c/generic/net/icmp_api.c (added)
-
c/generic/net/icmp_common.c (moved) (moved from uspace/lib/socket/generic/icmp_common.c ) (1 diff)
-
c/generic/net/inet.c (added)
-
c/generic/net/modules.c (added)
-
c/generic/net/packet.c (added)
-
c/generic/net/socket_client.c (added)
-
c/generic/net/socket_parse.c (moved) (moved from uspace/lib/socket/generic/socket_parse.c ) (1 diff)
-
c/generic/task.c (modified) (4 diffs)
-
c/generic/vfs/vfs.c (modified) (4 diffs)
-
c/include/adt/char_map.h (added)
-
c/include/adt/dynamic_fifo.h (moved) (moved from uspace/lib/net/include/ip_local.h ) (1 diff)
-
c/include/adt/generic_char_map.h (added)
-
c/include/adt/generic_field.h (added)
-
c/include/adt/int_map.h (added)
-
c/include/adt/measured_strings.h (added)
-
c/include/async_rel.h (added)
-
c/include/byteorder.h (modified) (1 diff)
-
c/include/ddi.h (modified) (1 diff)
-
c/include/device/char.h (added)
-
c/include/device/hw_res.h (added)
-
c/include/devman.h (added)
-
c/include/devmap.h (modified) (2 diffs)
-
c/include/err.h (modified) (2 diffs)
-
c/include/errno.h (modified) (1 diff)
-
c/include/fibril.h (modified) (2 diffs)
-
c/include/fibril_synch.h (modified) (5 diffs)
-
c/include/ipc/arp.h (moved) (moved from uspace/lib/net/include/arp_messages.h ) (1 diff)
-
c/include/ipc/dev_iface.h (added)
-
c/include/ipc/devman.h (added)
-
c/include/ipc/devmap.h (modified) (2 diffs)
-
c/include/ipc/driver.h (added)
-
c/include/ipc/icmp.h (moved) (moved from uspace/lib/socket/include/icmp_messages.h ) (1 diff)
-
c/include/ipc/il.h (moved) (moved from uspace/lib/net/include/il_messages.h ) (2 diffs)
-
c/include/ipc/ip.h (moved) (moved from uspace/lib/net/include/ip_messages.h ) (1 diff)
-
c/include/ipc/net.h (added)
-
c/include/ipc/net_net.h (moved) (moved from uspace/lib/net/include/net_net_messages.h ) (1 diff)
-
c/include/ipc/netif.h (moved) (moved from uspace/lib/net/include/netif_messages.h ) (4 diffs)
-
c/include/ipc/nil.h (moved) (moved from uspace/lib/net/include/nil_messages.h ) (2 diffs)
-
c/include/ipc/packet.h (moved) (moved from uspace/lib/socket/include/packet/packet_messages.h ) (2 diffs)
-
c/include/ipc/serial_ctl.h (added)
-
c/include/ipc/services.h (modified) (2 diffs)
-
c/include/ipc/socket.h (moved) (moved from uspace/lib/socket/include/socket_messages.h ) (2 diffs)
-
c/include/ipc/tl.h (moved) (moved from uspace/lib/net/include/tl_messages.h ) (1 diff)
-
c/include/net/device.h (moved) (moved from uspace/lib/socket/include/net_device.h ) (2 diffs)
-
c/include/net/icmp_api.h (added)
-
c/include/net/icmp_codes.h (moved) (moved from uspace/lib/socket/include/icmp_codes.h ) (2 diffs)
-
c/include/net/icmp_common.h (added)
-
c/include/net/in.h (moved) (moved from uspace/lib/socket/include/in.h ) (2 diffs)
-
c/include/net/in6.h (moved) (moved from uspace/lib/socket/include/in6.h ) (2 diffs)
-
c/include/net/inet.h (moved) (moved from uspace/lib/socket/include/icmp_common.h ) (1 diff)
-
c/include/net/ip_codes.h (added)
-
c/include/net/ip_protocols.h (added)
-
c/include/net/modules.h (added)
-
c/include/net/packet.h (added)
-
c/include/net/packet_header.h (moved) (moved from uspace/lib/socket/include/packet/packet_header.h ) (1 diff)
-
c/include/net/socket.h (added)
-
c/include/net/socket_codes.h (added)
-
c/include/net/socket_parse.h (moved) (moved from uspace/lib/socket/include/socket_parse.h )
-
c/include/stdio.h (modified) (1 diff)
-
c/include/sys/stat.h (modified) (2 diffs)
-
c/include/sys/time.h (modified) (1 diff)
-
c/include/task.h (modified) (1 diff)
-
c/include/unistd.h (modified) (2 diffs)
-
c/include/vfs/vfs.h (modified) (1 diff)
-
drv/Makefile (moved) (moved from uspace/srv/net/netstart/Makefile ) (1 diff)
-
drv/generic/dev_iface.c (added)
-
drv/generic/driver.c (added)
-
drv/generic/remote_char.c (added)
-
drv/generic/remote_res.c (added)
-
drv/generic/remote_usbhc.c (added)
-
drv/include/char.h (added)
-
drv/include/dev_iface.h (added)
-
drv/include/driver.h (added)
-
drv/include/remote_char.h (added)
-
drv/include/remote_res.h (added)
-
drv/include/remote_usbhc.h (added)
-
drv/include/resource.h (added)
-
drv/include/usbhc_iface.h (added)
-
fs/libfs.c (modified) (18 diffs)
-
fs/libfs.h (modified) (3 diffs)
-
net/Makefile (modified) (2 diffs)
-
net/adt/module_map.c (modified) (4 diffs)
-
net/generic/generic.c (added)
-
net/generic/net_checksum.c (modified) (4 diffs)
-
net/generic/net_remote.c (modified) (1 diff)
-
net/generic/packet_client.c (added)
-
net/generic/packet_remote.c (modified) (8 diffs)
-
net/generic/protocol_map.c (added)
-
net/il/arp_remote.c (modified) (2 diffs)
-
net/il/il_interface.c (added)
-
net/il/ip_client.c (modified) (4 diffs)
-
net/il/ip_remote.c (modified) (13 diffs)
-
net/include/adt/module_map.h (modified) (1 diff)
-
net/include/arp_interface.h (modified) (1 diff)
-
net/include/ethernet_lsap.h (modified) (1 diff)
-
net/include/ethernet_protocols.h (modified) (1 diff)
-
net/include/generic.h (moved) (moved from uspace/lib/socket/generic/icmp_api.c ) (1 diff)
-
net/include/icmp_client.h (modified) (1 diff)
-
net/include/icmp_header.h (modified) (1 diff)
-
net/include/icmp_interface.h (modified) (1 diff)
-
net/include/il_interface.h (modified) (2 diffs)
-
net/include/il_local.h (modified) (1 diff)
-
net/include/ip_client.h (modified) (1 diff)
-
net/include/ip_header.h (modified) (2 diffs)
-
net/include/ip_interface.h (modified) (2 diffs)
-
net/include/ip_remote.h (modified) (1 diff)
-
net/include/net_checksum.h (modified) (1 diff)
-
net/include/net_hardware.h (modified) (2 diffs)
-
net/include/net_interface.h (modified) (1 diff)
-
net/include/netif_interface.h (modified) (2 diffs)
-
net/include/netif_local.h (modified) (12 diffs)
-
net/include/netif_remote.h (modified) (1 diff)
-
net/include/nil_interface.h (modified) (4 diffs)
-
net/include/nil_local.h (modified) (3 diffs)
-
net/include/nil_remote.h (modified) (1 diff)
-
net/include/packet_client.h (added)
-
net/include/packet_remote.h (modified) (1 diff)
-
net/include/protocol_map.h (modified) (2 diffs)
-
net/include/socket_core.h (added)
-
net/include/tl_common.h (modified) (1 diff)
-
net/include/tl_interface.h (modified) (3 diffs)
-
net/include/tl_local.h (modified) (1 diff)
-
net/netif/netif_local.c (modified) (18 diffs)
-
net/netif/netif_nil_bundle.c (deleted)
-
net/netif/netif_remote.c (modified) (7 diffs)
-
net/nil/nil_remote.c (modified) (3 diffs)
-
net/tl/icmp_client.c (modified) (2 diffs)
-
net/tl/icmp_remote.c (modified) (3 diffs)
-
net/tl/socket_core.c (added)
-
net/tl/tl_common.c (modified) (5 diffs)
-
net/tl/tl_interface.c (added)
-
packet/Makefile (moved) (moved from uspace/srv/hw/bus/pci/Makefile ) (1 diff)
-
packet/generic/packet_server.c (added)
-
packet/include/net_byteorder.h (moved) (moved from uspace/lib/socket/include/net_byteorder.h )
-
packet/include/net_err.h (moved) (moved from uspace/lib/socket/include/net_err.h )
-
packet/include/netdb.h (moved) (moved from uspace/lib/socket/include/netdb.h )
-
packet/include/packet_server.h (added)
-
packet/include/socket_errno.h (moved) (moved from uspace/lib/socket/include/socket_errno.h )
-
packet/include/tcp_codes.h (moved) (moved from uspace/lib/socket/include/tcp_codes.h )
-
pci/COPYING (deleted)
-
pci/VERSION (deleted)
-
pci/access.c (deleted)
-
pci/generic.c (deleted)
-
pci/header.h (deleted)
-
pci/i386-ports.c (deleted)
-
pci/internal.h (deleted)
-
pci/names.c (deleted)
-
pci/pci.h (deleted)
-
pci/pci_ids.h (deleted)
-
pci/sysdep.h (deleted)
-
pci/types.h (deleted)
-
socket/adt/char_map.c (deleted)
-
socket/adt/dynamic_fifo.c (deleted)
-
socket/adt/measured_strings.c (deleted)
-
socket/generic/inet.c (deleted)
-
socket/generic/net_modules.c (deleted)
-
socket/generic/socket_client.c (deleted)
-
socket/generic/socket_core.c (deleted)
-
socket/include/adt/char_map.h (deleted)
-
socket/include/adt/dynamic_fifo.h (deleted)
-
socket/include/adt/generic_char_map.h (deleted)
-
socket/include/adt/generic_field.h (deleted)
-
socket/include/adt/int_map.h (deleted)
-
socket/include/adt/measured_strings.h (deleted)
-
socket/include/icmp_api.h (deleted)
-
socket/include/inet.h (deleted)
-
socket/include/ip_codes.h (deleted)
-
socket/include/ip_protocols.h (deleted)
-
socket/include/net_messages.h (deleted)
-
socket/include/net_modules.h (deleted)
-
socket/include/packet/packet.h (deleted)
-
socket/include/packet/packet_client.h (deleted)
-
socket/include/packet/packet_server.h (deleted)
-
socket/include/socket.h (deleted)
-
socket/include/socket_codes.h (deleted)
-
socket/include/socket_core.h (deleted)
-
socket/packet/packet.c (deleted)
-
socket/packet/packet_client.c (deleted)
-
socket/packet/packet_server.c (deleted)
-
usb/Makefile (added)
-
usb/include/usb/classes/classes.h (added)
-
usb/include/usb/classes/hid.h (added)
-
usb/include/usb/classes/hidut.h (added)
-
usb/include/usb/classes/hidutkbd.h (added)
-
usb/include/usb/classes/hub.h (added)
-
usb/include/usb/descriptor.h (added)
-
usb/include/usb/devreq.h (added)
-
usb/include/usb/hcdhubd.h (added)
-
usb/include/usb/usb.h (added)
-
usb/include/usb/usbdrv.h (added)
-
usb/src/hcdhubd.c (added)
-
usb/src/localdrv.c (added)
-
usb/src/usb.c (added)
-
usb/src/usbdrv.c (added)
-
usbvirt/Makefile (added)
-
usbvirt/callback.c (added)
-
usbvirt/ctrlpipe.c (added)
-
usbvirt/debug.c (added)
-
usbvirt/device.h (added)
-
usbvirt/hub.h (added)
-
usbvirt/main.c (added)
-
usbvirt/private.h (added)
-
usbvirt/stdreq.c (added)
-
usbvirt/transaction.c (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r9a1d8ab r0b749a3 75 75 typedef struct { 76 76 link_t link; 77 dev _handle_t dev_handle;77 devmap_handle_t devmap_handle; 78 78 int dev_phone; 79 79 fibril_mutex_t comm_area_lock; … … 91 91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 92 92 93 static devcon_t *devcon_search(dev _handle_t dev_handle)93 static devcon_t *devcon_search(devmap_handle_t devmap_handle) 94 94 { 95 95 link_t *cur; … … 98 98 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 99 99 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 100 if (devcon->dev _handle == dev_handle) {100 if (devcon->devmap_handle == devmap_handle) { 101 101 fibril_mutex_unlock(&dcl_lock); 102 102 return devcon; … … 107 107 } 108 108 109 static int devcon_add(dev _handle_t dev_handle, int dev_phone, size_t bsize,109 static int devcon_add(devmap_handle_t devmap_handle, int dev_phone, size_t bsize, 110 110 void *comm_area, size_t comm_size) 111 111 { … … 121 121 122 122 link_initialize(&devcon->link); 123 devcon->dev _handle = dev_handle;123 devcon->devmap_handle = devmap_handle; 124 124 devcon->dev_phone = dev_phone; 125 125 fibril_mutex_initialize(&devcon->comm_area_lock); … … 134 134 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 135 135 devcon_t *d = list_get_instance(cur, devcon_t, link); 136 if (d->dev _handle == dev_handle) {136 if (d->devmap_handle == devmap_handle) { 137 137 fibril_mutex_unlock(&dcl_lock); 138 138 free(devcon); … … 152 152 } 153 153 154 int block_init(dev _handle_t dev_handle, size_t comm_size)154 int block_init(devmap_handle_t devmap_handle, size_t comm_size) 155 155 { 156 156 int rc; … … 165 165 } 166 166 167 dev_phone = devmap_device_connect(dev _handle, IPC_FLAG_BLOCKING);167 dev_phone = devmap_device_connect(devmap_handle, IPC_FLAG_BLOCKING); 168 168 if (dev_phone < 0) { 169 169 munmap(comm_area, comm_size); … … 185 185 } 186 186 187 rc = devcon_add(dev _handle, dev_phone, bsize, comm_area, comm_size);187 rc = devcon_add(devmap_handle, dev_phone, bsize, comm_area, comm_size); 188 188 if (rc != EOK) { 189 189 munmap(comm_area, comm_size); … … 195 195 } 196 196 197 void block_fini(dev _handle_t dev_handle)198 { 199 devcon_t *devcon = devcon_search(dev _handle);197 void block_fini(devmap_handle_t devmap_handle) 198 { 199 devcon_t *devcon = devcon_search(devmap_handle); 200 200 assert(devcon); 201 201 202 202 if (devcon->cache) 203 (void) block_cache_fini(dev _handle);203 (void) block_cache_fini(devmap_handle); 204 204 205 205 devcon_remove(devcon); … … 214 214 } 215 215 216 int block_bb_read(dev _handle_t dev_handle, aoff64_t ba)216 int block_bb_read(devmap_handle_t devmap_handle, aoff64_t ba) 217 217 { 218 218 void *bb_buf; 219 219 int rc; 220 220 221 devcon_t *devcon = devcon_search(dev _handle);221 devcon_t *devcon = devcon_search(devmap_handle); 222 222 if (!devcon) 223 223 return ENOENT; … … 244 244 } 245 245 246 void *block_bb_get(dev _handle_t dev_handle)247 { 248 devcon_t *devcon = devcon_search(dev _handle);246 void *block_bb_get(devmap_handle_t devmap_handle) 247 { 248 devcon_t *devcon = devcon_search(devmap_handle); 249 249 assert(devcon); 250 250 return devcon->bb_buf; … … 272 272 }; 273 273 274 int block_cache_init(dev _handle_t dev_handle, size_t size, unsigned blocks,274 int block_cache_init(devmap_handle_t devmap_handle, size_t size, unsigned blocks, 275 275 enum cache_mode mode) 276 276 { 277 devcon_t *devcon = devcon_search(dev _handle);277 devcon_t *devcon = devcon_search(devmap_handle); 278 278 cache_t *cache; 279 279 if (!devcon) … … 305 305 } 306 306 307 int block_cache_fini(dev _handle_t dev_handle)308 { 309 devcon_t *devcon = devcon_search(dev _handle);307 int block_cache_fini(devmap_handle_t devmap_handle) 308 { 309 devcon_t *devcon = devcon_search(devmap_handle); 310 310 cache_t *cache; 311 311 int rc; … … 374 374 * @param block Pointer to where the function will store the 375 375 * block pointer on success. 376 * @param dev _handle Device handle of the block device.376 * @param devmap_handle Device handle of the block device. 377 377 * @param boff Block offset. 378 378 * @param flags If BLOCK_FLAGS_NOREAD is specified, block_get() … … 382 382 * @return EOK on success or a negative error code. 383 383 */ 384 int block_get(block_t **block, dev _handle_t dev_handle, aoff64_t boff, int flags)384 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags) 385 385 { 386 386 devcon_t *devcon; … … 391 391 int rc; 392 392 393 devcon = devcon_search(dev _handle);393 devcon = devcon_search(devmap_handle); 394 394 395 395 assert(devcon); … … 500 500 501 501 block_initialize(b); 502 b->dev _handle = dev_handle;502 b->devmap_handle = devmap_handle; 503 503 b->size = cache->lblock_size; 504 504 b->boff = boff; … … 549 549 int block_put(block_t *block) 550 550 { 551 devcon_t *devcon = devcon_search(block->dev _handle);551 devcon_t *devcon = devcon_search(block->devmap_handle); 552 552 cache_t *cache; 553 553 unsigned blocks_cached; … … 645 645 /** Read sequential data from a block device. 646 646 * 647 * @param dev _handle Device handle of the block device.647 * @param devmap_handle Device handle of the block device. 648 648 * @param bufpos Pointer to the first unread valid offset within the 649 649 * communication buffer. … … 657 657 * @return EOK on success or a negative return code on failure. 658 658 */ 659 int block_seqread(dev _handle_t dev_handle, size_t *bufpos, size_t *buflen,659 int block_seqread(devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen, 660 660 aoff64_t *pos, void *dst, size_t size) 661 661 { … … 665 665 devcon_t *devcon; 666 666 667 devcon = devcon_search(dev _handle);667 devcon = devcon_search(devmap_handle); 668 668 assert(devcon); 669 669 block_size = devcon->pblock_size; … … 711 711 /** Read blocks directly from device (bypass cache). 712 712 * 713 * @param dev _handle Device handle of the block device.713 * @param devmap_handle Device handle of the block device. 714 714 * @param ba Address of first block. 715 715 * @param cnt Number of blocks. … … 718 718 * @return EOK on success or negative error code on failure. 719 719 */ 720 int block_read_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)720 int block_read_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf) 721 721 { 722 722 devcon_t *devcon; 723 723 int rc; 724 724 725 devcon = devcon_search(dev _handle);725 devcon = devcon_search(devmap_handle); 726 726 assert(devcon); 727 727 … … 739 739 /** Write blocks directly to device (bypass cache). 740 740 * 741 * @param dev _handle Device handle of the block device.741 * @param devmap_handle Device handle of the block device. 742 742 * @param ba Address of first block. 743 743 * @param cnt Number of blocks. … … 746 746 * @return EOK on success or negative error code on failure. 747 747 */ 748 int block_write_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt,748 int block_write_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, 749 749 const void *data) 750 750 { … … 752 752 int rc; 753 753 754 devcon = devcon_search(dev _handle);754 devcon = devcon_search(devmap_handle); 755 755 assert(devcon); 756 756 … … 767 767 /** Get device block size. 768 768 * 769 * @param dev _handle Device handle of the block device.769 * @param devmap_handle Device handle of the block device. 770 770 * @param bsize Output block size. 771 771 * 772 772 * @return EOK on success or negative error code on failure. 773 773 */ 774 int block_get_bsize(dev _handle_t dev_handle, size_t *bsize)774 int block_get_bsize(devmap_handle_t devmap_handle, size_t *bsize) 775 775 { 776 776 devcon_t *devcon; 777 777 778 devcon = devcon_search(dev _handle);778 devcon = devcon_search(devmap_handle); 779 779 assert(devcon); 780 780 … … 784 784 /** Get number of blocks on device. 785 785 * 786 * @param dev _handle Device handle of the block device.786 * @param devmap_handle Device handle of the block device. 787 787 * @param nblocks Output number of blocks. 788 788 * 789 789 * @return EOK on success or negative error code on failure. 790 790 */ 791 int block_get_nblocks(dev _handle_t dev_handle, aoff64_t *nblocks)791 int block_get_nblocks(devmap_handle_t devmap_handle, aoff64_t *nblocks) 792 792 { 793 793 devcon_t *devcon; 794 794 795 devcon = devcon_search(dev _handle);795 devcon = devcon_search(devmap_handle); 796 796 assert(devcon); 797 797 … … 818 818 printf("Error %d reading %d blocks starting at block %" PRIuOFF64 819 819 " from device handle %d\n", rc, cnt, ba, 820 devcon->dev _handle);820 devcon->devmap_handle); 821 821 #ifndef NDEBUG 822 822 stacktrace_print(); … … 844 844 if (rc != EOK) { 845 845 printf("Error %d writing %d blocks starting at block %" PRIuOFF64 846 " to device handle %d\n", rc, cnt, ba, devcon->dev _handle);846 " to device handle %d\n", rc, cnt, ba, devcon->devmap_handle); 847 847 #ifndef NDEBUG 848 848 stacktrace_print(); -
uspace/lib/block/libblock.h
r9a1d8ab r0b749a3 72 72 fibril_rwlock_t contents_lock; 73 73 /** Handle of the device where the block resides. */ 74 dev _handle_t dev_handle;74 devmap_handle_t devmap_handle; 75 75 /** Block offset on the block device. Counted in 'size'-byte blocks. */ 76 76 aoff64_t boff; … … 93 93 }; 94 94 95 extern int block_init(dev _handle_t, size_t);96 extern void block_fini(dev _handle_t);95 extern int block_init(devmap_handle_t, size_t); 96 extern void block_fini(devmap_handle_t); 97 97 98 extern int block_bb_read(dev _handle_t, aoff64_t);99 extern void *block_bb_get(dev _handle_t);98 extern int block_bb_read(devmap_handle_t, aoff64_t); 99 extern void *block_bb_get(devmap_handle_t); 100 100 101 extern int block_cache_init(dev _handle_t, size_t, unsigned, enum cache_mode);102 extern int block_cache_fini(dev _handle_t);101 extern int block_cache_init(devmap_handle_t, size_t, unsigned, enum cache_mode); 102 extern int block_cache_fini(devmap_handle_t); 103 103 104 extern int block_get(block_t **, dev _handle_t, aoff64_t, int);104 extern int block_get(block_t **, devmap_handle_t, aoff64_t, int); 105 105 extern int block_put(block_t *); 106 106 107 extern int block_seqread(dev _handle_t, size_t *, size_t *, aoff64_t *, void *,107 extern int block_seqread(devmap_handle_t, size_t *, size_t *, aoff64_t *, void *, 108 108 size_t); 109 109 110 extern int block_get_bsize(dev _handle_t, size_t *);111 extern int block_get_nblocks(dev _handle_t, aoff64_t *);112 extern int block_read_direct(dev _handle_t, aoff64_t, size_t, void *);113 extern int block_write_direct(dev _handle_t, aoff64_t, size_t, const void *);110 extern int block_get_bsize(devmap_handle_t, size_t *); 111 extern int block_get_nblocks(devmap_handle_t, aoff64_t *); 112 extern int block_read_direct(devmap_handle_t, aoff64_t, size_t, void *); 113 extern int block_write_direct(devmap_handle_t, aoff64_t, size_t, const void *); 114 114 115 115 #endif -
uspace/lib/c/Makefile
r9a1d8ab r0b749a3 57 57 generic/clipboard.c \ 58 58 generic/devmap.c \ 59 generic/devman.c \ 60 generic/device/hw_res.c \ 61 generic/device/char.c \ 59 62 generic/event.c \ 60 63 generic/errno.c \ … … 84 87 generic/ipc.c \ 85 88 generic/async.c \ 89 generic/async_rel.c \ 86 90 generic/loader.c \ 87 91 generic/getopt.c \ 88 92 generic/adt/list.o \ 89 93 generic/adt/hash_table.o \ 94 generic/adt/dynamic_fifo.c \ 95 generic/adt/measured_strings.c \ 96 generic/adt/char_map.c \ 90 97 generic/time.c \ 91 98 generic/err.c \ … … 95 102 generic/vfs/vfs.c \ 96 103 generic/vfs/canonify.c \ 104 generic/net/inet.c \ 105 generic/net/icmp_common.c \ 106 generic/net/icmp_api.c \ 107 generic/net/modules.c \ 108 generic/net/packet.c \ 109 generic/net/socket_client.c \ 110 generic/net/socket_parse.c \ 97 111 generic/stacktrace.c \ 98 112 generic/arg_parse.c \ -
uspace/lib/c/arch/abs32le/include/fibril.h
r9a1d8ab r0b749a3 44 44 (ctx)->pc = (uintptr_t) (_pc); \ 45 45 (ctx)->sp = ((uintptr_t) (stack)) + (size) - SP_DELTA; \ 46 (ctx)->fp = 0; \ 46 47 (ctx)->tls = ((uintptr_t) (ptls)) + sizeof(tcb_t); \ 47 48 } while (0) … … 53 54 typedef struct { 54 55 uintptr_t sp; 56 uintptr_t fp; 55 57 uintptr_t pc; 56 58 uintptr_t tls; 57 59 } context_t; 60 61 static inline uintptr_t context_get_fp(context_t *ctx) 62 { 63 /* On real hardware, this function returns the frame pointer. */ 64 return ctx->fp; 65 } 58 66 59 67 #endif -
uspace/lib/c/arch/abs32le/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_abs32le__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * On real hardware this stores the registers which 43 * need to be preserved during interupts. 44 */ 45 typedef struct istate { 46 uintptr_t ip; 47 uintptr_t fp; 48 uint32_t stack[]; 49 } istate_t; 50 51 static inline uintptr_t istate_get_pc(istate_t *istate) 52 { 53 return istate->ip; 54 } 55 56 static inline uintptr_t istate_get_fp(istate_t *istate) 57 { 58 return istate->fp; 59 } 38 #include <arch/istate.h> 60 39 61 40 #endif -
uspace/lib/c/arch/abs32le/src/stacktrace.c
r9a1d8ab r0b749a3 56 56 uintptr_t stacktrace_fp_get(void) 57 57 { 58 return NULL;58 return (uintptr_t) NULL; 59 59 } 60 60 61 61 uintptr_t stacktrace_pc_get(void) 62 62 { 63 return NULL;63 return (uintptr_t) NULL; 64 64 } 65 65 -
uspace/lib/c/arch/abs32le/src/tls.c
r9a1d8ab r0b749a3 46 46 uintptr_t __aeabi_read_tp(void) 47 47 { 48 return NULL;48 return (uintptr_t) NULL; 49 49 } 50 50 -
uspace/lib/c/arch/amd64/include/fibril.h
r9a1d8ab r0b749a3 56 56 */ 57 57 typedef struct { 58 uint64_t sp; 59 uint64_t pc; 60 61 uint64_t rbx; 62 uint64_t rbp; 58 uint64_t sp; 59 uint64_t pc; 63 60 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 61 uint64_t rbx; 62 uint64_t rbp; 68 63 69 uint64_t tls; 64 uint64_t r12; 65 uint64_t r13; 66 uint64_t r14; 67 uint64_t r15; 68 69 uint64_t tls; 70 70 } context_t; 71 72 static inline uintptr_t context_get_fp(context_t *ctx) 73 { 74 return ctx->rbp; 75 } 71 76 72 77 #endif -
uspace/lib/c/arch/amd64/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_amd64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint64_t rax; 46 uint64_t rcx; 47 uint64_t rdx; 48 uint64_t rsi; 49 uint64_t rdi; 50 uint64_t r8; 51 uint64_t r9; 52 uint64_t r10; 53 uint64_t r11; 54 uint64_t rbp; 55 uint64_t error_word; 56 uint64_t rip; 57 uint64_t cs; 58 uint64_t rflags; 59 uint64_t stack[]; /* Additional data on stack */ 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->rip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->rbp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/amd64/src/entry.s
r9a1d8ab r0b749a3 42 42 # 43 43 pushq $0 44 mov %rsp, %rbp44 movq %rsp, %rbp 45 45 46 46 # %rdi was deliberately chosen as the first argument is also in %rdi -
uspace/lib/c/arch/amd64/src/fibril.S
r9a1d8ab r0b749a3 49 49 movq %rax, OFFSET_TLS(%rdi) 50 50 51 xor q %rax,%rax # context_save returns 152 inc q %rax51 xorl %eax, %eax # context_save returns 1 52 incl %eax 53 53 ret 54 54 … … 67 67 # Set thread local storage 68 68 movq OFFSET_TLS(%rdi), %rdi # Set arg1 to TLS addr 69 mov q $1, %rax # SYS_TLS_SET69 movl $1, %eax # SYS_TLS_SET 70 70 syscall 71 71 72 xor q %rax,%rax # context_restore returns 072 xorl %eax, %eax # context_restore returns 0 73 73 ret -
uspace/lib/c/arch/arm32/include/fibril.h
r9a1d8ab r0b749a3 86 86 } context_t; 87 87 88 static inline uintptr_t context_get_fp(context_t *ctx) 89 { 90 return ctx->fp; 91 } 92 88 93 89 94 #endif -
uspace/lib/c/arch/arm32/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_arm32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t spsr; 46 uint32_t sp; 47 uint32_t lr; 48 49 uint32_t r0; 50 uint32_t r1; 51 uint32_t r2; 52 uint32_t r3; 53 uint32_t r4; 54 uint32_t r5; 55 uint32_t r6; 56 uint32_t r7; 57 uint32_t r8; 58 uint32_t r9; 59 uint32_t r10; 60 uint32_t fp; 61 uint32_t r12; 62 63 uint32_t pc; 64 } istate_t; 65 66 static inline uintptr_t istate_get_pc(istate_t *istate) 67 { 68 return istate->pc; 69 } 70 71 static inline uintptr_t istate_get_fp(istate_t *istate) 72 { 73 return istate->fp; 74 } 38 #include <arch/istate.h> 75 39 76 40 #endif -
uspace/lib/c/arch/ia32/include/fibril.h
r9a1d8ab r0b749a3 67 67 } context_t; 68 68 69 static inline uintptr_t context_get_fp(context_t *ctx) 70 { 71 return ctx->ebp; 72 } 73 69 74 #endif 70 75 -
uspace/lib/c/arch/ia32/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_ia32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t eax; 46 uint32_t ecx; 47 uint32_t edx; 48 uint32_t ebp; 49 50 uint32_t gs; 51 uint32_t fs; 52 uint32_t es; 53 uint32_t ds; 54 55 uint32_t error_word; 56 uint32_t eip; 57 uint32_t cs; 58 uint32_t eflags; 59 uint32_t stack[]; 60 } istate_t; 61 62 static inline uintptr_t istate_get_pc(istate_t *istate) 63 { 64 return istate->eip; 65 } 66 67 static inline uintptr_t istate_get_fp(istate_t *istate) 68 { 69 return istate->ebp; 70 } 38 #include <arch/istate.h> 71 39 72 40 #endif -
uspace/lib/c/arch/ia64/include/fibril.h
r9a1d8ab r0b749a3 130 130 } context_t; 131 131 132 static inline uintptr_t context_get_fp(context_t *ctx) 133 { 134 return 0; /* FIXME */ 135 } 136 132 137 #endif 133 138 -
uspace/lib/c/arch/ia64/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_ia64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/arch/mips32/include/fibril.h
r9a1d8ab r0b749a3 85 85 } context_t; 86 86 87 static inline uintptr_t context_get_fp(context_t *ctx) 88 { 89 return ctx->sp; 90 } 91 87 92 #endif 88 93 -
uspace/lib/c/arch/mips32/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_mips32__ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 uint32_t at; 46 uint32_t v0; 47 uint32_t v1; 48 uint32_t a0; 49 uint32_t a1; 50 uint32_t a2; 51 uint32_t a3; 52 uint32_t t0; 53 uint32_t t1; 54 uint32_t t2; 55 uint32_t t3; 56 uint32_t t4; 57 uint32_t t5; 58 uint32_t t6; 59 uint32_t t7; 60 uint32_t t8; 61 uint32_t t9; 62 uint32_t gp; 63 uint32_t sp; 64 uint32_t ra; 65 66 uint32_t lo; 67 uint32_t hi; 68 69 uint32_t status; /* cp0_status */ 70 uint32_t epc; /* cp0_epc */ 71 uint32_t k1; /* We use it as thread-local pointer */ 72 } istate_t; 73 74 static inline uintptr_t istate_get_pc(istate_t *istate) 75 { 76 return istate->epc; 77 } 78 79 static inline uintptr_t istate_get_fp(istate_t *istate) 80 { 81 /* TODO */ 82 return 0; 83 } 38 #include <arch/istate.h> 84 39 85 40 #endif -
uspace/lib/c/arch/ppc32/include/fibril.h
r9a1d8ab r0b749a3 78 78 } __attribute__ ((packed)) context_t; 79 79 80 static inline uintptr_t context_get_fp(context_t *ctx) 81 { 82 return ctx->sp; 83 } 84 80 85 #endif 81 86 -
uspace/lib/c/arch/sparc64/include/fibril.h
r9a1d8ab r0b749a3 77 77 } context_t; 78 78 79 static inline uintptr_t context_get_fp(context_t *ctx) 80 { 81 return ctx->sp + STACK_BIAS; 82 } 83 79 84 #endif 80 85 -
uspace/lib/c/arch/sparc64/include/istate.h
r9a1d8ab r0b749a3 36 36 #define LIBC_sparc64_ISTATE_H_ 37 37 38 #include <sys/types.h> 39 40 /** Interrupt context. 41 * 42 * This is a copy of the kernel definition with which it must be kept in sync. 43 */ 44 typedef struct istate { 45 /* TODO */ 46 } istate_t; 47 48 static inline uintptr_t istate_get_pc(istate_t *istate) 49 { 50 /* TODO */ 51 return 0; 52 } 53 54 static inline uintptr_t istate_get_fp(istate_t *istate) 55 { 56 /* TODO */ 57 return 0; 58 } 38 #include <arch/istate.h> 59 39 60 40 #endif -
uspace/lib/c/generic/async.c
r9a1d8ab r0b749a3 536 536 if (callid) 537 537 ipc_answer_0(callid, ENOMEM); 538 return NULL;538 return (uintptr_t) NULL; 539 539 } 540 540 … … 556 556 if (callid) 557 557 ipc_answer_0(callid, ENOMEM); 558 return NULL;558 return (uintptr_t) NULL; 559 559 } 560 560 -
uspace/lib/c/generic/ddi.c
r9a1d8ab r0b749a3 96 96 } 97 97 98 /** Interrupt control 99 * 100 * @param enable 1 - enable interrupts, 0 - disable interrupts 98 /** Enable an interrupt. 99 * 100 * @param irq the interrupt. 101 * 102 * @return Zero on success, negative error code otherwise. 101 103 */ 102 int preemption_control(int enable)104 int interrupt_enable(int irq) 103 105 { 104 return __SYSCALL1(SYS_PREEMPT_CONTROL, (sysarg_t) enable); 106 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 1); 107 } 108 109 /** Disable an interrupt. 110 * 111 * @param irq the interrupt. 112 * 113 * @return Zero on success, negative error code otherwise. 114 */ 115 int interrupt_disable(int irq) 116 { 117 return __SYSCALL2(SYS_INTERRUPT_ENABLE, (sysarg_t) irq, 0); 105 118 } 106 119 -
uspace/lib/c/generic/devmap.c
r9a1d8ab r0b749a3 132 132 * 133 133 */ 134 int devmap_device_register(const char *fqdn, dev _handle_t *handle)134 int devmap_device_register(const char *fqdn, devmap_handle_t *handle) 135 135 { 136 136 int phone = devmap_get_phone(DEVMAP_DRIVER, IPC_FLAG_BLOCKING); … … 163 163 164 164 if (handle != NULL) 165 *handle = (dev _handle_t) IPC_GET_ARG1(answer);165 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 166 166 167 167 return retval; 168 168 } 169 169 170 int devmap_device_get_handle(const char *fqdn, dev _handle_t *handle, unsigned int flags)170 int devmap_device_get_handle(const char *fqdn, devmap_handle_t *handle, unsigned int flags) 171 171 { 172 172 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 194 194 if (retval != EOK) { 195 195 if (handle != NULL) 196 *handle = (dev _handle_t) -1;196 *handle = (devmap_handle_t) -1; 197 197 return retval; 198 198 } 199 199 200 200 if (handle != NULL) 201 *handle = (dev _handle_t) IPC_GET_ARG1(answer);201 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 202 202 203 203 return retval; 204 204 } 205 205 206 int devmap_namespace_get_handle(const char *name, dev _handle_t *handle, unsigned int flags)206 int devmap_namespace_get_handle(const char *name, devmap_handle_t *handle, unsigned int flags) 207 207 { 208 208 int phone = devmap_get_phone(DEVMAP_CLIENT, flags); … … 230 230 if (retval != EOK) { 231 231 if (handle != NULL) 232 *handle = (dev _handle_t) -1;232 *handle = (devmap_handle_t) -1; 233 233 return retval; 234 234 } 235 235 236 236 if (handle != NULL) 237 *handle = (dev _handle_t) IPC_GET_ARG1(answer);237 *handle = (devmap_handle_t) IPC_GET_ARG1(answer); 238 238 239 239 return retval; 240 240 } 241 241 242 devmap_handle_type_t devmap_handle_probe(dev _handle_t handle)242 devmap_handle_type_t devmap_handle_probe(devmap_handle_t handle) 243 243 { 244 244 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 255 255 } 256 256 257 int devmap_device_connect(dev _handle_t handle, unsigned int flags)257 int devmap_device_connect(devmap_handle_t handle, unsigned int flags) 258 258 { 259 259 int phone; … … 305 305 } 306 306 307 static size_t devmap_count_devices_internal(int phone, dev _handle_t ns_handle)307 static size_t devmap_count_devices_internal(int phone, devmap_handle_t ns_handle) 308 308 { 309 309 ipcarg_t count; … … 325 325 } 326 326 327 size_t devmap_count_devices(dev _handle_t ns_handle)327 size_t devmap_count_devices(devmap_handle_t ns_handle) 328 328 { 329 329 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); … … 387 387 } 388 388 389 size_t devmap_get_devices(dev _handle_t ns_handle, dev_desc_t **data)389 size_t devmap_get_devices(devmap_handle_t ns_handle, dev_desc_t **data) 390 390 { 391 391 int phone = devmap_get_phone(DEVMAP_CLIENT, IPC_FLAG_BLOCKING); -
uspace/lib/c/generic/fibril.c
r9a1d8ab r0b749a3 275 275 fibril->func = func; 276 276 fibril->arg = arg; 277 278 fibril->waits_for = NULL; 277 279 278 280 context_save(&fibril->ctx); -
uspace/lib/c/generic/fibril_synch.c
r9a1d8ab r0b749a3 42 42 #include <errno.h> 43 43 #include <assert.h> 44 #include <stacktrace.h> 45 #include <stdlib.h> 44 46 45 47 static void optimize_execution_power(void) … … 56 58 } 57 59 60 static void print_deadlock(fibril_owner_info_t *oi) 61 { 62 fibril_t *f = (fibril_t *) fibril_get_id(); 63 64 printf("Deadlock detected.\n"); 65 stacktrace_print(); 66 67 printf("Fibril %p waits for primitive %p.\n", f, oi); 68 69 while (oi && oi->owned_by) { 70 printf("Primitive %p is owned by fibril %p.\n", 71 oi, oi->owned_by); 72 if (oi->owned_by == f) 73 break; 74 stacktrace_print_fp_pc(context_get_fp(&oi->owned_by->ctx), 75 oi->owned_by->ctx.pc); 76 printf("Fibril %p waits for primitive %p.\n", 77 oi->owned_by, oi->owned_by->waits_for); 78 oi = oi->owned_by->waits_for; 79 } 80 } 81 82 83 static void check_for_deadlock(fibril_owner_info_t *oi) 84 { 85 while (oi && oi->owned_by) { 86 if (oi->owned_by == (fibril_t *) fibril_get_id()) { 87 print_deadlock(oi); 88 abort(); 89 } 90 oi = oi->owned_by->waits_for; 91 } 92 } 93 94 58 95 void fibril_mutex_initialize(fibril_mutex_t *fm) 59 96 { 97 fm->oi.owned_by = NULL; 60 98 fm->counter = 1; 61 99 list_initialize(&fm->waiters); … … 64 102 void fibril_mutex_lock(fibril_mutex_t *fm) 65 103 { 104 fibril_t *f = (fibril_t *) fibril_get_id(); 105 66 106 futex_down(&async_futex); 67 107 if (fm->counter-- <= 0) { … … 73 113 link_initialize(&wdata.wu_event.link); 74 114 list_append(&wdata.wu_event.link, &fm->waiters); 115 check_for_deadlock(&fm->oi); 116 f->waits_for = &fm->oi; 75 117 fibril_switch(FIBRIL_TO_MANAGER); 76 118 } else { 119 fm->oi.owned_by = f; 77 120 futex_up(&async_futex); 78 121 } … … 86 129 if (fm->counter > 0) { 87 130 fm->counter--; 131 fm->oi.owned_by = (fibril_t *) fibril_get_id(); 88 132 locked = true; 89 133 } … … 99 143 link_t *tmp; 100 144 awaiter_t *wdp; 145 fibril_t *f; 101 146 102 147 assert(!list_empty(&fm->waiters)); … … 105 150 wdp->active = true; 106 151 wdp->wu_event.inlist = false; 152 153 f = (fibril_t *) wdp->fid; 154 fm->oi.owned_by = f; 155 f->waits_for = NULL; 156 107 157 list_remove(&wdp->wu_event.link); 108 158 fibril_add_ready(wdp->fid); 109 159 optimize_execution_power(); 160 } else { 161 fm->oi.owned_by = NULL; 110 162 } 111 163 } … … 120 172 void fibril_rwlock_initialize(fibril_rwlock_t *frw) 121 173 { 174 frw->oi.owned_by = NULL; 122 175 frw->writers = 0; 123 176 frw->readers = 0; … … 127 180 void fibril_rwlock_read_lock(fibril_rwlock_t *frw) 128 181 { 182 fibril_t *f = (fibril_t *) fibril_get_id(); 183 129 184 futex_down(&async_futex); 130 185 if (frw->writers) { 131 fibril_t *f = (fibril_t *) fibril_get_id();132 186 awaiter_t wdata; 133 187 … … 138 192 f->flags &= ~FIBRIL_WRITER; 139 193 list_append(&wdata.wu_event.link, &frw->waiters); 194 check_for_deadlock(&frw->oi); 195 f->waits_for = &frw->oi; 140 196 fibril_switch(FIBRIL_TO_MANAGER); 141 197 } else { 142 frw->readers++; 198 /* Consider the first reader the owner. */ 199 if (frw->readers++ == 0) 200 frw->oi.owned_by = f; 143 201 futex_up(&async_futex); 144 202 } … … 147 205 void fibril_rwlock_write_lock(fibril_rwlock_t *frw) 148 206 { 207 fibril_t *f = (fibril_t *) fibril_get_id(); 208 149 209 futex_down(&async_futex); 150 210 if (frw->writers || frw->readers) { 151 fibril_t *f = (fibril_t *) fibril_get_id();152 211 awaiter_t wdata; 153 212 … … 158 217 f->flags |= FIBRIL_WRITER; 159 218 list_append(&wdata.wu_event.link, &frw->waiters); 219 check_for_deadlock(&frw->oi); 220 f->waits_for = &frw->oi; 160 221 fibril_switch(FIBRIL_TO_MANAGER); 161 222 } else { 223 frw->oi.owned_by = f; 162 224 frw->writers++; 163 225 futex_up(&async_futex); … … 170 232 assert(frw->readers || (frw->writers == 1)); 171 233 if (frw->readers) { 172 if (--frw->readers) 234 if (--frw->readers) { 235 if (frw->oi.owned_by == (fibril_t *) fibril_get_id()) { 236 /* 237 * If this reader firbril was considered the 238 * owner of this rwlock, clear the ownership 239 * information even if there are still more 240 * readers. 241 * 242 * This is the limitation of the detection 243 * mechanism rooted in the fact that tracking 244 * all readers would require dynamically 245 * allocated memory for keeping linkage info. 246 */ 247 frw->oi.owned_by = NULL; 248 } 173 249 goto out; 250 } 174 251 } else { 175 252 frw->writers--; … … 177 254 178 255 assert(!frw->readers && !frw->writers); 256 257 frw->oi.owned_by = NULL; 179 258 180 259 while (!list_empty(&frw->waiters)) { … … 185 264 wdp = list_get_instance(tmp, awaiter_t, wu_event.link); 186 265 f = (fibril_t *) wdp->fid; 266 267 f->waits_for = NULL; 187 268 188 269 if (f->flags & FIBRIL_WRITER) { … … 194 275 fibril_add_ready(wdp->fid); 195 276 frw->writers++; 277 frw->oi.owned_by = f; 196 278 optimize_execution_power(); 197 279 break; … … 201 283 list_remove(&wdp->wu_event.link); 202 284 fibril_add_ready(wdp->fid); 203 frw->readers++; 285 if (frw->readers++ == 0) { 286 /* Consider the first reader the owner. */ 287 frw->oi.owned_by = f; 288 } 204 289 optimize_execution_power(); 205 290 } -
uspace/lib/c/generic/io/klog.c
r9a1d8ab r0b749a3 52 52 void klog_update(void) 53 53 { 54 (void) __SYSCALL3(SYS_KLOG, 1, NULL, 0);54 (void) __SYSCALL3(SYS_KLOG, 1, (uintptr_t) NULL, 0); 55 55 } 56 56 -
uspace/lib/c/generic/libc.c
r9a1d8ab r0b749a3 50 50 #include <ipc/ipc.h> 51 51 #include <async.h> 52 #include <async_rel.h> 52 53 #include <as.h> 53 54 #include <loader/pcb.h> … … 65 66 __heap_init(); 66 67 __async_init(); 68 (void) async_rel_init(); 67 69 fibril_t *fibril = fibril_setup(); 68 70 __tcb_set(fibril->tcb); -
uspace/lib/c/generic/net/icmp_common.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP common interface implementation.35 * @see icmp_common.h34 * ICMP common interface implementation. 35 * @see icmp_common.h 36 36 */ 37 37 38 #include <net/modules.h> 39 #include <net/icmp_common.h> 40 41 #include <ipc/services.h> 42 #include <ipc/icmp.h> 43 44 #include <sys/time.h> 38 45 #include <async.h> 39 #include <ipc/services.h>40 46 41 #include <net_modules.h> 42 #include <icmp_common.h> 43 #include <icmp_messages.h> 44 45 int icmp_connect_module(services_t service, suseconds_t timeout){ 47 /** Connects to the ICMP module. 48 * 49 * @param service The ICMP module service. Ignored parameter. 50 * @param[in] timeout The connection timeout in microseconds. No timeout if 51 * set to zero. 52 * @return The ICMP module phone on success. 53 * @return ETIMEOUT if the connection timeouted. 54 */ 55 int icmp_connect_module(services_t service, suseconds_t timeout) 56 { 46 57 int phone; 47 58 48 59 phone = connect_to_service_timeout(SERVICE_ICMP, timeout); 49 if (phone >= 0){60 if (phone >= 0) 50 61 async_req_0_0(phone, NET_ICMP_INIT); 51 } 62 52 63 return phone; 53 64 } -
uspace/lib/c/generic/net/socket_parse.c
r9a1d8ab r0b749a3 35 35 */ 36 36 37 #include <socket_parse.h> 37 #include <net/socket_parse.h> 38 #include <net/socket.h> 38 39 #include <arg_parse.h> 39 40 #include <errno.h> 40 41 #include <str.h> 41 #include <socket.h>42 42 43 43 /** Translate the character string to the address family number. -
uspace/lib/c/generic/task.c
r9a1d8ab r0b749a3 39 39 #include <errno.h> 40 40 #include <loader/loader.h> 41 #include <stdarg.h> 41 42 #include <str.h> 42 43 #include <ipc/ns.h> … … 68 69 * 69 70 * This is really just a convenience wrapper over the more complicated 70 * loader API. 71 * 72 * @param path Pathname of the binary to execute. 73 * @param argv Command-line arguments. 74 * @param err If not NULL, the error value is stored here. 75 * 76 * @return ID of the newly created task or zero on error. 77 * 78 */ 79 task_id_t task_spawn(const char *path, const char *const args[], int *err) 80 { 71 * loader API. Arguments are passed as a null-terminated array of strings. 72 * 73 * @param id If not NULL, the ID of the task is stored here on success. 74 * @param path Pathname of the binary to execute. 75 * @param argv Command-line arguments. 76 * 77 * @return Zero on success or negative error code. 78 */ 79 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 80 { 81 loader_t *ldr; 82 task_id_t task_id; 83 int rc; 84 81 85 /* Connect to a program loader. */ 82 loader_t *ldr = loader_connect(); 83 if (ldr == NULL) { 84 if (err != NULL) 85 *err = EREFUSED; 86 87 return 0; 88 } 86 ldr = loader_connect(); 87 if (ldr == NULL) 88 return EREFUSED; 89 89 90 90 /* Get task ID. */ 91 task_id_t task_id; 92 int rc = loader_get_task_id(ldr, &task_id); 91 rc = loader_get_task_id(ldr, &task_id); 93 92 if (rc != EOK) 94 93 goto error; … … 149 148 free(ldr); 150 149 151 if ( err!= NULL)152 * err = EOK;153 154 return task_id;150 if (id != NULL) 151 *id = task_id; 152 153 return EOK; 155 154 156 155 error: … … 158 157 loader_abort(ldr); 159 158 free(ldr); 160 161 if (err != NULL) 162 *err = rc; 163 164 return 0; 159 return rc; 160 } 161 162 /** Create a new task by running an executable from the filesystem. 163 * 164 * This is really just a convenience wrapper over the more complicated 165 * loader API. Arguments are passed as a null-terminated list of arguments. 166 * 167 * @param id If not NULL, the ID of the task is stored here on success. 168 * @param path Pathname of the binary to execute. 169 * @param ... Command-line arguments. 170 * 171 * @return Zero on success or negative error code. 172 */ 173 int task_spawnl(task_id_t *task_id, const char *path, ...) 174 { 175 va_list ap; 176 int rc, cnt; 177 const char *arg; 178 const char **arglist; 179 180 /* Count the number of arguments. */ 181 cnt = 0; 182 va_start(ap, path); 183 do { 184 arg = va_arg(ap, const char *); 185 cnt++; 186 } while (arg != NULL); 187 va_end(ap); 188 189 /* Allocate argument list. */ 190 arglist = malloc(cnt * sizeof(const char *)); 191 if (arglist == NULL) 192 return ENOMEM; 193 194 /* Fill in arguments. */ 195 cnt = 0; 196 va_start(ap, path); 197 do { 198 arg = va_arg(ap, const char *); 199 arglist[cnt++] = arg; 200 } while (arg != NULL); 201 va_end(ap); 202 203 /* Spawn task. */ 204 rc = task_spawnv(task_id, path, arglist); 205 206 /* Free argument list. */ 207 free(arglist); 208 return rc; 165 209 } 166 210 -
uspace/lib/c/generic/vfs/vfs.c
r9a1d8ab r0b749a3 136 136 } 137 137 138 dev _handle_t dev_handle;139 int res = devmap_device_get_handle(fqdn, &dev _handle, flags);138 devmap_handle_t devmap_handle; 139 int res = devmap_device_get_handle(fqdn, &devmap_handle, flags); 140 140 if (res != EOK) { 141 141 if (null_id != -1) … … 159 159 160 160 ipcarg_t rc_orig; 161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, dev _handle, flags, NULL);161 aid_t req = async_send_2(vfs_phone, VFS_IN_MOUNT, devmap_handle, flags, NULL); 162 162 ipcarg_t rc = async_data_write_start(vfs_phone, (void *) mpa, mpa_size); 163 163 if (rc != EOK) { … … 328 328 ipc_call_t answer; 329 329 aid_t req = async_send_4(vfs_phone, VFS_IN_OPEN_NODE, node->fs_handle, 330 node->dev _handle, node->index, oflag, &answer);330 node->devmap_handle, node->index, oflag, &answer); 331 331 332 332 ipcarg_t rc; … … 797 797 if (rc == EOK) { 798 798 node->fs_handle = stat.fs_handle; 799 node->dev _handle = stat.dev_handle;799 node->devmap_handle = stat.devmap_handle; 800 800 node->index = stat.index; 801 801 } -
uspace/lib/c/include/adt/dynamic_fifo.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_IP_LOCAL_H__ 34 #define __NET_IP_LOCAL_H__ 33 /** @file 34 * Dynamic first in first out positive integer queue. 35 * Possitive integer values only. 36 */ 35 37 36 #i nclude <async.h>37 # include <ipc/services.h>38 #ifndef LIBC_DYNAMIC_FIFO_H_ 39 #define LIBC_DYNAMIC_FIFO_H_ 38 40 39 #include <ip_codes.h> 40 #include <inet.h> 41 #include <in.h> 42 #include <socket.h> 41 /** Type definition of the dynamic fifo queue. 42 * @see dyn_fifo 43 */ 44 typedef struct dyn_fifo dyn_fifo_t; 43 45 44 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t, 45 services_t); 46 extern int ip_set_gateway_req_local(int, device_id_t, in_addr_t); 47 extern int ip_packet_size_req_local(int, device_id_t, packet_dimension_ref); 48 extern int ip_received_error_msg_local(int, device_id_t, packet_t, services_t, 49 services_t); 50 extern int ip_device_req_local(int, device_id_t, services_t); 51 extern int ip_add_route_req_local(int, device_id_t, in_addr_t, in_addr_t, 52 in_addr_t); 53 extern int ip_send_msg_local(int, device_id_t, packet_t, services_t, 54 services_t); 55 extern int ip_get_route_req_local(int, ip_protocol_t, const struct sockaddr *, 56 socklen_t, device_id_t *, void **, size_t *); 46 /** Dynamic first in first out positive integer queue. 47 * Possitive integer values only. 48 * The queue automatically resizes if needed. 49 */ 50 struct dyn_fifo { 51 /** Stored item field. */ 52 int *items; 53 /** Actual field size. */ 54 int size; 55 /** First item in the queue index. */ 56 int head; 57 /** Last item in the queue index. */ 58 int tail; 59 /** Consistency check magic value. */ 60 int magic_value; 61 }; 62 63 extern int dyn_fifo_initialize(dyn_fifo_t *, int); 64 extern int dyn_fifo_destroy(dyn_fifo_t *); 65 extern int dyn_fifo_push(dyn_fifo_t *, int, int); 66 extern int dyn_fifo_pop(dyn_fifo_t *); 67 extern int dyn_fifo_value(dyn_fifo_t *); 57 68 58 69 #endif -
uspace/lib/c/include/byteorder.h
r9a1d8ab r0b749a3 80 80 #endif 81 81 82 #define htons(n) host2uint16_t_be((n)) 83 #define htonl(n) host2uint32_t_be((n)) 84 #define ntohs(n) uint16_t_be2host((n)) 85 #define ntohl(n) uint32_t_be2host((n)) 86 82 87 static inline uint64_t uint64_t_byteorder_swap(uint64_t n) 83 88 { -
uspace/lib/c/include/ddi.h
r9a1d8ab r0b749a3 41 41 extern int physmem_map(void *, void *, unsigned long, int); 42 42 extern int iospace_enable(task_id_t, void *, unsigned long); 43 extern int preemption_control(int);44 43 extern int pio_enable(void *, size_t, void **); 44 extern int interrupt_enable(int); 45 extern int interrupt_disable(int); 45 46 46 47 #endif -
uspace/lib/c/include/devmap.h
r9a1d8ab r0b749a3 44 44 45 45 extern int devmap_driver_register(const char *, async_client_conn_t); 46 extern int devmap_device_register(const char *, dev _handle_t *);46 extern int devmap_device_register(const char *, devmap_handle_t *); 47 47 48 extern int devmap_device_get_handle(const char *, dev _handle_t *, unsigned int);49 extern int devmap_namespace_get_handle(const char *, dev _handle_t *, unsigned int);50 extern devmap_handle_type_t devmap_handle_probe(dev _handle_t);48 extern int devmap_device_get_handle(const char *, devmap_handle_t *, unsigned int); 49 extern int devmap_namespace_get_handle(const char *, devmap_handle_t *, unsigned int); 50 extern devmap_handle_type_t devmap_handle_probe(devmap_handle_t); 51 51 52 extern int devmap_device_connect(dev _handle_t, unsigned int);52 extern int devmap_device_connect(devmap_handle_t, unsigned int); 53 53 54 54 extern int devmap_null_create(void); … … 56 56 57 57 extern size_t devmap_count_namespaces(void); 58 extern size_t devmap_count_devices(dev _handle_t);58 extern size_t devmap_count_devices(devmap_handle_t); 59 59 60 60 extern size_t devmap_get_namespaces(dev_desc_t **); 61 extern size_t devmap_get_devices(dev _handle_t, dev_desc_t **);61 extern size_t devmap_get_devices(devmap_handle_t, dev_desc_t **); 62 62 63 63 #endif -
uspace/lib/c/include/err.h
r9a1d8ab r0b749a3 36 36 #define LIBC_ERR_H_ 37 37 38 #include <stdio.h> 39 38 40 #define errx(status, fmt, ...) { \ 39 41 printf((fmt), ##__VA_ARGS__); \ … … 45 47 /** @} 46 48 */ 49 -
uspace/lib/c/include/errno.h
r9a1d8ab r0b749a3 56 56 #define EMLINK (-266) 57 57 58 /** An API function is called while another blocking function is in progress. */ 59 #define EINPROGRESS (-10036) 60 61 /** The socket identifier is not valid. */ 62 #define ENOTSOCK (-10038) 63 64 /** The destination address required. */ 65 #define EDESTADDRREQ (-10039) 66 67 /** Protocol is not supported. */ 68 #define EPROTONOSUPPORT (-10043) 69 70 /** Socket type is not supported. */ 71 #define ESOCKTNOSUPPORT (-10044) 72 73 /** Protocol family is not supported. */ 74 #define EPFNOSUPPORT (-10046) 75 76 /** Address family is not supported. */ 77 #define EAFNOSUPPORT (-10047) 78 79 /** Address is already in use. */ 80 #define EADDRINUSE (-10048) 81 82 /** The socket is not connected or bound. */ 83 #define ENOTCONN (-10057) 84 85 /** The requested operation was not performed. 86 * Try again later. 87 */ 88 #define TRY_AGAIN (-11002) 89 90 /** No data. 91 */ 92 #define NO_DATA (-11004) 93 58 94 #endif 59 95 -
uspace/lib/c/include/fibril.h
r9a1d8ab r0b749a3 48 48 #define FIBRIL_WRITER 2 49 49 50 struct fibril; 51 52 typedef struct { 53 struct fibril *owned_by; 54 } fibril_owner_info_t; 55 50 56 typedef enum { 51 57 FIBRIL_PREEMPT, … … 68 74 int retval; 69 75 int flags; 76 77 fibril_owner_info_t *waits_for; 70 78 } fibril_t; 71 79 -
uspace/lib/c/include/fibril_synch.h
r9a1d8ab r0b749a3 43 43 44 44 typedef struct { 45 fibril_owner_info_t oi; /* Keep this the first thing. */ 45 46 int counter; 46 47 link_t waiters; 47 48 } fibril_mutex_t; 48 49 49 #define FIBRIL_MUTEX_INITIALIZE(name) \ 50 fibril_mutex_t name = { \ 50 #define FIBRIL_MUTEX_INITIALIZER(name) \ 51 { \ 52 .oi = { \ 53 .owned_by = NULL \ 54 }, \ 51 55 .counter = 1, \ 52 56 .waiters = { \ … … 55 59 } \ 56 60 } 61 62 #define FIBRIL_MUTEX_INITIALIZE(name) \ 63 fibril_mutex_t name = FIBRIL_MUTEX_INITIALIZER(name) 57 64 58 65 typedef struct { 66 fibril_owner_info_t oi; /* Keep this the first thing. */ 59 67 unsigned writers; 60 68 unsigned readers; … … 62 70 } fibril_rwlock_t; 63 71 64 #define FIBRIL_RWLOCK_INITIALIZE(name) \ 65 fibril_rwlock_t name = { \ 72 #define FIBRIL_RWLOCK_INITIALIZER(name) \ 73 { \ 74 .oi = { \ 75 .owned_by = NULL \ 76 }, \ 66 77 .readers = 0, \ 67 78 .writers = 0, \ … … 72 83 } 73 84 85 #define FIBRIL_RWLOCK_INITIALIZE(name) \ 86 fibril_rwlock_t name = FIBRIL_RWLOCK_INITIALIZER(name) 87 74 88 typedef struct { 75 89 link_t waiters; 76 90 } fibril_condvar_t; 77 91 78 #define FIBRIL_CONDVAR_INITIALIZE (name) \79 fibril_condvar_t name ={ \92 #define FIBRIL_CONDVAR_INITIALIZER(name) \ 93 { \ 80 94 .waiters = { \ 81 95 .next = &name.waiters, \ … … 83 97 } \ 84 98 } 99 100 #define FIBRIL_CONDVAR_INITIALIZE(name) \ 101 fibril_condvar_t name = FIBRIL_CONDVAR_INITIALIZER(name) 85 102 86 103 extern void fibril_mutex_initialize(fibril_mutex_t *); -
uspace/lib/c/include/ipc/arp.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup arp30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ARP module messages.35 * @see arp_interface.h34 * ARP module messages. 35 * @see arp_interface.h 36 36 */ 37 37 38 #ifndef __NET_ARP_MESSAGES__39 #define __NET_ARP_MESSAGES__38 #ifndef LIBC_ARP_MESSAGES_ 39 #define LIBC_ARP_MESSAGES_ 40 40 41 41 #include <ipc/ipc.h> 42 #include <ipc/net.h> 42 43 43 #include <net_messages.h> 44 45 /** ARP module messages. 46 */ 47 typedef enum{ 44 /** ARP module messages. */ 45 typedef enum { 48 46 /** Clean cache message. 49 * @see arp_clean_cache()47 * @see arp_clean_cache() 50 48 */ 51 49 NET_ARP_CLEAN_CACHE = NET_ARP_FIRST, 52 50 /** Clear address cache message. 53 * @see arp_clear_address_msg()51 * @see arp_clear_address_msg() 54 52 */ 55 53 NET_ARP_CLEAR_ADDRESS, 56 54 /** Clear device cache message. 57 * @see arp_clear_device_req()55 * @see arp_clear_device_req() 58 56 */ 59 57 NET_ARP_CLEAR_DEVICE, 60 58 /** New device message. 61 * @see arp_device_req()59 * @see arp_device_req() 62 60 */ 63 61 NET_ARP_DEVICE, 64 62 /** Address translation message. 65 * @see arp_translate_req()63 * @see arp_translate_req() 66 64 */ 67 65 NET_ARP_TRANSLATE 68 66 } arp_messages; 69 67 70 /** @name ARP specific message parameters definitions 71 */ 68 /** @name ARP specific message parameters definitions */ 72 69 /*@{*/ 73 70 74 71 /** Returns the protocol service message parameter. 75 * @param[in] call The message call structure.72 * @param[in] call The message call structure. 76 73 */ 77 74 #define ARP_GET_NETIF(call) \ 78 ({services_t service = (services_t) IPC_GET_ARG2(*call); service;}) 75 ({ \ 76 services_t service = (services_t) IPC_GET_ARG2(*call); \ 77 service; \ 78 }) 79 79 80 80 /*@}*/ -
uspace/lib/c/include/ipc/devmap.h
r9a1d8ab r0b749a3 40 40 #define DEVMAP_NAME_MAXLEN 255 41 41 42 typedef ipcarg_t dev _handle_t;42 typedef ipcarg_t devmap_handle_t; 43 43 44 44 typedef enum { … … 81 81 82 82 typedef struct { 83 dev _handle_t handle;83 devmap_handle_t handle; 84 84 char name[DEVMAP_NAME_MAXLEN + 1]; 85 85 } dev_desc_t; -
uspace/lib/c/include/ipc/icmp.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP module messages.35 * @see icmp_interface.h34 * ICMP module messages. 35 * @see icmp_interface.h 36 36 */ 37 37 38 #ifndef __NET_ICMP_MESSAGES__39 #define __NET_ICMP_MESSAGES__38 #ifndef LIBC_ICMP_MESSAGES_ 39 #define LIBC_ICMP_MESSAGES_ 40 40 41 41 #include <ipc/ipc.h> 42 #include <ipc/net.h> 42 43 #include <sys/types.h> 44 #include <sys/time.h> 43 45 44 #include <icmp_codes.h> 45 #include <net_messages.h> 46 #include <net/icmp_codes.h> 46 47 47 /** ICMP module messages. 48 */ 49 typedef enum{ 50 /** Sends echo request. 51 * @see icmp_echo() 52 */ 48 /** ICMP module messages. */ 49 typedef enum { 50 /** Sends echo request. @see icmp_echo() */ 53 51 NET_ICMP_ECHO = NET_ICMP_FIRST, 54 /** Sends destination unreachable error message. 55 * @see icmp_destination_unreachable_msg() 52 53 /** 54 * Sends destination unreachable error message. 55 * @see icmp_destination_unreachable_msg() 56 56 */ 57 57 NET_ICMP_DEST_UNREACH, 58 /** Sends source quench error message. 59 * @see icmp_source_quench_msg() 58 59 /** 60 * Sends source quench error message. 61 * @see icmp_source_quench_msg() 60 62 */ 61 63 NET_ICMP_SOURCE_QUENCH, 62 /** Sends time exceeded error message. 63 * @see icmp_time_exceeded_msg() 64 65 /** 66 * Sends time exceeded error message. 67 * @see icmp_time_exceeded_msg() 64 68 */ 65 69 NET_ICMP_TIME_EXCEEDED, 66 /** Sends parameter problem error message. 67 * @see icmp_parameter_problem_msg() 70 71 /** 72 * Sends parameter problem error message. 73 * @see icmp_parameter_problem_msg() 68 74 */ 69 75 NET_ICMP_PARAMETERPROB, 70 /** Initializes new connection.71 */76 77 /** Initializes new connection. */ 72 78 NET_ICMP_INIT 73 79 } icmp_messages; 74 80 75 /** @name ICMP specific message parameters definitions 76 */ 81 /** @name ICMP specific message parameters definitions */ 77 82 /*@{*/ 78 83 79 84 /** Returns the ICMP code message parameter. 80 * @param[in] call The message call structure. 85 * 86 * @param[in] call The message call structure. 81 87 */ 82 88 #define ICMP_GET_CODE(call) \ 83 ({icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); code;}) 89 ({ \ 90 icmp_code_t code = (icmp_code_t) IPC_GET_ARG1(*call); \ 91 code; \ 92 }) 84 93 85 94 /** Returns the ICMP link MTU message parameter. 86 * @param[in] call The message call structure. 95 * 96 * @param[in] call The message call structure. 87 97 */ 88 98 #define ICMP_GET_MTU(call) \ 89 ({icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); mtu;}) 99 ({ \ 100 icmp_param_t mtu = (icmp_param_t) IPC_GET_ARG3(*call); \ 101 mtu; \ 102 }) 90 103 91 104 /** Returns the pointer message parameter. 92 * @param[in] call The message call structure. 105 * 106 * @param[in] call The message call structure. 93 107 */ 94 108 #define ICMP_GET_POINTER(call) \ 95 ({icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); pointer;}) 109 ({ \ 110 icmp_param_t pointer = (icmp_param_t) IPC_GET_ARG3(*call); \ 111 pointer; \ 112 }) 96 113 97 114 /** Returns the size message parameter. 98 * @param[in] call The message call structure. 115 * 116 * @param[in] call The message call structure. 99 117 */ 100 118 #define ICMP_GET_SIZE(call) \ 101 ({size_t size = (size_t) IPC_GET_ARG1(call); size;}) 119 ({ \ 120 size_t size = (size_t) IPC_GET_ARG1(call); \ 121 size; \ 122 }) 102 123 103 124 /** Returns the timeout message parameter. 104 * @param[in] call The message call structure. 125 * 126 * @param[in] call The message call structure. 105 127 */ 106 128 #define ICMP_GET_TIMEOUT(call) \ 107 (({suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); timeout;})) 129 ({ \ 130 suseconds_t timeout = (suseconds_t) IPC_GET_ARG2(call); \ 131 timeout; \ 132 }) 108 133 109 134 /** Returns the time to live message parameter. 110 * @param[in] call The message call structure. 135 * 136 * @param[in] call The message call structure. 111 137 */ 112 138 #define ICMP_GET_TTL(call) \ 113 ({ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); ttl;}) 139 ({ \ 140 ip_ttl_t ttl = (ip_ttl_t) IPC_GET_ARG3(call); \ 141 ttl; \ 142 }) 114 143 115 144 /** Returns the type of service message parameter. 116 * @param[in] call The message call structure. 145 * 146 * @param[in] call The message call structure. 117 147 */ 118 148 #define ICMP_GET_TOS(call) \ 119 ({ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); tos;}) 149 ({ \ 150 ip_tos_t tos = (ip_tos_t) IPC_GET_ARG4(call); \ 151 tos; \ 152 }) 120 153 121 154 /** Returns the dont fragment message parameter. 122 * @param[in] call The message call structure. 155 * 156 * @param[in] call The message call structure. 123 157 */ 124 158 #define ICMP_GET_DONT_FRAGMENT(call) \ 125 ({int dont_fragment = (int) IPC_GET_ARG5(call); dont_fragment;}) 159 ({ \ 160 int dont_fragment = (int) IPC_GET_ARG5(call); \ 161 dont_fragment; \ 162 }) 126 163 127 164 /*@}*/ -
uspace/lib/c/include/ipc/il.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_il29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 37 37 */ 38 38 39 #ifndef __NET_IL_MESSAGES_H__40 #define __NET_IL_MESSAGES_H__39 #ifndef LIBC_IL_MESSAGES_H_ 40 #define LIBC_IL_MESSAGES_H_ 41 41 42 42 #include <ipc/ipc.h> 43 #include <ipc/net.h> 43 44 44 /** Internet layer modules messages. 45 */ 45 /** Internet layer modules messages. */ 46 46 typedef enum { 47 47 /** New device message. 48 * @see ip_device_req()48 * @see ip_device_req() 49 49 */ 50 50 NET_IL_DEVICE = NET_IL_FIRST, 51 51 /** Device state changed message. 52 * @see il_device_state_msg()52 * @see il_device_state_msg() 53 53 */ 54 54 NET_IL_DEVICE_STATE, 55 55 /** Device MTU changed message. 56 * @see il_mtu_changed_msg()56 * @see il_mtu_changed_msg() 57 57 */ 58 58 NET_IL_MTU_CHANGED, 59 59 /** Packet size message. 60 * @see il_packet_size_req()60 * @see il_packet_size_req() 61 61 */ 62 62 NET_IL_PACKET_SPACE, 63 63 /** Packet received message. 64 * @see il_received_msg()64 * @see il_received_msg() 65 65 */ 66 66 NET_IL_RECEIVED, 67 67 /** Packet send message. 68 * @see il_send_msg()68 * @see il_send_msg() 69 69 */ 70 70 NET_IL_SEND 71 71 } il_messages; 72 72 73 /** @name Internetwork layer specific message parameters definitions 74 * 75 */ 73 /** @name Internetwork layer specific message parameters definitions */ 76 74 /*@{*/ 77 75 78 76 /** Return the protocol number message parameter. 79 77 * @param[in] call The message call structure. 80 *81 78 */ 82 #define IL_GET_PROTO(call) (int) IPC_GET_ARG1(*call)79 #define IL_GET_PROTO(call) (int) IPC_GET_ARG1(*call) 83 80 84 81 /** Return the registering service message parameter. 85 82 * @param[in] call The message call structure. 86 *87 83 */ 88 #define IL_GET_SERVICE(call) (services_t) IPC_GET_ARG2(*call)84 #define IL_GET_SERVICE(call) (services_t) IPC_GET_ARG2(*call) 89 85 90 86 /*@}*/ -
uspace/lib/c/include/ipc/ip.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * IP module messages.35 * @see ip_interface.h34 * IP module messages. 35 * @see ip_interface.h 36 36 */ 37 37 38 #ifndef __NET_IP_MESSAGES_H__39 #define __NET_IP_MESSAGES_H__38 #ifndef LIBC_IP_MESSAGES_H_ 39 #define LIBC_IP_MESSAGES_H_ 40 40 41 41 #include <ipc/ipc.h> 42 #include <ipc/net.h> 42 43 43 #include < in.h>44 #include < ip_codes.h>44 #include <net/in.h> 45 #include <net/ip_codes.h> 45 46 46 /** IP module messages. 47 */ 48 typedef enum{ 47 /** IP module messages. */ 48 typedef enum { 49 49 /** Adds the routing entry. 50 * @see ip_add_route()50 * @see ip_add_route() 51 51 */ 52 52 NET_IP_ADD_ROUTE = NET_IP_FIRST, 53 53 /** Gets the actual route information. 54 * @see ip_get_route()54 * @see ip_get_route() 55 55 */ 56 56 NET_IP_GET_ROUTE, 57 57 /** Processes the received error notification. 58 * @see ip_received_error_msg()58 * @see ip_received_error_msg() 59 59 */ 60 60 NET_IP_RECEIVED_ERROR, 61 61 /** Sets the default gateway. 62 * @see ip_set_default_gateway()62 * @see ip_set_default_gateway() 63 63 */ 64 64 NET_IP_SET_GATEWAY 65 65 } ip_messages; 66 66 67 /** @name IP specific message parameters definitions 68 */ 67 /** @name IP specific message parameters definitions */ 69 68 /*@{*/ 70 69 71 70 /** Returns the address message parameter. 72 * @param[in] call The message call structure.71 * @param[in] call The message call structure. 73 72 */ 74 73 #define IP_GET_ADDRESS(call) \ 75 ({in_addr_t addr; addr.s_addr = IPC_GET_ARG3(*call); addr;}) 74 ({ \ 75 in_addr_t addr; \ 76 addr.s_addr = IPC_GET_ARG3(*call); \ 77 addr; \ 78 }) 76 79 77 80 /** Returns the gateway message parameter. 78 * @param[in] call The message call structure.81 * @param[in] call The message call structure. 79 82 */ 80 83 #define IP_GET_GATEWAY(call) \ 81 ({in_addr_t addr; addr.s_addr = IPC_GET_ARG2(*call); addr;}) 84 ({ \ 85 in_addr_t addr; \ 86 addr.s_addr = IPC_GET_ARG2(*call); \ 87 addr; \ 88 }) 82 89 83 90 /** Sets the header length in the message answer. 84 * @param[out] answer The message answer structure.91 * @param[out] answer The message answer structure. 85 92 */ 86 93 #define IP_SET_HEADERLEN(answer, value) \ 87 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(*answer, argument);} 94 do { \ 95 ipcarg_t argument = (ipcarg_t) (value); \ 96 IPC_SET_ARG2(*answer, argument); \ 97 } while (0) 88 98 89 99 /** Returns the network mask message parameter. 90 * @param[in] call The message call structure.100 * @param[in] call The message call structure. 91 101 */ 92 102 #define IP_GET_NETMASK(call) \ 93 ({in_addr_t addr; addr.s_addr = IPC_GET_ARG4(*call); addr;}) 103 ({ \ 104 in_addr_t addr; \ 105 addr.s_addr = IPC_GET_ARG4(*call); \ 106 addr; \ 107 }) 94 108 95 109 /** Returns the protocol message parameter. 96 * @param[in] call The message call structure.110 * @param[in] call The message call structure. 97 111 */ 98 112 #define IP_GET_PROTOCOL(call) \ 99 ({ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); protocol;}) 113 ({ \ 114 ip_protocol_t protocol = (ip_protocol_t) IPC_GET_ARG1(*call); \ 115 protocol; \ 116 }) 100 117 101 118 /*@}*/ -
uspace/lib/c/include/ipc/net_net.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Networking subsystem central module messages.35 * @see net_interface.h34 * Networking subsystem central module messages. 35 * @see net_interface.h 36 36 */ 37 37 38 #ifndef __NET_NET_MESSAGES_H__39 #define __NET_NET_MESSAGES_H__38 #ifndef LIBC_NET_NET_MESSAGES_H_ 39 #define LIBC_NET_NET_MESSAGES_H_ 40 40 41 41 #include <ipc/ipc.h> 42 #include <ipc/net.h> 42 43 43 #include <net_messages.h> 44 45 /** Networking subsystem central module messages. 46 */ 47 typedef enum{ 44 /** Networking subsystem central module messages. */ 45 typedef enum { 48 46 /** Returns the general configuration 49 * @see net_get_conf_req()47 * @see net_get_conf_req() 50 48 */ 51 49 NET_NET_GET_CONF = NET_FIRST, 52 50 /** Returns the device specific configuration 53 * @see net_get_device_conf_req()51 * @see net_get_device_conf_req() 54 52 */ 55 53 NET_NET_GET_DEVICE_CONF, 56 /** Starts the networking stack. 57 */ 54 /** Starts the networking stack. */ 58 55 NET_NET_STARTUP, 59 56 } net_messages; -
uspace/lib/c/include/ipc/netif.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef __NET_NETIF_MESSAGES_H__38 #define __NET_NETIF_MESSAGES_H__37 #ifndef LIBC_NETIF_MESSAGES_H_ 38 #define LIBC_NETIF_MESSAGES_H_ 39 39 40 40 #include <ipc/ipc.h> 41 #include <ipc/net.h> 41 42 42 #include <net_messages.h> 43 44 /** Network interface common module messages. 45 */ 43 /** Network interface common module messages. */ 46 44 typedef enum { 47 45 /** Probe device message. 48 * @see netif_probe_req()46 * @see netif_probe_req() 49 47 */ 50 48 NET_NETIF_PROBE = NET_NETIF_FIRST, 51 49 /** Send packet message. 52 * @see netif_send_msg()50 * @see netif_send_msg() 53 51 */ 54 52 NET_NETIF_SEND, 55 53 /** Start device message. 56 * @see netif_start_req()54 * @see netif_start_req() 57 55 */ 58 56 NET_NETIF_START, 59 57 /** Get device usage statistics message. 60 * @see netif_stats_req()58 * @see netif_stats_req() 61 59 */ 62 60 NET_NETIF_STATS, 63 61 /** Stop device message. 64 * @see netif_stop_req()62 * @see netif_stop_req() 65 63 */ 66 64 NET_NETIF_STOP, 67 65 /** Get device address message. 68 * @see netif_get_addr_req()66 * @see netif_get_addr_req() 69 67 */ 70 68 NET_NETIF_GET_ADDR, 71 69 } netif_messages; 72 70 73 /** @name Network interface specific message parameters definitions 74 */ 71 /** @name Network interface specific message parameters definitions */ 75 72 /*@{*/ 76 73 … … 79 76 */ 80 77 #define NETIF_GET_IRQ(call) \ 81 ({int irq = (int) IPC_GET_ARG2(*call); irq;}) 78 ({ \ 79 int irq = (int) IPC_GET_ARG2(*call); \ 80 irq; \ 81 }) 82 82 83 83 /** Return the input/output address message parameter. … … 85 85 */ 86 86 #define NETIF_GET_IO(call) \ 87 ({int io = (int) IPC_GET_ARG3(*call); io;}) 87 ({ \ 88 int io = (int) IPC_GET_ARG3(*call); \ 89 io; \ 90 }) 88 91 89 92 /*@}*/ -
uspace/lib/c/include/ipc/nil.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef __NET_NIL_MESSAGES_H__38 #define __NET_NIL_MESSAGES_H__37 #ifndef LIBC_NIL_MESSAGES_H_ 38 #define LIBC_NIL_MESSAGES_H_ 39 39 40 40 #include <ipc/ipc.h> 41 #include <ipc/net.h> 41 42 42 #include <net_messages.h> 43 44 /** Network interface layer module messages. 45 */ 43 /** Network interface layer module messages. */ 46 44 typedef enum { 47 45 /** New device or update MTU message. 48 * @see nil_device_req()46 * @see nil_device_req() 49 47 */ 50 48 NET_NIL_DEVICE = NET_NIL_FIRST, 51 49 /** New device state message. 52 * @see nil_device_state_msg()50 * @see nil_device_state_msg() 53 51 */ 54 52 NET_NIL_DEVICE_STATE, 55 53 /** Received packet queue message. 56 * @see nil_received_msg()54 * @see nil_received_msg() 57 55 */ 58 56 NET_NIL_RECEIVED, 59 57 /** Send packet queue message. 60 * @see nil_send_msg()58 * @see nil_send_msg() 61 59 */ 62 60 NET_NIL_SEND, 63 61 /** Packet size message. 64 * @see nil_packet_size_req()62 * @see nil_packet_size_req() 65 63 */ 66 64 NET_NIL_PACKET_SPACE, 67 65 /** Device local hardware address message. 68 * @see nil_get_addr()66 * @see nil_get_addr() 69 67 */ 70 68 NET_NIL_ADDR, 71 69 /** Device broadcast hardware address message. 72 * @see nil_get_broadcast_addr()70 * @see nil_get_broadcast_addr() 73 71 */ 74 72 NET_NIL_BROADCAST_ADDR, 75 73 } nil_messages; 76 74 77 /** @name Network interface layer specific message parameters definitions 78 */ 75 /** @name Network interface layer specific message parameters definitions */ 79 76 /*@{*/ 80 77 81 /** Return the protocol service message parameter. 82 */ 78 /** Return the protocol service message parameter. */ 83 79 #define NIL_GET_PROTO(call) \ 84 ({services_t service = (services_t) IPC_GET_ARG2(*call); service;}) 80 ({ \ 81 services_t service = (services_t) IPC_GET_ARG2(*call); \ 82 service; \ 83 }) 85 84 86 85 /*@}*/ -
uspace/lib/c/include/ipc/packet.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef __NET_PACKET_MESSAGES__38 #define __NET_PACKET_MESSAGES__37 #ifndef LIBC_PACKET_MESSAGES_ 38 #define LIBC_PACKET_MESSAGES_ 39 39 40 40 #include <ipc/ipc.h> 41 #include <ipc/net.h> 41 42 42 #include <net_messages.h> 43 44 /** Packet server module messages. 45 */ 43 /** Packet server module messages. */ 46 44 typedef enum { 47 45 /** Create packet message with specified content length. 48 * @see packet_get_1()46 * @see packet_get_1() 49 47 */ 50 48 NET_PACKET_CREATE_1 = NET_PACKET_FIRST, 51 /** Create packet message with specified address length, prefix, content and suffix. 52 * @see packet_get_4() 49 50 /** 51 * Create packet message with specified address length, prefix, content 52 * and suffix. 53 * @see packet_get_4() 53 54 */ 54 55 NET_PACKET_CREATE_4, 56 55 57 /** Get packet message. 56 * @see packet_return() 57 */ 58 * @see packet_return() */ 58 59 NET_PACKET_GET, 60 59 61 /** Get packet size message. 60 * @see packet_translate()62 * @see packet_translate() 61 63 */ 62 64 NET_PACKET_GET_SIZE, 65 63 66 /** Release packet message. 64 * @see pq_release()67 * @see pq_release() 65 68 */ 66 69 NET_PACKET_RELEASE 67 70 } packet_messages; 68 71 69 /** Returns the protocol service message parameter. 70 */ 71 #define ARP_GET_PROTO(call) (services_t) IPC_GET_ARG2(*call) 72 /** Returns the protocol service message parameter. */ 73 #define ARP_GET_PROTO(call) (services_t) IPC_GET_ARG2(*call) 72 74 73 /** Returns the packet identifier message parameter. 74 */ 75 #define IPC_GET_ID(call) (packet_id_t) IPC_GET_ARG1(*call) 75 /** Returns the packet identifier message parameter. */ 76 #define IPC_GET_ID(call) (packet_id_t) IPC_GET_ARG1(*call) 76 77 77 /** Returns the maximal content length message parameter. 78 */ 79 #define IPC_GET_CONTENT(call) (size_t) IPC_GET_ARG1(*call) 78 /** Returns the maximal content length message parameter. */ 79 #define IPC_GET_CONTENT(call) (size_t) IPC_GET_ARG1(*call) 80 80 81 /** Returns the maximal address length message parameter. 82 */ 81 /** Returns the maximal address length message parameter. */ 83 82 #define IPC_GET_ADDR_LEN(call) (size_t) IPC_GET_ARG2(*call) 84 83 85 /** Returns the maximal prefix length message parameter. 86 */ 87 #define IPC_GET_PREFIX(call) (size_t) IPC_GET_ARG3(*call) 84 /** Returns the maximal prefix length message parameter. */ 85 #define IPC_GET_PREFIX(call) (size_t) IPC_GET_ARG3(*call) 88 86 89 /** Returns the maximal suffix length message parameter. 90 */ 91 #define IPC_GET_SUFFIX(call) (size_t) IPC_GET_ARG4(*call) 87 /** Returns the maximal suffix length message parameter. */ 88 #define IPC_GET_SUFFIX(call) (size_t) IPC_GET_ARG4(*call) 92 89 93 90 #endif -
uspace/lib/c/include/ipc/services.h
r9a1d8ab r0b749a3 39 39 40 40 typedef enum { 41 SERVICE_LOAD = 1, 41 SERVICE_NONE = 0, 42 SERVICE_LOAD, 42 43 SERVICE_PCI, 43 44 SERVICE_VIDEO, … … 45 46 SERVICE_VFS, 46 47 SERVICE_DEVMAP, 48 SERVICE_DEVMAN, 47 49 SERVICE_FHC, 48 50 SERVICE_OBIO, -
uspace/lib/c/include/ipc/socket.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup socket30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Socket messages. 35 * @see socket.h 36 */ 37 38 39 #ifndef __NET_SOCKET_MESSAGES_H__ 40 #define __NET_SOCKET_MESSAGES_H__ 34 * Socket messages. 35 */ 36 37 #ifndef LIBC_SOCKET_MESSAGES_H_ 38 #define LIBC_SOCKET_MESSAGES_H_ 41 39 42 40 #include <ipc/ipc.h> 43 44 #include <net_messages.h> 45 #include <socket_codes.h> 46 47 /** Socket client messages. 48 */ 49 typedef enum{ 50 /** Creates a new socket. 51 * @see socket() 52 */ 41 #include <ipc/net.h> 42 43 /** Socket client messages. */ 44 typedef enum { 45 /** Creates a new socket. @see socket() */ 53 46 NET_SOCKET = NET_SOCKET_FIRST, 54 /** Binds the socket. 55 * @see bind() 56 */ 47 /** Binds the socket. @see bind() */ 57 48 NET_SOCKET_BIND, 58 /** Creates a new socket. 59 * @see socket() 60 */ 49 /** Creates a new socket. @see socket() */ 61 50 NET_SOCKET_LISTEN, 62 /** Accepts an incomming connection. 63 * @see accept() 64 */ 51 /** Accepts an incomming connection. @see accept() */ 65 52 NET_SOCKET_ACCEPT, 66 /** Connects the socket. 67 * @see connect() 68 */ 53 /** Connects the socket. @see connect() */ 69 54 NET_SOCKET_CONNECT, 70 /** Closes the socket. 71 * @see closesocket() 72 */ 55 /** Closes the socket. @see closesocket() */ 73 56 NET_SOCKET_CLOSE, 74 /** Sends data via the stream socket. 75 * @see send() 76 */ 57 /** Sends data via the stream socket. @see send() */ 77 58 NET_SOCKET_SEND, 78 /** Sends data via the datagram socket. 79 * @see sendto() 80 */ 59 /** Sends data via the datagram socket. @see sendto() */ 81 60 NET_SOCKET_SENDTO, 82 /** Receives data from the stream socket. 83 * @see socket() 84 */ 61 /** Receives data from the stream socket. @see socket() */ 85 62 NET_SOCKET_RECV, 86 /** Receives data from the datagram socket. 87 * @see socket() 88 */ 63 /** Receives data from the datagram socket. @see socket() */ 89 64 NET_SOCKET_RECVFROM, 90 /** Gets the socket option. 91 * @see getsockopt() 92 */ 65 /** Gets the socket option. @see getsockopt() */ 93 66 NET_SOCKET_GETSOCKOPT, 94 /** Sets the socket option. 95 * @see setsockopt() 96 */ 67 /** Sets the socket option. @see setsockopt() */ 97 68 NET_SOCKET_SETSOCKOPT, 98 /** New socket for acceptence notification message. 99 */ 69 /** New socket for acceptence notification message. */ 100 70 NET_SOCKET_ACCEPTED, 101 /** New data received notification message. 102 */ 71 /** New data received notification message. */ 103 72 NET_SOCKET_RECEIVED, 104 /** New socket data fragment size notification message. 105 */ 73 /** New socket data fragment size notification message. */ 106 74 NET_SOCKET_DATA_FRAGMENT_SIZE 107 75 } socket_messages; … … 112 80 113 81 /** Sets the socket identifier in the message answer. 114 * @param[out] answerThe message answer structure.82 * @param[out] answer The message answer structure. 115 83 */ 116 84 #define SOCKET_SET_SOCKET_ID(answer, value) \ 117 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);} 85 do { \ 86 ipcarg_t argument = (ipcarg_t) (value); \ 87 IPC_SET_ARG1(answer, argument); \ 88 } while (0) 118 89 119 90 /** Returns the socket identifier message parameter. 120 * @param[in] callThe message call structure.91 * @param[in] call The message call structure. 121 92 */ 122 93 #define SOCKET_GET_SOCKET_ID(call) \ 123 ({int socket_id = (int) IPC_GET_ARG1(call); socket_id;}) 94 ({ \ 95 int socket_id = (int) IPC_GET_ARG1(call); \ 96 socket_id; \ 97 }) 124 98 125 99 /** Sets the read data length in the message answer. 126 * @param[out] answerThe message answer structure.100 * @param[out] answer The message answer structure. 127 101 */ 128 102 #define SOCKET_SET_READ_DATA_LENGTH(answer, value) \ 129 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG1(answer, argument);} 103 do { \ 104 ipcarg_t argument = (ipcarg_t) (value); \ 105 IPC_SET_ARG1(answer, argument); \ 106 } while (0) 130 107 131 108 /** Returns the read data length message parameter. 132 * @param[in] callThe message call structure.109 * @param[in] call The message call structure. 133 110 */ 134 111 #define SOCKET_GET_READ_DATA_LENGTH(call) \ 135 ({int data_length = (int) IPC_GET_ARG1(call); data_length;}) 112 ({ \ 113 int data_length = (int) IPC_GET_ARG1(call); \ 114 data_length; \ 115 }) 136 116 137 117 /** Returns the backlog message parameter. 138 * @param[in] callThe message call structure.118 * @param[in] call The message call structure. 139 119 */ 140 120 #define SOCKET_GET_BACKLOG(call) \ 141 ({int backlog = (int) IPC_GET_ARG2(call); backlog;}) 121 ({ \ 122 int backlog = (int) IPC_GET_ARG2(call); \ 123 backlog; \ 124 }) 142 125 143 126 /** Returns the option level message parameter. 144 * @param[in] callThe message call structure.127 * @param[in] call The message call structure. 145 128 */ 146 129 #define SOCKET_GET_OPT_LEVEL(call) \ 147 ({int opt_level = (int) IPC_GET_ARG2(call); opt_level;}) 130 ({ \ 131 int opt_level = (int) IPC_GET_ARG2(call); \ 132 opt_level; \ 133 }) 148 134 149 135 /** Returns the data fragment size message parameter. 150 * @param[in] callThe message call structure.136 * @param[in] call The message call structure. 151 137 */ 152 138 #define SOCKET_GET_DATA_FRAGMENT_SIZE(call) \ 153 ({size_t size = (size_t) IPC_GET_ARG2(call); size;}) 139 ({ \ 140 size_t size = (size_t) IPC_GET_ARG2(call); \ 141 size; \ 142 }) 154 143 155 144 /** Sets the data fragment size in the message answer. 156 * @param[out] answerThe message answer structure.145 * @param[out] answer The message answer structure. 157 146 */ 158 147 #define SOCKET_SET_DATA_FRAGMENT_SIZE(answer, value) \ 159 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG2(answer, argument);} 148 do { \ 149 ipcarg_t argument = (ipcarg_t) (value); \ 150 IPC_SET_ARG2(answer, argument); \ 151 } while (0) 160 152 161 153 /** Sets the address length in the message answer. 162 * @param[out] answerThe message answer structure.154 * @param[out] answer The message answer structure. 163 155 */ 164 156 #define SOCKET_SET_ADDRESS_LENGTH(answer, value) \ 165 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);} 157 do { \ 158 ipcarg_t argument = (ipcarg_t) (value); \ 159 IPC_SET_ARG3(answer, argument);\ 160 } while (0) 166 161 167 162 /** Returns the address length message parameter. 168 * @param[in] callThe message call structure.163 * @param[in] call The message call structure. 169 164 */ 170 165 #define SOCKET_GET_ADDRESS_LENGTH(call) \ 171 ({socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); address_length;}) 166 ({ \ 167 socklen_t address_length = (socklen_t) IPC_GET_ARG3(call); \ 168 address_length; \ 169 }) 172 170 173 171 /** Sets the header size in the message answer. 174 * @param[out] answerThe message answer structure.172 * @param[out] answer The message answer structure. 175 173 */ 176 174 #define SOCKET_SET_HEADER_SIZE(answer, value) \ 177 \ 178 {ipcarg_t argument = (ipcarg_t) (value); IPC_SET_ARG3(answer, argument);} 175 do { \ 176 ipcarg_t argument = (ipcarg_t) (value); \ 177 IPC_SET_ARG3(answer, argument); \ 178 } while (0) 179 179 180 180 /** Returns the header size message parameter. 181 * @param[in] call The message call structure.181 * @param[in] call The message call structure. 182 182 */ 183 183 #define SOCKET_GET_HEADER_SIZE(call) \ 184 ({size_t size = (size_t) IPC_GET_ARG3(call); size;}) 184 ({ \ 185 size_t size = (size_t) IPC_GET_ARG3(call); \ 186 size; \ 187 }) 185 188 186 189 /** Returns the flags message parameter. 187 * @param[in] call The message call structure.190 * @param[in] call The message call structure. 188 191 */ 189 192 #define SOCKET_GET_FLAGS(call) \ 190 ({int flags = (int) IPC_GET_ARG4(call); flags;}) 193 ({ \ 194 int flags = (int) IPC_GET_ARG4(call); \ 195 flags; \ 196 }) 191 197 192 198 /** Returns the option name message parameter. 193 * @param[in] call The message call structure.199 * @param[in] call The message call structure. 194 200 */ 195 201 #define SOCKET_GET_OPT_NAME(call) \ 196 ({int opt_name = (int) IPC_GET_ARG4(call); opt_name;}) 202 ({ \ 203 int opt_name = (int) IPC_GET_ARG4(call); \ 204 opt_name; \ 205 }) 197 206 198 207 /** Returns the data fragments message parameter. 199 * @param[in] call The message call structure.208 * @param[in] call The message call structure. 200 209 */ 201 210 #define SOCKET_GET_DATA_FRAGMENTS(call) \ 202 ({int fragments = (int) IPC_GET_ARG5(call); fragments;}) 211 ({ \ 212 int fragments = (int) IPC_GET_ARG5(call); \ 213 fragments; \ 214 }) 203 215 204 216 /** Returns the new socket identifier message parameter. 205 * @param[in] call The message call structure.217 * @param[in] call The message call structure. 206 218 */ 207 219 #define SOCKET_GET_NEW_SOCKET_ID(call) \ 208 ({int socket_id = (int) IPC_GET_ARG5(call); socket_id;}) 220 ({ \ 221 int socket_id = (int) IPC_GET_ARG5(call); \ 222 socket_id; \ 223 }) 209 224 210 225 /*@}*/ -
uspace/lib/c/include/ipc/tl.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_tl30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Transport layer modules messages.35 * @see tl_interface.h34 * Transport layer modules messages. 35 * @see tl_interface.h 36 36 */ 37 37 38 #ifndef __NET_TL_MESSAGES_H__39 #define __NET_TL_MESSAGES_H__38 #ifndef LIBC_TL_MESSAGES_H_ 39 #define LIBC_TL_MESSAGES_H_ 40 40 41 41 #include <ipc/ipc.h> 42 #include <ipc/net.h> 42 43 43 #include <net_messages.h> 44 45 /** Transport layer modules messages. 46 */ 47 typedef enum{ 44 /** Transport layer modules messages. */ 45 typedef enum { 48 46 /** Packet received message. 49 * @see tl_received_msg()47 * @see tl_received_msg() 50 48 */ 51 49 NET_TL_RECEIVED = NET_TL_FIRST -
uspace/lib/c/include/net/device.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif30 * @{29 /** @addtogroup libc 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Device identifier, state and usage statistics.34 * Device identifier, state and usage statistics. 35 35 */ 36 36 37 #ifndef __NET_DEVICE_ID_TYPE_H__38 #define __NET_DEVICE_ID_TYPE_H__37 #ifndef LIBC_DEVICE_ID_TYPE_H_ 38 #define LIBC_DEVICE_ID_TYPE_H_ 39 39 40 40 #include <adt/int_map.h> 41 41 42 /** Device identifier to generic type map declaration. 43 */ 44 #define DEVICE_MAP_DECLARE INT_MAP_DECLARE 42 /** Device identifier to generic type map declaration. */ 43 #define DEVICE_MAP_DECLARE INT_MAP_DECLARE 45 44 46 /** Device identifier to generic type map implementation. 47 */ 45 /** Device identifier to generic type map implementation. */ 48 46 #define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT 49 47 50 /** Invalid device identifier. 51 */ 52 #define DEVICE_INVALID_ID (-1) 48 /** Invalid device identifier. */ 49 #define DEVICE_INVALID_ID (-1) 53 50 54 /** Device identifier type. 55 */ 56 typedef int device_id_t; 51 /** Device identifier type. */ 52 typedef int device_id_t; 57 53 58 /** Device state type. 59 */ 60 typedef enum device_state device_state_t; 54 /** Device state type. */ 55 typedef enum device_state device_state_t; 61 56 62 57 /** Type definition of the device usage statistics. 63 * @see device_stats58 * @see device_stats 64 59 */ 65 typedef struct device_stats device_stats_t;60 typedef struct device_stats device_stats_t; 66 61 67 /** Type definition of the device usage statistics pointer. 68 * @see device_stats 69 */ 70 typedef device_stats_t * device_stats_ref; 71 72 /** Device state. 73 */ 74 enum device_state{ 75 /** Device not present or not initialized. 76 */ 62 /** Device state. */ 63 enum device_state { 64 /** Device not present or not initialized. */ 77 65 NETIF_NULL = 0, 78 /** Device present and stopped. 79 */ 66 /** Device present and stopped. */ 80 67 NETIF_STOPPED, 81 /** Device present and active. 82 */ 68 /** Device present and active. */ 83 69 NETIF_ACTIVE, 84 /** Device present but unable to transmit. 85 */ 70 /** Device present but unable to transmit. */ 86 71 NETIF_CARRIER_LOST 87 72 }; 88 73 89 /** Device usage statistics. 90 */ 91 struct device_stats{ 92 /** Total packets received. 93 */ 74 /** Device usage statistics. */ 75 struct device_stats { 76 /** Total packets received. */ 94 77 unsigned long receive_packets; 95 /** Total packets transmitted. 96 */ 78 /** Total packets transmitted. */ 97 79 unsigned long send_packets; 98 /** Total bytes received. 99 */ 80 /** Total bytes received. */ 100 81 unsigned long receive_bytes; 101 /** Total bytes transmitted. 102 */ 82 /** Total bytes transmitted. */ 103 83 unsigned long send_bytes; 104 /** Bad packets received counter. 105 */ 84 /** Bad packets received counter. */ 106 85 unsigned long receive_errors; 107 /** Packet transmition problems counter. 108 */ 86 /** Packet transmition problems counter. */ 109 87 unsigned long send_errors; 110 /** No space in buffers counter. 111 */ 88 /** No space in buffers counter. */ 112 89 unsigned long receive_dropped; 113 /** No space available counter. 114 */ 90 /** No space available counter. */ 115 91 unsigned long send_dropped; 116 /** Total multicast packets received. 117 */ 92 /** Total multicast packets received. */ 118 93 unsigned long multicast; 119 /** The number of collisions due to congestion on the medium. 120 */ 94 /** The number of collisions due to congestion on the medium. */ 121 95 unsigned long collisions; 122 96 123 /* detailed receive_errors :*/124 /** Received packet length error counter. 125 */97 /* detailed receive_errors */ 98 99 /** Received packet length error counter. */ 126 100 unsigned long receive_length_errors; 127 /** Receiver buffer overflow counter. 128 */ 101 /** Receiver buffer overflow counter. */ 129 102 unsigned long receive_over_errors; 130 /** Received packet with crc error counter. 131 */ 103 /** Received packet with crc error counter. */ 132 104 unsigned long receive_crc_errors; 133 /** Received frame alignment error counter. 134 */ 105 /** Received frame alignment error counter. */ 135 106 unsigned long receive_frame_errors; 136 /** Receiver fifo overrun counter. 137 */ 107 /** Receiver fifo overrun counter. */ 138 108 unsigned long receive_fifo_errors; 139 /** Receiver missed packet counter. 140 */ 109 /** Receiver missed packet counter. */ 141 110 unsigned long receive_missed_errors; 142 111 143 112 /* detailed send_errors */ 144 /** Transmitter aborted counter. 145 */113 114 /** Transmitter aborted counter. */ 146 115 unsigned long send_aborted_errors; 147 /** Transmitter carrier errors counter. 148 */ 116 /** Transmitter carrier errors counter. */ 149 117 unsigned long send_carrier_errors; 150 /** Transmitter fifo overrun counter. 151 */ 118 /** Transmitter fifo overrun counter. */ 152 119 unsigned long send_fifo_errors; 153 /** Transmitter carrier errors counter. 154 */ 120 /** Transmitter carrier errors counter. */ 155 121 unsigned long send_heartbeat_errors; 156 /** Transmitter window errors counter. 157 */ 122 /** Transmitter window errors counter. */ 158 123 unsigned long send_window_errors; 159 124 160 125 /* for cslip etc */ 161 /** Total compressed packets received.162 */126 127 /** Total compressed packets received. */ 163 128 unsigned long receive_compressed; 164 /** Total compressed packet transmitted. 165 */ 129 /** Total compressed packet transmitted. */ 166 130 unsigned long send_compressed; 167 131 }; … … 171 135 /** @} 172 136 */ 173 -
uspace/lib/c/include/net/icmp_codes.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP types and codes according to the on-line IANA - ICMP Type Numbers - <http://http://www.iana.org/assignments/icmp-parameters>, cited September 14 2009. 35 */ 36 37 #ifndef __NET_ICMP_CODES_H__ 38 #define __NET_ICMP_CODES_H__ 39 40 /** ICMP type type definition. 41 */ 42 typedef uint8_t icmp_type_t; 43 44 /** ICMP code type definition. 45 */ 46 typedef uint8_t icmp_code_t; 47 48 /** ICMP parameter type definition. 49 */ 50 typedef uint16_t icmp_param_t; 51 52 /** @name ICMP types definitions 53 */ 54 /*@{*/ 55 56 /** Echo Reply. 57 */ 34 * ICMP types and codes according to the on-line IANA - ICMP Type Numbers 35 * 36 * http://www.iana.org/assignments/icmp-parameters> 37 * 38 * cited September 14 2009. 39 */ 40 41 #ifndef LIBC_ICMP_CODES_H_ 42 #define LIBC_ICMP_CODES_H_ 43 44 #include <sys/types.h> 45 46 /** ICMP type type definition. */ 47 typedef uint8_t icmp_type_t; 48 49 /** ICMP code type definition. */ 50 typedef uint8_t icmp_code_t; 51 52 /** ICMP parameter type definition. */ 53 typedef uint16_t icmp_param_t; 54 55 /** @name ICMP types definitions */ 56 /*@{*/ 57 58 /** Echo Reply. */ 58 59 #define ICMP_ECHOREPLY 0 59 60 60 /** Destination Unreachable. 61 */ 61 /** Destination Unreachable. */ 62 62 #define ICMP_DEST_UNREACH 3 63 63 64 /** Source Quench. 65 */ 64 /** Source Quench. */ 66 65 #define ICMP_SOURCE_QUENCH 4 67 66 68 /** Redirect. 69 */ 67 /** Redirect. */ 70 68 #define ICMP_REDIRECT 5 71 69 72 /** Alternate Host Address. 73 */ 70 /** Alternate Host Address. */ 74 71 #define ICMP_ALTERNATE_ADDR 6 75 72 76 /** Echo Request. 77 */ 78 #define ICMP_ECHO 8 79 80 /** Router Advertisement. 81 */ 73 /** Echo Request. */ 74 #define ICMP_ECHO 8 75 76 /** Router Advertisement. */ 82 77 #define ICMP_ROUTER_ADV 9 83 78 84 /** Router solicitation. 85 */ 79 /** Router solicitation. */ 86 80 #define ICMP_ROUTER_SOL 10 87 81 88 /** Time Exceeded. 89 */ 82 /** Time Exceeded. */ 90 83 #define ICMP_TIME_EXCEEDED 11 91 84 92 /** Parameter Problem. 93 */ 85 /** Parameter Problem. */ 94 86 #define ICMP_PARAMETERPROB 12 95 87 96 /** Timestamp Request. 97 */ 88 /** Timestamp Request. */ 98 89 #define ICMP_TIMESTAMP 13 99 90 100 /** Timestamp Reply. 101 */ 91 /** Timestamp Reply. */ 102 92 #define ICMP_TIMESTAMPREPLY 14 103 93 104 /** Information Request. 105 */ 94 /** Information Request. */ 106 95 #define ICMP_INFO_REQUEST 15 107 96 108 /** Information Reply. 109 */ 97 /** Information Reply. */ 110 98 #define ICMP_INFO_REPLY 16 111 99 112 /** Address Mask Request. 113 */ 100 /** Address Mask Request. */ 114 101 #define ICMP_ADDRESS 17 115 102 116 /** Address Mask Reply. 117 */ 103 /** Address Mask Reply. */ 118 104 #define ICMP_ADDRESSREPLY 18 119 105 120 /** Traceroute. 121 */ 106 /** Traceroute. */ 122 107 #define ICMP_TRACEROUTE 30 123 108 124 /** Datagram Conversion Error. 125 */ 109 /** Datagram Conversion Error. */ 126 110 #define ICMP_CONVERSION_ERROR 31 127 111 128 /** Mobile Host Redirect. 129 */ 112 /** Mobile Host Redirect. */ 130 113 #define ICMP_REDIRECT_MOBILE 32 131 114 132 /** IPv6 Where-Are-You. 133 */ 115 /** IPv6 Where-Are-You. */ 134 116 #define ICMP_IPV6_WHERE_ARE_YOU 33 135 117 136 /** IPv6 I-Am-Here. 137 */ 118 /** IPv6 I-Am-Here. */ 138 119 #define ICMP_IPV6_I_AM_HERE 34 139 120 140 /** Mobile Registration Request. 141 */ 121 /** Mobile Registration Request. */ 142 122 #define ICMP_MOBILE_REQUEST 35 143 123 144 /** Mobile Registration Reply. 145 */ 124 /** Mobile Registration Reply. */ 146 125 #define ICMP_MOBILE_REPLY 36 147 126 148 /** Domain name request. 149 */ 127 /** Domain name request. */ 150 128 #define ICMP_DN_REQUEST 37 151 129 152 /** Domain name reply. 153 */ 130 /** Domain name reply. */ 154 131 #define ICMP_DN_REPLY 38 155 132 156 /** SKIP. 157 */ 158 #define ICMP_SKIP 39 159 160 /** Photuris. 161 */ 133 /** SKIP. */ 134 #define ICMP_SKIP 39 135 136 /** Photuris. */ 162 137 #define ICMP_PHOTURIS 40 163 138 … … 168 143 /*@{*/ 169 144 170 /** Network Unreachable. 171 */ 145 /** Network Unreachable. */ 172 146 #define ICMP_NET_UNREACH 0 173 147 174 /** Host Unreachable. 175 */ 148 /** Host Unreachable. */ 176 149 #define ICMP_HOST_UNREACH 1 177 150 178 /** Protocol Unreachable. 179 */ 151 /** Protocol Unreachable. */ 180 152 #define ICMP_PROT_UNREACH 2 181 153 182 /** Port Unreachable. 183 */ 154 /** Port Unreachable. */ 184 155 #define ICMP_PORT_UNREACH 3 185 156 186 /** Fragmentation needed but the Do Not Fragment bit was set. 187 */ 157 /** Fragmentation needed but the Do Not Fragment bit was set. */ 188 158 #define ICMP_FRAG_NEEDED 4 189 159 190 /** Source Route failed. 191 */ 160 /** Source Route failed. */ 192 161 #define ICMP_SR_FAILED 5 193 162 194 /** Destination network unknown. 195 */ 163 /** Destination network unknown. */ 196 164 #define ICMP_NET_UNKNOWN 6 197 165 198 /** Destination host unknown. 199 */ 166 /** Destination host unknown. */ 200 167 #define ICMP_HOST_UNKNOWN 7 201 168 202 /** Source host isolated (obsolete). 203 */ 169 /** Source host isolated (obsolete). */ 204 170 #define ICMP_HOST_ISOLATED 8 205 171 206 /** Destination network administratively prohibited. 207 */ 172 /** Destination network administratively prohibited. */ 208 173 #define ICMP_NET_ANO 9 209 174 210 /** Destination host administratively prohibited. 211 */ 175 /** Destination host administratively prohibited. */ 212 176 #define ICMP_HOST_ANO 10 213 177 214 /** Network unreachable for this type of service. 215 */ 178 /** Network unreachable for this type of service. */ 216 179 #define ICMP_NET_UNR_TOS 11 217 180 218 /** Host unreachable for this type of service. 219 */ 181 /** Host unreachable for this type of service. */ 220 182 #define ICMP_HOST_UNR_TOS 12 221 183 222 /** Communication administratively prohibited by filtering. 223 */ 184 /** Communication administratively prohibited by filtering. */ 224 185 #define ICMP_PKT_FILTERED 13 225 186 226 /** Host precedence violation. 227 */ 187 /** Host precedence violation. */ 228 188 #define ICMP_PREC_VIOLATION 14 229 189 230 /** Precedence cutoff in effect. 231 */ 190 /** Precedence cutoff in effect. */ 232 191 #define ICMP_PREC_CUTOFF 15 233 192 234 193 /*@}*/ 235 194 236 /** @name ICMP_REDIRECT codes definitions 237 */ 238 /*@{*/ 239 240 /** Network redirect (or subnet). 241 */ 195 /** @name ICMP_REDIRECT codes definitions */ 196 /*@{*/ 197 198 /** Network redirect (or subnet). */ 242 199 #define ICMP_REDIR_NET 0 243 200 244 /** Host redirect. 245 */ 201 /** Host redirect. */ 246 202 #define ICMP_REDIR_HOST 1 247 203 248 /** Network redirect for this type of service. 249 */ 204 /** Network redirect for this type of service. */ 250 205 #define ICMP_REDIR_NETTOS 2 251 206 252 /** Host redirect for this type of service. 253 */ 207 /** Host redirect for this type of service. */ 254 208 #define ICMP_REDIR_HOSTTOS 3 255 209 256 210 /*@}*/ 257 211 258 /** @name ICMP_ALTERNATE_ADDRESS codes definitions 259 */ 260 /*@{*/ 261 262 /** Alternate address for host. 263 */ 212 /** @name ICMP_ALTERNATE_ADDRESS codes definitions */ 213 /*@{*/ 214 215 /** Alternate address for host. */ 264 216 #define ICMP_ALTERNATE_HOST 0 265 217 266 218 /*@}*/ 267 219 268 /** @name ICMP_ROUTER_ADV codes definitions 269 */ 270 /*@{*/ 271 272 /** Normal router advertisement. 273 */ 220 /** @name ICMP_ROUTER_ADV codes definitions */ 221 /*@{*/ 222 223 /** Normal router advertisement. */ 274 224 #define ICMP_ROUTER_NORMAL 0 275 225 276 /** Does not route common traffic. 277 */ 226 /** Does not route common traffic. */ 278 227 #define ICMP_ROUTER_NO_NORMAL_TRAFFIC 16 279 228 280 229 /*@}*/ 281 230 282 /** @name ICMP_TIME_EXCEEDED codes definitions 283 */ 284 /*@{*/ 285 286 /** Transit TTL exceeded. 287 */ 231 /** @name ICMP_TIME_EXCEEDED codes definitions */ 232 /*@{*/ 233 234 /** Transit TTL exceeded. */ 288 235 #define ICMP_EXC_TTL 0 289 236 290 /** Reassembly TTL exceeded. 291 */ 237 /** Reassembly TTL exceeded. */ 292 238 #define ICMP_EXC_FRAGTIME 1 293 239 294 240 /*@}*/ 295 241 296 /** @name ICMP_PARAMETERPROB codes definitions 297 */ 298 /*@{*/ 299 300 /** Pointer indicates the error. 301 */ 242 /** @name ICMP_PARAMETERPROB codes definitions */ 243 /*@{*/ 244 245 /** Pointer indicates the error. */ 302 246 #define ICMP_PARAM_POINTER 0 303 247 304 /** Missing required option. 305 */ 248 /** Missing required option. */ 306 249 #define ICMP_PARAM_MISSING 1 307 250 308 /** Bad length. 309 */ 251 /** Bad length. */ 310 252 #define ICMP_PARAM_LENGTH 2 311 253 312 254 /*@}*/ 313 255 314 /** @name ICMP_PHOTURIS codes definitions 315 */ 316 /*@{*/ 317 318 /** Bad SPI. 319 */ 320 #define ICMP_PHOTURIS_BAD_SPI 0 321 322 /** Authentication failed. 323 */ 324 #define ICMP_PHOTURIS_AUTHENTICATION 1 325 326 /** Decompression failed. 327 */ 256 /** @name ICMP_PHOTURIS codes definitions */ 257 /*@{*/ 258 259 /** Bad SPI. */ 260 #define ICMP_PHOTURIS_BAD_SPI 0 261 262 /** Authentication failed. */ 263 #define ICMP_PHOTURIS_AUTHENTICATION 1 264 265 /** Decompression failed. */ 328 266 #define ICMP_PHOTURIS_DECOMPRESSION 2 329 267 330 /** Decryption failed. 331 */ 332 #define ICMP_PHOTURIS_DECRYPTION 3 333 334 /** Need authentication. 335 */ 268 /** Decryption failed. */ 269 #define ICMP_PHOTURIS_DECRYPTION 3 270 271 /** Need authentication. */ 336 272 #define ICMP_PHOTURIS_NEED_AUTHENTICATION 4 337 273 338 /** Need authorization. 339 */ 274 /** Need authorization. */ 340 275 #define ICMP_PHOTURIS_NEED_AUTHORIZATION 5 341 276 -
uspace/lib/c/include/net/in.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef __NET_IN_H__38 #define __NET_IN_H__37 #ifndef LIBC_IN_H_ 38 #define LIBC_IN_H_ 39 39 40 #include <net/inet.h> 41 #include <net/ip_protocols.h> 40 42 #include <sys/types.h> 41 43 42 #include <ip_protocols.h> 43 #include <inet.h> 44 45 /** INET string address maximum length. 46 */ 44 /** INET string address maximum length. */ 47 45 #define INET_ADDRSTRLEN (4 * 3 + 3 + 1) 48 46 49 47 /** Type definition of the INET address. 50 * @see in_addr48 * @see in_addr 51 49 */ 52 50 typedef struct in_addr in_addr_t; 53 51 54 52 /** Type definition of the INET socket address. 55 * @see sockaddr_in53 * @see sockaddr_in 56 54 */ 57 55 typedef struct sockaddr_in sockaddr_in_t; 58 56 59 /** INET address. 60 */ 61 struct in_addr{ 62 /** 4 byte IP address. 63 */ 57 /** INET address. */ 58 struct in_addr { 59 /** 4 byte IP address. */ 64 60 uint32_t s_addr; 65 61 }; 66 62 67 63 /** INET socket address. 68 * @see sockaddr64 * @see sockaddr 69 65 */ 70 struct sockaddr_in{ 71 /** Address family. 72 * Should be AF_INET. 73 */ 66 struct sockaddr_in { 67 /** Address family. Should be AF_INET. */ 74 68 uint16_t sin_family; 75 /** Port number. 76 */ 69 /** Port number. */ 77 70 uint16_t sin_port; 78 /** Internet address. 79 */ 71 /** Internet address. */ 80 72 struct in_addr sin_addr; 81 /** Padding to meet the sockaddr size. 82 */ 73 /** Padding to meet the sockaddr size. */ 83 74 uint8_t sin_zero[8]; 84 75 }; -
uspace/lib/c/include/net/in6.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef __NET_IN6_H__38 #define __NET_IN6_H__37 #ifndef LIBC_IN6_H_ 38 #define LIBC_IN6_H_ 39 39 40 #include <net/inet.h> 41 #include <net/ip_protocols.h> 40 42 #include <sys/types.h> 41 43 42 #include <ip_protocols.h> 43 #include <inet.h> 44 45 /** INET6 string address maximum length. 46 */ 44 /** INET6 string address maximum length. */ 47 45 #define INET6_ADDRSTRLEN (8 * 4 + 7 + 1) 48 46 49 47 /** Type definition of the INET6 address. 50 * @see in6_addr48 * @see in6_addr 51 49 */ 52 50 typedef struct in6_addr in6_addr_t; 53 51 54 52 /** Type definition of the INET6 socket address. 55 * @see sockaddr_in653 * @see sockaddr_in6 56 54 */ 57 55 typedef struct sockaddr_in6 sockaddr_in6_t; 58 56 59 /** INET6 address. 60 */ 61 struct in6_addr{ 62 /** 16 byte IPv6 address. 63 */ 57 /** INET6 address. */ 58 struct in6_addr { 59 /** 16 byte IPv6 address. */ 64 60 unsigned char s6_addr[16]; 65 61 }; 66 62 67 63 /** INET6 socket address. 68 * @see sockaddr64 * @see sockaddr 69 65 */ 70 struct sockaddr_in6{ 71 /** Address family. 72 * Should be AF_INET6. 73 */ 66 struct sockaddr_in6 { 67 /** Address family. Should be AF_INET6. */ 74 68 uint16_t sin6_family; 75 /** Port number. 76 */ 69 /** Port number. */ 77 70 uint16_t sin6_port; 78 /** IPv6 flow information. 79 */ 71 /** IPv6 flow information. */ 80 72 uint32_t sin6_flowinfo; 81 /** IPv6 address. 82 */ 73 /** IPv6 address. */ 83 74 struct in6_addr sin6_addr; 84 /** Scope identifier. 85 */ 75 /** Scope identifier. */ 86 76 uint32_t sin6_scope_id; 87 77 }; -
uspace/lib/c/include/net/inet.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * I CMP module common interface.34 * Internet common definitions. 35 35 */ 36 36 37 #ifndef __NET_ICMP_COMMON_H__38 #define __NET_ICMP_COMMON_H__37 #ifndef LIBC_INET_H_ 38 #define LIBC_INET_H_ 39 39 40 #include <ipc/services.h> 40 #include <sys/types.h> 41 #include <byteorder.h> 41 42 42 #include <sys/time.h> 43 /** Type definition of the socket address. 44 * @see sockaddr 45 */ 46 typedef struct sockaddr sockaddr_t; 43 47 44 /** Default timeout for incoming connections in microseconds. 48 /** Type definition of the address information. 49 * @see addrinfo 45 50 */ 46 #define ICMP_CONNECT_TIMEOUT (1 * 1000 * 1000) 51 typedef struct addrinfo addrinfo_t; 47 52 48 /** Connects to the ICMP module. 49 * @param service The ICMP module service. Ignored parameter. 50 * @param[in] timeout The connection timeout in microseconds. No timeout if set to zero (0). 51 * @returns The ICMP module phone on success. 52 * @returns The ICMP socket identifier if called by the bundle module. 53 * @returns ETIMEOUT if the connection timeouted. 54 */ 55 extern int icmp_connect_module(services_t service, suseconds_t timeout); 53 /** Socket address. */ 54 struct sockaddr { 55 /** Address family. @see socket.h */ 56 uint16_t sa_family; 57 /** 14 byte protocol address. */ 58 uint8_t sa_data[14]; 59 }; 60 61 extern int inet_ntop(uint16_t, const uint8_t *, char *, size_t); 62 extern int inet_pton(uint16_t, const char *, uint8_t *); 56 63 57 64 #endif -
uspace/lib/c/include/net/packet_header.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Packet header.34 * Packet header. 35 35 */ 36 36 37 #ifndef __NET_PACKET_HEADER_H__38 #define __NET_PACKET_HEADER_H__37 #ifndef LIBC_PACKET_HEADER_H_ 38 #define LIBC_PACKET_HEADER_H_ 39 39 40 #include < packet/packet.h>40 #include <net/packet.h> 41 41 42 42 /** Returns the actual packet data length. 43 * @param[in] headerThe packet header.43 * @param[in] header The packet header. 44 44 */ 45 #define PACKET_DATA_LENGTH(header) ((header)->data_end - (header)->data_start) 45 #define PACKET_DATA_LENGTH(header) \ 46 ((header)->data_end - (header)->data_start) 46 47 47 48 /** Returns the maximum packet address length. 48 * @param[in] headerThe packet header.49 * @param[in] header The packet header. 49 50 */ 50 #define PACKET_MAX_ADDRESS_LENGTH(header) ((header)->dest_addr - (header)->src_addr) 51 #define PACKET_MAX_ADDRESS_LENGTH(header) \ 52 ((header)->dest_addr - (header)->src_addr) 51 53 52 54 /** Returns the minimum packet suffix. 53 * @param[in] header The packet header.55 * @param[in] header The packet header. 54 56 */ 55 #define PACKET_MIN_SUFFIX(header) ((header)->length - (header)->data_start - (header)->max_content) 57 #define PACKET_MIN_SUFFIX(header) \ 58 ((header)->length - (header)->data_start - (header)->max_content) 56 59 57 /** Packet integrity check magic value. 58 */ 60 /** Packet integrity check magic value. */ 59 61 #define PACKET_MAGIC_VALUE 0x11227788 60 62 61 /** Packet header. 62 */ 63 struct packet{ 64 /** Packet identifier. 65 */ 63 /** Packet header. */ 64 struct packet { 65 /** Packet identifier. */ 66 66 packet_id_t packet_id; 67 /** Packet queue sorting value. 68 * The packet queue is sorted the ascending order. 67 68 /** 69 * Packet queue sorting value. 70 * The packet queue is sorted the ascending order. 69 71 */ 70 72 size_t order; 71 /** Packet metric. 72 */73 74 /** Packet metric. */ 73 75 size_t metric; 74 /** Previous packet in the queue. 75 */ 76 /** Previous packet in the queue. */ 76 77 packet_id_t previous; 77 /** Next packet in the queue. 78 */ 78 /** Next packet in the queue. */ 79 79 packet_id_t next; 80 /** Total length of the packet. 81 * Contains the header, the addresses and the data of the packet. 82 * Corresponds to the mapped sharable memory block. 80 81 /** 82 * Total length of the packet. 83 * Contains the header, the addresses and the data of the packet. 84 * Corresponds to the mapped sharable memory block. 83 85 */ 84 86 size_t length; 85 /** Stored source and destination addresses length. 86 */87 88 /** Stored source and destination addresses length. */ 87 89 size_t addr_len; 88 /** Souce address offset in bytes from the beginning of the packet header. 90 91 /** 92 * Souce address offset in bytes from the beginning of the packet 93 * header. 89 94 */ 90 95 size_t src_addr; 91 /** Destination address offset in bytes from the beginning of the packet header. 96 97 /** 98 * Destination address offset in bytes from the beginning of the packet 99 * header. 92 100 */ 93 101 size_t dest_addr; 94 /** Reserved data prefix length in bytes. 95 */102 103 /** Reserved data prefix length in bytes. */ 96 104 size_t max_prefix; 97 /** Reserved content length in bytes. 98 */ 105 /** Reserved content length in bytes. */ 99 106 size_t max_content; 100 /** Actual data start offset in bytes from the beginning of the packet header. 107 108 /** 109 * Actual data start offset in bytes from the beginning of the packet 110 * header. 101 111 */ 102 112 size_t data_start; 103 /** Actual data end offset in bytes from the beginning of the packet header. 113 114 /** 115 * Actual data end offset in bytes from the beginning of the packet 116 * header. 104 117 */ 105 118 size_t data_end; 106 /** Integrity check magic value. 107 */119 120 /** Integrity check magic value. */ 108 121 int magic_value; 109 122 }; 110 123 111 124 /** Returns whether the packet is valid. 112 * @param[in] packet The packet to be checked. 113 * @returns true if the packet is not NULL and the magic value is correct. 114 * @returns false otherwise. 125 * @param[in] packet The packet to be checked. 126 * @return True if the packet is not NULL and the magic value is 127 * correct. 128 * @return False otherwise. 115 129 */ 116 static inline int packet_is_valid(const packet_t packet){ 130 static inline int packet_is_valid(const packet_t *packet) 131 { 117 132 return packet && (packet->magic_value == PACKET_MAGIC_VALUE); 118 133 } -
uspace/lib/c/include/stdio.h
r9a1d8ab r0b749a3 46 46 #define BUFSIZ 4096 47 47 48 #define DEBUG(fmt, ...) se\48 #define DEBUG(fmt, ...) \ 49 49 { \ 50 50 char _buf[256]; \ -
uspace/lib/c/include/sys/stat.h
r9a1d8ab r0b749a3 43 43 struct stat { 44 44 fs_handle_t fs_handle; 45 dev _handle_t dev_handle;45 devmap_handle_t devmap_handle; 46 46 fs_index_t index; 47 47 unsigned int lnkcnt; … … 49 49 bool is_directory; 50 50 aoff64_t size; 51 dev _handle_t device;51 devmap_handle_t device; 52 52 }; 53 53 -
uspace/lib/c/include/sys/time.h
r9a1d8ab r0b749a3 43 43 typedef long suseconds_t; 44 44 45 typedef uint32_t useconds_t; 46 typedef uint32_t mseconds_t; 47 45 48 struct timeval { 46 49 time_t tv_sec; /* seconds */ -
uspace/lib/c/include/task.h
r9a1d8ab r0b749a3 48 48 extern int task_set_name(const char *); 49 49 extern task_id_t task_spawn(const char *, const char *const[], int *); 50 extern int task_spawnv(task_id_t *, const char *path, const char *const []); 51 extern int task_spawnl(task_id_t *, const char *path, ...); 52 50 53 extern int task_wait(task_id_t id, task_exit_t *, int *); 51 54 extern int task_retval(int); -
uspace/lib/c/include/unistd.h
r9a1d8ab r0b749a3 37 37 38 38 #include <sys/types.h> 39 #include <time.h> 39 40 #include <libarch/config.h> 40 41 41 42 #ifndef NULL 42 #define NULL 043 #define NULL ((void *) 0) 43 44 #endif 44 45 … … 56 57 #define SEEK_END 2 57 58 #endif 58 59 typedef uint32_t useconds_t;60 59 61 60 extern int dup2(int oldfd, int newfd); -
uspace/lib/c/include/vfs/vfs.h
r9a1d8ab r0b749a3 47 47 typedef struct { 48 48 fs_handle_t fs_handle; 49 dev _handle_t dev_handle;49 devmap_handle_t devmap_handle; 50 50 fs_index_t index; 51 51 } fdi_node_t; -
uspace/lib/drv/Makefile
r9a1d8ab r0b749a3 28 28 # 29 29 30 USPACE_PREFIX = ../../.. 31 LIBS = $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a 32 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include 33 34 BINARY = netstart 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude -I$(LIBUSB_PREFIX)/include 32 LIBRARY = libdrv 35 33 36 34 SOURCES = \ 37 netstart.c \ 38 self_test.c 35 generic/driver.c \ 36 generic/dev_iface.c \ 37 generic/remote_res.c \ 38 generic/remote_usbhc.c \ 39 generic/remote_char.c 39 40 40 41 include $(USPACE_PREFIX)/Makefile.common -
uspace/lib/fs/libfs.c
r9a1d8ab r0b749a3 150 150 ipc_call_t *request) 151 151 { 152 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);152 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 153 153 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 154 154 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); 155 dev _handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request);155 devmap_handle_t mr_devmap_handle = (devmap_handle_t) IPC_GET_ARG4(*request); 156 156 int res; 157 157 ipcarg_t rc; … … 174 174 175 175 fs_node_t *fn; 176 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);176 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 177 177 if ((res != EOK) || (!fn)) { 178 178 ipc_hangup(mountee_phone); … … 201 201 ipc_call_t answer; 202 202 rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED, 203 mr_dev _handle, &answer);203 mr_devmap_handle, &answer); 204 204 205 205 if (rc == EOK) { 206 206 fn->mp_data.mp_active = true; 207 207 fn->mp_data.fs_handle = mr_fs_handle; 208 fn->mp_data.dev _handle = mr_dev_handle;208 fn->mp_data.devmap_handle = mr_devmap_handle; 209 209 fn->mp_data.phone = mountee_phone; 210 210 } … … 219 219 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request) 220 220 { 221 dev _handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);221 devmap_handle_t mp_devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 222 222 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request); 223 223 fs_node_t *fn; 224 224 int res; 225 225 226 res = ops->node_get(&fn, mp_dev _handle, mp_fs_index);226 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 227 227 if ((res != EOK) || (!fn)) { 228 228 ipc_answer_0(rid, combine_rc(res, ENOENT)); … … 243 243 */ 244 244 res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED, 245 fn->mp_data.dev _handle);245 fn->mp_data.devmap_handle); 246 246 247 247 /* … … 252 252 fn->mp_data.mp_active = false; 253 253 fn->mp_data.fs_handle = 0; 254 fn->mp_data.dev _handle = 0;254 fn->mp_data.devmap_handle = 0; 255 255 fn->mp_data.phone = 0; 256 256 /* Drop the reference created in libfs_mount(). */ … … 281 281 unsigned int last = IPC_GET_ARG2(*request); 282 282 unsigned int next = first; 283 dev _handle_t dev_handle = IPC_GET_ARG3(*request);283 devmap_handle_t devmap_handle = IPC_GET_ARG3(*request); 284 284 int lflag = IPC_GET_ARG4(*request); 285 285 fs_index_t index = IPC_GET_ARG5(*request); … … 295 295 fs_node_t *tmp = NULL; 296 296 297 rc = ops->root_get(&cur, dev _handle);297 rc = ops->root_get(&cur, devmap_handle); 298 298 on_error(rc, goto out_with_answer); 299 299 300 300 if (cur->mp_data.mp_active) { 301 301 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP, 302 next, last, cur->mp_data.dev _handle, lflag, index,302 next, last, cur->mp_data.devmap_handle, lflag, index, 303 303 IPC_FF_ROUTE_FROM_ME); 304 304 (void) ops->node_put(cur); … … 358 358 359 359 ipc_forward_slow(rid, tmp->mp_data.phone, 360 VFS_OUT_LOOKUP, next, last, tmp->mp_data.dev _handle,360 VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle, 361 361 lflag, index, IPC_FF_ROUTE_FROM_ME); 362 362 (void) ops->node_put(cur); … … 385 385 fs_node_t *fn; 386 386 if (lflag & L_CREATE) 387 rc = ops->create(&fn, dev _handle,387 rc = ops->create(&fn, devmap_handle, 388 388 lflag); 389 389 else 390 rc = ops->node_get(&fn, dev _handle,390 rc = ops->node_get(&fn, devmap_handle, 391 391 index); 392 392 on_error(rc, goto out_with_answer); … … 401 401 aoff64_t size = ops->size_get(fn); 402 402 ipc_answer_5(rid, fs_handle, 403 dev _handle,403 devmap_handle, 404 404 ops->index_get(fn), 405 405 LOWER32(size), … … 469 469 fs_node_t *fn; 470 470 if (lflag & L_CREATE) 471 rc = ops->create(&fn, dev _handle, lflag);471 rc = ops->create(&fn, devmap_handle, lflag); 472 472 else 473 rc = ops->node_get(&fn, dev _handle, index);473 rc = ops->node_get(&fn, devmap_handle, index); 474 474 on_error(rc, goto out_with_answer); 475 475 … … 483 483 aoff64_t size = ops->size_get(fn); 484 484 ipc_answer_5(rid, fs_handle, 485 dev _handle,485 devmap_handle, 486 486 ops->index_get(fn), 487 487 LOWER32(size), … … 509 509 if (rc == EOK) { 510 510 aoff64_t size = ops->size_get(cur); 511 ipc_answer_5(rid, fs_handle, dev _handle,511 ipc_answer_5(rid, fs_handle, devmap_handle, 512 512 ops->index_get(cur), LOWER32(size), UPPER32(size), 513 513 old_lnkcnt); … … 547 547 if (rc == EOK) { 548 548 aoff64_t size = ops->size_get(cur); 549 ipc_answer_5(rid, fs_handle, dev _handle,549 ipc_answer_5(rid, fs_handle, devmap_handle, 550 550 ops->index_get(cur), LOWER32(size), UPPER32(size), 551 551 ops->lnkcnt_get(cur)); … … 571 571 ipc_call_t *request) 572 572 { 573 dev _handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);573 devmap_handle_t devmap_handle = (devmap_handle_t) IPC_GET_ARG1(*request); 574 574 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 575 575 576 576 fs_node_t *fn; 577 int rc = ops->node_get(&fn, dev _handle, index);577 int rc = ops->node_get(&fn, devmap_handle, index); 578 578 on_error(rc, answer_and_return(rid, rc)); 579 579 … … 592 592 593 593 stat.fs_handle = fs_handle; 594 stat.dev _handle = dev_handle;594 stat.devmap_handle = devmap_handle; 595 595 stat.index = index; 596 596 stat.lnkcnt = ops->lnkcnt_get(fn); … … 617 617 ipc_call_t *request) 618 618 { 619 dev _handle_t dev_handle = IPC_GET_ARG1(*request);619 devmap_handle_t devmap_handle = IPC_GET_ARG1(*request); 620 620 fs_index_t index = IPC_GET_ARG2(*request); 621 621 622 622 fs_node_t *fn; 623 int rc = ops->node_get(&fn, dev _handle, index);623 int rc = ops->node_get(&fn, devmap_handle, index); 624 624 on_error(rc, answer_and_return(rid, rc)); 625 625 -
uspace/lib/fs/libfs.h
r9a1d8ab r0b749a3 47 47 int phone; 48 48 fs_handle_t fs_handle; 49 dev _handle_t dev_handle;49 devmap_handle_t devmap_handle; 50 50 } mp_data_t; 51 51 … … 61 61 * argument holds the output argument. 62 62 */ 63 int (* root_get)(fs_node_t **, dev _handle_t);63 int (* root_get)(fs_node_t **, devmap_handle_t); 64 64 int (* match)(fs_node_t **, fs_node_t *, const char *); 65 int (* node_get)(fs_node_t **, dev _handle_t, fs_index_t);65 int (* node_get)(fs_node_t **, devmap_handle_t, fs_index_t); 66 66 int (* node_open)(fs_node_t *); 67 67 int (* node_put)(fs_node_t *); 68 int (* create)(fs_node_t **, dev _handle_t, int);68 int (* create)(fs_node_t **, devmap_handle_t, int); 69 69 int (* destroy)(fs_node_t *); 70 70 int (* link)(fs_node_t *, fs_node_t *, const char *); … … 81 81 bool (* is_directory)(fs_node_t *); 82 82 bool (* is_file)(fs_node_t *); 83 dev _handle_t (* device_get)(fs_node_t *);83 devmap_handle_t (* device_get)(fs_node_t *); 84 84 } libfs_ops_t; 85 85 -
uspace/lib/net/Makefile
r9a1d8ab r0b749a3 29 29 30 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude -I$(LIBSOCKET_PREFIX)/include31 EXTRA_CFLAGS = -Iinclude 32 32 LIBRARY = libnet 33 33 34 34 SOURCES = \ 35 generic/generic.c \ 35 36 generic/net_remote.c \ 36 37 generic/net_checksum.c \ 38 generic/packet_client.c \ 37 39 generic/packet_remote.c \ 40 generic/protocol_map.c \ 38 41 adt/module_map.c \ 39 42 netif/netif_local.c \ 40 43 netif/netif_remote.c \ 41 netif/netif_nil_bundle.c \42 44 nil/nil_remote.c \ 45 il/il_interface.c \ 43 46 il/ip_remote.c \ 44 47 il/ip_client.c \ … … 46 49 tl/icmp_remote.c \ 47 50 tl/icmp_client.c \ 51 tl/socket_core.c \ 52 tl/tl_interface.c \ 48 53 tl/tl_common.c 49 54 -
uspace/lib/net/adt/module_map.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Character string to module map implementation.34 * Character string to module map implementation. 35 35 */ 36 36 … … 38 38 #include <task.h> 39 39 #include <unistd.h> 40 #include <errno.h> 40 41 41 42 #include <ipc/services.h> 42 43 43 #include <net_err.h> 44 #include <net_modules.h> 44 #include <net/modules.h> 45 45 46 46 #include <adt/generic_char_map.h> … … 49 49 GENERIC_CHAR_MAP_IMPLEMENT(modules, module_t) 50 50 51 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t connect_module){ 52 ERROR_DECLARE; 51 /** Adds module to the module map. 52 * 53 * @param[out] module The module structure added. 54 * @param[in] modules The module map. 55 * @param[in] name The module name. 56 * @param[in] filename The full path filename. 57 * @param[in] service The module service. 58 * @param[in] task_id The module current task identifier. Zero means not 59 * running. 60 * @param[in] connect_module The module connecting function. 61 * @return EOK on success. 62 * @return ENOMEM if there is not enough memory left. 63 */ 64 int 65 add_module(module_t **module, modules_t *modules, const char *name, 66 const char *filename, services_t service, task_id_t task_id, 67 connect_module_t connect_module) 68 { 69 module_t *tmp_module; 70 int rc; 53 71 54 module_ref tmp_module; 72 tmp_module = (module_t *) malloc(sizeof(module_t)); 73 if (!tmp_module) 74 return ENOMEM; 55 75 56 tmp_module = (module_ref) malloc(sizeof(module_t));57 if(! tmp_module){58 return ENOMEM;59 }60 76 tmp_module->task_id = task_id; 61 77 tmp_module->phone = 0; … … 65 81 tmp_module->service = service; 66 82 tmp_module->connect_module = connect_module; 67 if(ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0, tmp_module))){ 83 84 rc = modules_add(modules, tmp_module->name, 0, tmp_module); 85 if (rc != EOK) { 68 86 free(tmp_module); 69 return ERROR_CODE;87 return rc; 70 88 } 71 if (module){89 if (module) 72 90 *module = tmp_module; 73 } 91 74 92 return EOK; 75 93 } 76 94 77 module_ref get_running_module(modules_ref modules, char * name){ 78 module_ref module; 95 /** Searches and returns the specified module. 96 * 97 * If the module is not running, the module filaname is spawned. 98 * If the module is not connected, the connect_function is called. 99 * 100 * @param[in] modules The module map. 101 * @param[in] name The module name. 102 * @return The running module found. It does not have to be 103 * connected. 104 * @return NULL if there is no such module. 105 */ 106 module_t *get_running_module(modules_t *modules, char *name) 107 { 108 module_t *module; 79 109 80 110 module = modules_find(modules, name, 0); 81 if (! module){111 if (!module) 82 112 return NULL; 113 114 if (!module->task_id) { 115 module->task_id = spawn(module->filename); 116 if (!module->task_id) 117 return NULL; 83 118 } 84 if(! module->task_id){ 85 module->task_id = spawn(module->filename); 86 if(! module->task_id){ 87 return NULL; 88 } 89 } 90 if(! module->phone){ 119 if (!module->phone) 91 120 module->phone = module->connect_module(module->service); 92 } 121 93 122 return module; 94 123 } 95 124 125 /** Starts the given module. 126 * 127 * @param[in] fname The module full or relative path filename. 128 * @return The new module task identifier on success. 129 * @return Zero if there is no such module. 130 */ 96 131 task_id_t spawn(const char *fname) 97 132 { 98 const char *argv[2];99 task_id_t res;133 task_id_t id; 134 int rc; 100 135 101 argv[0] = fname;102 argv[1] = NULL;103 res = task_spawn(fname, argv, NULL);136 rc = task_spawnl(&id, fname, fname, NULL); 137 if (rc != EOK) 138 return 0; 104 139 105 return res;140 return id; 106 141 } 107 142 -
uspace/lib/net/generic/net_checksum.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * General CRC and checksum computation implementation.34 * General CRC and checksum computation implementation. 35 35 */ 36 36 … … 39 39 #include <net_checksum.h> 40 40 41 /** Big-endian encoding CRC divider. 42 */ 43 #define CRC_DIVIDER_BE 0x04C11DB7 44 45 /** Little-endian encoding CRC divider. 46 */ 47 #define CRC_DIVIDER_LE 0xEDB88320 48 49 uint16_t compact_checksum(uint32_t sum){ 41 /** Big-endian encoding CRC divider. */ 42 #define CRC_DIVIDER_BE 0x04c11db7 43 44 /** Little-endian encoding CRC divider. */ 45 #define CRC_DIVIDER_LE 0xedb88320 46 47 /** Compacts the computed checksum to the 16 bit number adding the carries. 48 * 49 * @param[in] sum Computed checksum. 50 * @return Compacted computed checksum to the 16 bits. 51 */ 52 uint16_t compact_checksum(uint32_t sum) 53 { 50 54 // shorten to the 16 bits 51 while(sum >> 16){ 52 sum = (sum &0xFFFF) + (sum >> 16); 53 } 55 while (sum >> 16) 56 sum = (sum & 0xffff) + (sum >> 16); 54 57 55 58 return (uint16_t) sum; 56 59 } 57 60 58 uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length){ 61 /** Computes sum of the 2 byte fields. 62 * 63 * Padds one zero (0) byte if odd. 64 * 65 * @param[in] seed Initial value. Often used as 0 or ~0. 66 * @param[in] data Pointer to the beginning of data to process. 67 * @param[in] length Length of the data in bytes. 68 * @return The computed checksum of the length bytes of the data. 69 */ 70 uint32_t compute_checksum(uint32_t seed, uint8_t *data, size_t length) 71 { 59 72 size_t index; 60 73 61 74 // sum all the 16 bit fields 62 for (index = 0; index + 1 < length; index += 2){75 for (index = 0; index + 1 < length; index += 2) 63 76 seed += (data[index] << 8) + data[index + 1]; 64 }65 77 66 78 // last odd byte with zero padding 67 if (index + 1 == length){79 if (index + 1 == length) 68 80 seed += data[index] << 8; 69 }70 81 71 82 return seed; 72 83 } 73 84 74 uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length){ 85 /** Computes CRC32 value in the big-endian environment. 86 * 87 * @param[in] seed Initial value. Often used as 0 or ~0. 88 * @param[in] data Pointer to the beginning of data to process. 89 * @param[in] length Length of the data in bits. 90 * @return The computed CRC32 of the length bits of the data. 91 */ 92 uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length) 93 { 75 94 size_t index; 76 95 77 96 // process full bytes 78 while (length >= 8){97 while (length >= 8) { 79 98 // add the data 80 99 seed ^= (*data) << 24; 100 81 101 // for each added bit 82 for (index = 0; index < 8; ++ index){102 for (index = 0; index < 8; ++index) { 83 103 // if the first bit is set 84 if (seed &0x80000000){104 if (seed & 0x80000000) { 85 105 // shift and divide the checksum 86 106 seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE); 87 } else{107 } else { 88 108 // shift otherwise 89 109 seed <<= 1; 90 110 } 91 111 } 112 92 113 // move to the next byte 93 ++ data;114 ++data; 94 115 length -= 8; 95 116 } 96 117 97 118 // process the odd bits 98 if (length > 0){119 if (length > 0) { 99 120 // add the data with zero padding 100 seed ^= ((*data) &(0xFF << (8 - length))) << 24; 121 seed ^= ((*data) & (0xff << (8 - length))) << 24; 122 101 123 // for each added bit 102 for (index = 0; index < length; ++ index){124 for (index = 0; index < length; ++index) { 103 125 // if the first bit is set 104 if (seed &0x80000000){126 if (seed & 0x80000000) { 105 127 // shift and divide the checksum 106 128 seed = (seed << 1) ^ ((uint32_t) CRC_DIVIDER_BE); 107 } else{129 } else { 108 130 // shift otherwise 109 131 seed <<= 1; … … 115 137 } 116 138 117 uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length){ 139 /** Computes CRC32 value in the little-endian environment. 140 * 141 * @param[in] seed Initial value. Often used as 0 or ~0. 142 * @param[in] data Pointer to the beginning of data to process. 143 * @param[in] length Length of the data in bits. 144 * @return The computed CRC32 of the length bits of the data. 145 */ 146 uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length) 147 { 118 148 size_t index; 119 149 120 150 // process full bytes 121 while (length >= 8){151 while (length >= 8) { 122 152 // add the data 123 153 seed ^= (*data); 154 124 155 // for each added bit 125 for (index = 0; index < 8; ++ index){156 for (index = 0; index < 8; ++index) { 126 157 // if the last bit is set 127 if (seed &1){158 if (seed & 1) { 128 159 // shift and divide the checksum 129 160 seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE); 130 } else{161 } else { 131 162 // shift otherwise 132 163 seed >>= 1; 133 164 } 134 165 } 166 135 167 // move to the next byte 136 ++ data;168 ++data; 137 169 length -= 8; 138 170 } 139 171 140 172 // process the odd bits 141 if (length > 0){173 if (length > 0) { 142 174 // add the data with zero padding 143 175 seed ^= (*data) >> (8 - length); 144 for(index = 0; index < length; ++ index){ 176 177 for (index = 0; index < length; ++index) { 145 178 // if the last bit is set 146 if (seed &1){179 if (seed & 1) { 147 180 // shift and divide the checksum 148 181 seed = (seed >> 1) ^ ((uint32_t) CRC_DIVIDER_LE); 149 } else{182 } else { 150 183 // shift otherwise 151 184 seed >>= 1; … … 157 190 } 158 191 159 uint16_t flip_checksum(uint16_t checksum){ 192 /** Returns or flips the checksum if zero. 193 * 194 * @param[in] checksum The computed checksum. 195 * @return The internet protocol header checksum. 196 * @return 0xFFFF if the computed checksum is zero. 197 */ 198 uint16_t flip_checksum(uint16_t checksum) 199 { 160 200 // flip, zero is returned as 0xFFFF (not flipped) 161 checksum = ~ checksum;201 checksum = ~checksum; 162 202 return checksum ? checksum : IP_CHECKSUM_ZERO; 163 203 } 164 204 165 uint16_t ip_checksum(uint8_t * data, size_t length){ 205 /** Computes the ip header checksum. 206 * 207 * To compute the checksum of a new packet, the checksum header field must be 208 * zero. To check the checksum of a received packet, the checksum may be left 209 * set. Zero will be returned in this case if valid. 210 * 211 * @param[in] data The header data. 212 * @param[in] length The header length in bytes. 213 * @return The internet protocol header checksum. 214 * @return 0xFFFF if the computed checksum is zero. 215 */ 216 uint16_t ip_checksum(uint8_t *data, size_t length) 217 { 166 218 // compute, compact and flip the data checksum 167 return flip_checksum(compact_checksum(compute_checksum(0, data, length))); 219 return flip_checksum(compact_checksum(compute_checksum(0, data, 220 length))); 168 221 } 169 222 -
uspace/lib/net/generic/net_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Networking interface implementation for remote modules.35 * @see net_interface.h34 * Networking interface implementation for remote modules. 35 * @see net_interface.h 36 36 */ 37 37 38 38 #include <ipc/services.h> 39 #include <ipc/net_net.h> 39 40 40 41 #include <malloc.h> 41 42 42 #include < net_messages.h>43 #include <net _modules.h>44 #include <net _device.h>43 #include <generic.h> 44 #include <net/modules.h> 45 #include <net/device.h> 45 46 #include <net_interface.h> 46 47 #include <adt/measured_strings.h> 47 #include <net_net_messages.h>48 48 49 int net_connect_module(services_t service){ 49 /** Connects to the networking module. 50 * 51 * @return The networking module phone on success. 52 */ 53 int net_connect_module(void) 54 { 50 55 return connect_to_service(SERVICE_NETWORKING); 51 56 } 52 57 53 void net_free_settings(measured_string_ref settings, char * data){ 54 if(settings){ 58 /** Frees the received settings. 59 * 60 * @param[in] settings The received settings. 61 * @param[in] data The received settings data. 62 * @see net_get_device_conf_req() 63 * @see net_get_conf_req() 64 */ 65 void net_free_settings(measured_string_t *settings, char *data) 66 { 67 if (settings) 55 68 free(settings); 56 } 57 if(data){ 69 if (data) 58 70 free(data); 59 }60 71 } 61 72 62 int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data){ 63 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, * configuration, count, configuration, data); 73 /** Returns the global configuration. 74 * 75 * The configuration names are read and the appropriate settings are set 76 * instead. Call net_free_settings() function to release the returned 77 * configuration. 78 * 79 * @param[in] net_phone The networking module phone. 80 * @param[in,out] configuration The requested configuration. The names are read 81 * and the appropriate settings are set instead. 82 * 83 * @param[in] count The configuration entries count. 84 * @param[in,out] data The configuration and settings data. 85 * @return EOK on success. 86 * @return EINVAL if the configuration is NULL. 87 * @return EINVAL if the count is zero. 88 * @return Other error codes as defined for the 89 * generic_translate_req() function. 90 */ 91 int 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 93 size_t count, char **data) 94 { 95 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, 96 *configuration, count, configuration, data); 64 97 } 65 98 66 int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data){ 67 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, device_id, 0, * configuration, count, configuration, data); 99 /** Returns the device specific configuration. 100 * 101 * Returns the global configuration if the device specific is not found. 102 * The configuration names are read and the appropriate settings are set 103 * instead. Call net_free_settings() function to release the returned 104 * configuration. 105 * 106 * @param[in] net_phone The networking module phone. 107 * @param[in] device_id The device identifier. 108 * @param[in,out] configuration The requested device configuration. The names 109 * are read and the appropriate settings are set instead. 110 * @param[in] count The configuration entries count. 111 * @param[in,out] data The configuration and settings data. 112 * @return EOK on success. 113 * @return EINVAL if the configuration is NULL. 114 * @return EINVAL if the count is zero. 115 * @return Other error codes as defined for the 116 * generic_translate_req() function. 117 */ 118 int 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 120 measured_string_t **configuration, size_t count, char **data) 121 { 122 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 123 device_id, 0, *configuration, count, configuration, data); 68 124 } 69 125 -
uspace/lib/net/generic/packet_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Packet client interface implementation for remote modules.35 * @see packet_client.h34 * Packet client interface implementation for remote modules. 35 * @see packet_client.h 36 36 */ 37 37 … … 39 39 #include <errno.h> 40 40 #include <ipc/ipc.h> 41 #include <ipc/packet.h> 41 42 #include <sys/mman.h> 42 43 43 #include <net_err.h> 44 #include <net_messages.h> 45 #include <packet/packet.h> 46 #include <packet/packet_client.h> 47 #include <packet/packet_header.h> 48 #include <packet/packet_messages.h> 44 #include <packet_client.h> 49 45 #include <packet_remote.h> 46 47 #include <net/packet.h> 48 #include <net/packet_header.h> 50 49 51 50 /** Obtain the packet from the packet server as the shared memory block. … … 64 63 * 65 64 */ 66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){67 ERROR_DECLARE; 68 65 static int 66 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size) 67 { 69 68 ipc_call_t answer; 70 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 71 *packet = (packet_t) as_get_mappable_page(size); 72 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) 73 || ERROR_OCCURRED(pm_add(*packet))) { 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 74 *packet = (packet_t *) as_get_mappable_page(size); 75 rc = async_share_in_start_0_0(phone, *packet, size); 76 if (rc != EOK) { 74 77 munmap(*packet, size); 75 78 async_wait_for(message, NULL); 76 return ERROR_CODE; 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 77 86 } 78 87 … … 83 92 } 84 93 85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 86 { 87 ERROR_DECLARE; 94 /** Translates the packet identifier to the packet reference. 95 * 96 * Tries to find mapping first. 97 * Contacts the packet server to share the packet if the mapping is not present. 98 * 99 * @param[in] phone The packet server module phone. 100 * @param[out] packet The packet reference. 101 * @param[in] packet_id The packet identifier. 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 */ 109 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id) 110 { 111 int rc; 88 112 89 113 if (!packet) … … 91 115 92 116 *packet = pm_find(packet_id); 93 if (! (*packet)) {117 if (!*packet) { 94 118 ipcarg_t size; 95 119 96 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size)); 97 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 98 } 99 if ((** packet).next) { 100 packet_t next; 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 127 } 128 if ((*packet)->next) { 129 packet_t *next; 101 130 102 return packet_translate_remote(phone, &next, (* * packet).next);131 return packet_translate_remote(phone, &next, (*packet)->next); 103 132 } 104 133 … … 106 135 } 107 136 108 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 137 /** Obtains the packet of the given dimensions. 138 * 139 * Contacts the packet server to return the appropriate packet. 140 * 141 * @param[in] phone The packet server module phone. 142 * @param[in] addr_len The source and destination addresses maximal length in 143 * bytes. 144 * @param[in] max_prefix The maximal prefix length in bytes. 145 * @param[in] max_content The maximal content length in bytes. 146 * @param[in] max_suffix The maximal suffix length in bytes. 147 * @return The packet reference. 148 * @return NULL on error. 149 */ 150 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 109 151 size_t max_prefix, size_t max_suffix) 110 152 { 111 ERROR_DECLARE;112 113 153 ipcarg_t packet_id; 114 154 ipcarg_t size; 115 116 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, 117 addr_len, max_prefix, max_suffix, &packet_id, &size))) 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 118 160 return NULL; 119 161 120 162 121 packet_t packet = pm_find(packet_id);163 packet_t *packet = pm_find(packet_id); 122 164 if (!packet) { 123 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 165 rc = packet_return(phone, &packet, packet_id, size); 166 if (rc != EOK) 124 167 return NULL; 125 168 } … … 128 171 } 129 172 130 packet_t packet_get_1_remote(int phone, size_t content) 131 { 132 ERROR_DECLARE; 133 173 /** Obtains the packet of the given content size. 174 * 175 * Contacts the packet server to return the appropriate packet. 176 * 177 * @param[in] phone The packet server module phone. 178 * @param[in] content The maximal content length in bytes. 179 * @return The packet reference. 180 * @return NULL on error. 181 */ 182 packet_t *packet_get_1_remote(int phone, size_t content) 183 { 134 184 ipcarg_t packet_id; 135 185 ipcarg_t size; 136 137 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 138 &packet_id, &size))) 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 139 191 return NULL; 140 192 141 packet_t packet = pm_find(packet_id);193 packet_t *packet = pm_find(packet_id); 142 194 if (!packet) { 143 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 195 rc = packet_return(phone, &packet, packet_id, size); 196 if (rc != EOK) 144 197 return NULL; 145 198 } … … 148 201 } 149 202 203 /** Releases the packet queue. 204 * 205 * All packets in the queue are marked as free for use. 206 * The packet queue may be one packet only. 207 * The module should not use the packets after this point until they are 208 * received or obtained again. 209 * 210 * @param[in] phone The packet server module phone. 211 * @param[in] packet_id The packet identifier. 212 */ 150 213 void pq_release_remote(int phone, packet_id_t packet_id) 151 214 { -
uspace/lib/net/il/arp_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup arp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ARP interface implementation for remote modules.35 * @see arp_interface.h34 * ARP interface implementation for remote modules. 35 * @see arp_interface.h 36 36 */ 37 38 #include <arp_interface.h> 39 #include <generic.h> 37 40 38 41 #include <async.h> … … 40 43 #include <ipc/ipc.h> 41 44 #include <ipc/services.h> 45 #include <ipc/arp.h> 42 46 43 #include <net_messages.h> 44 #include <net_modules.h> 45 #include <net_device.h> 46 #include <arp_interface.h> 47 #include <net/modules.h> 48 #include <net/device.h> 47 49 #include <adt/measured_strings.h> 48 #include <arp_messages.h>49 50 50 int arp_connect_module(services_t service){ 51 if(service != SERVICE_ARP){ 51 /** Connects to the ARP module. 52 * 53 * @param service The ARP module service. Ignored parameter. 54 * @return The ARP module phone on success. 55 */ 56 int arp_connect_module(services_t service) 57 { 58 if (service != SERVICE_ARP) 52 59 return EINVAL; 53 } 60 54 61 return connect_to_service(SERVICE_ARP); 55 62 } 56 63 57 int arp_clean_cache_req(int arp_phone){ 64 /** Cleans the cache. 65 * 66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 67 * @return EOK on success. 68 */ 69 int arp_clean_cache_req(int arp_phone) 70 { 58 71 return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE); 59 72 } 60 73 61 int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){ 74 /** Clears the given protocol address from the cache. 75 * 76 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 77 * @param[in] device_id The device identifier. 78 * @param[in] protocol The requesting protocol service. 79 * @param[in] address The protocol address to be cleared. 80 * @return EOK on success. 81 * @return ENOENT if the mapping is not found. 82 */ 83 int 84 arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, 85 measured_string_t *address) 86 { 62 87 aid_t message_id; 63 88 ipcarg_t result; 64 89 65 message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, (ipcarg_t) device_id, protocol, NULL); 90 message_id = async_send_2(arp_phone, NET_ARP_CLEAR_ADDRESS, 91 (ipcarg_t) device_id, protocol, NULL); 66 92 measured_strings_send(arp_phone, address, 1); 67 93 async_wait_for(message_id, &result); 94 68 95 return (int) result; 69 96 } 70 97 71 int arp_clear_device_req(int arp_phone, device_id_t device_id){ 72 return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id); 98 /** Clears the device cache. 99 * 100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 101 * @param[in] device_id The device identifier. 102 * @return EOK on success. 103 * @return ENOENT if the device is not found. 104 */ 105 int arp_clear_device_req(int arp_phone, device_id_t device_id) 106 { 107 return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, 108 (ipcarg_t) device_id); 73 109 } 74 110 75 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){ 111 /** Registers the new device and the requesting protocol service. 112 * 113 * Connects to the network interface layer service. 114 * Determines the device broadcast address, its address lengths and packet size. 115 * 116 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 117 * @param[in] device_id The new device identifier. 118 * @param[in] protocol The requesting protocol service. 119 * @param[in] netif The underlying device network interface layer service. 120 * @param[in] address The local requesting protocol address of the device. 121 * @return EOK on success. 122 * @return EEXIST if the device is already used. 123 * @return ENOMEM if there is not enough memory left. 124 * @return ENOENT if the network interface service is not known. 125 * @return EREFUSED if the network interface service is not 126 * responding. 127 * @return Other error codes as defined for the 128 * nil_packet_get_size() function. 129 * @return Other error codes as defined for the nil_get_addr() 130 * function. 131 * @return Other error codes as defined for the 132 * nil_get_broadcast_addr() function. 133 */ 134 int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, 135 services_t netif, measured_string_t *address) 136 { 76 137 aid_t message_id; 77 138 ipcarg_t result; 78 139 79 message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL); 140 message_id = async_send_3(arp_phone, NET_ARP_DEVICE, 141 (ipcarg_t) device_id, protocol, netif, NULL); 80 142 measured_strings_send(arp_phone, address, 1); 81 143 async_wait_for(message_id, &result); 144 82 145 return (int) result; 83 146 } 84 147 85 task_id_t arp_task_get_id(void){ 86 return 0; 87 } 88 89 int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){ 90 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data); 148 /** Translates the given protocol address to the network interface address. 149 * 150 * Broadcasts the ARP request if the mapping is not found. 151 * Allocates and returns the needed memory block as the data parameter. 152 * 153 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 154 * @param[in] device_id The device identifier. 155 * @param[in] protocol The requesting protocol service. 156 * @param[in] address The local requesting protocol address. 157 * @param[out] translation The translation of the local protocol address. 158 * @param[out] data The allocated raw translation data container. 159 * @return EOK on success. 160 * @return EINVAL if the address parameter is NULL. 161 * @return EBADMEM if the translation or the data parameters are 162 * NULL. 163 * @return ENOENT if the mapping is not found. 164 */ 165 int 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, char **data) 168 { 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, 170 protocol, address, 1, translation, data); 91 171 } 92 172 -
uspace/lib/net/il/ip_client.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * IP client interface implementation.35 * @see ip_client.h34 * IP client interface implementation. 35 * @see ip_client.h 36 36 */ 37 37 … … 40 40 41 41 #include <ip_client.h> 42 #include <socket_errno.h> 43 #include <packet/packet.h> 44 #include <packet/packet_client.h> 42 #include <packet_client.h> 45 43 #include <ip_header.h> 46 44 47 size_t ip_client_header_length(packet_t packet){ 48 ip_header_ref header; 49 50 header = (ip_header_ref) packet_get_data(packet); 51 if((! header) 52 || (packet_get_data_length(packet) < sizeof(ip_header_t))){ 45 #include <net/packet.h> 46 47 /** Returns the IP header length. 48 * 49 * @param[in] packet The packet. 50 * @return The IP header length in bytes. 51 * @return Zero if there is no IP header. 52 */ 53 size_t ip_client_header_length(packet_t *packet) 54 { 55 ip_header_t *header; 56 57 header = (ip_header_t *) packet_get_data(packet); 58 if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t))) 53 59 return 0; 54 } 60 55 61 return IP_HEADER_LENGTH(header); 56 62 } 57 63 58 int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen){ 59 ipv4_pseudo_header_ref header_in; 60 struct sockaddr_in * address_in; 61 62 if(!(header && headerlen)){ 64 /** Constructs the IPv4 pseudo header. 65 * 66 * @param[in] protocol The transport protocol. 67 * @param[in] src The source address. 68 * @param[in] srclen The source address length. 69 * @param[in] dest The destination address. 70 * @param[in] destlen The destination address length. 71 * @param[in] data_length The data length to be set. 72 * @param[out] header The constructed IPv4 pseudo header. 73 * @param[out] headerlen The length of the IP pseudo header in bytes. 74 * @return EOK on success. 75 * @return EBADMEM if the header and/or the headerlen parameter is 76 * NULL. 77 * @return EINVAL if the source address and/or the destination 78 * address parameter is NULL. 79 * @return EINVAL if the source address length is less than struct 80 * sockaddr length. 81 * @return EINVAL if the source address length differs from the 82 * destination address length. 83 * @return EINVAL if the source address family differs from the 84 * destination family. 85 * @return EAFNOSUPPORT if the address family is not supported. 86 * @return ENOMEM if there is not enough memory left. 87 */ 88 int 89 ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr *src, 90 socklen_t srclen, struct sockaddr *dest, socklen_t destlen, 91 size_t data_length, void **header, size_t *headerlen) 92 { 93 ipv4_pseudo_header_t *header_in; 94 struct sockaddr_in *address_in; 95 96 if (!header || !headerlen) 63 97 return EBADMEM; 64 } 65 if(!(src && dest && (srclen > 0) && ((size_t) srclen >= sizeof(struct sockaddr)) && (srclen == destlen) && (src->sa_family == dest->sa_family))){ 98 99 if (!src || !dest || srclen <= 0 || 100 (((size_t) srclen < sizeof(struct sockaddr))) || 101 (srclen != destlen) || (src->sa_family != dest->sa_family)) { 66 102 return EINVAL; 67 103 } 68 104 69 switch(src->sa_family){ 70 case AF_INET: 71 if(srclen != sizeof(struct sockaddr_in)){ 72 return EINVAL; 73 } 74 *headerlen = sizeof(*header_in); 75 header_in = (ipv4_pseudo_header_ref) malloc(*headerlen); 76 if(! header_in){ 77 return ENOMEM; 78 } 79 bzero(header_in, * headerlen); 80 address_in = (struct sockaddr_in *) dest; 81 header_in->destination_address = address_in->sin_addr.s_addr; 82 address_in = (struct sockaddr_in *) src; 83 header_in->source_address = address_in->sin_addr.s_addr; 84 header_in->protocol = protocol; 85 header_in->data_length = htons(data_length); 86 *header = header_in; 87 return EOK; 88 // TODO IPv6 89 /* case AF_INET6: 90 if(addrlen != sizeof(struct sockaddr_in6)){ 91 return EINVAL; 92 } 93 address_in6 = (struct sockaddr_in6 *) addr; 94 return EOK; 95 */ default: 96 return EAFNOSUPPORT; 97 } 98 } 99 100 int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length){ 101 ip_header_ref header; 102 uint8_t * data; 105 switch (src->sa_family) { 106 case AF_INET: 107 if (srclen != sizeof(struct sockaddr_in)) 108 return EINVAL; 109 110 *headerlen = sizeof(*header_in); 111 header_in = (ipv4_pseudo_header_t *) malloc(*headerlen); 112 if (!header_in) 113 return ENOMEM; 114 115 bzero(header_in, *headerlen); 116 address_in = (struct sockaddr_in *) dest; 117 header_in->destination_address = address_in->sin_addr.s_addr; 118 address_in = (struct sockaddr_in *) src; 119 header_in->source_address = address_in->sin_addr.s_addr; 120 header_in->protocol = protocol; 121 header_in->data_length = htons(data_length); 122 *header = header_in; 123 return EOK; 124 125 // TODO IPv6 126 /* case AF_INET6: 127 if (addrlen != sizeof(struct sockaddr_in6)) 128 return EINVAL; 129 130 address_in6 = (struct sockaddr_in6 *) addr; 131 return EOK; 132 */ 133 134 default: 135 return EAFNOSUPPORT; 136 } 137 } 138 139 /** Prepares the packet to be transfered via IP. 140 * 141 * The IP header is prefixed. 142 * 143 * @param[in,out] packet The packet to be prepared. 144 * @param[in] protocol The transport protocol. 145 * @param[in] ttl The time to live counter. The IPDEFTTL is set if zero. 146 * @param[in] tos The type of service. 147 * @param[in] dont_fragment The value indicating whether fragmentation is 148 * disabled. 149 * @param[in] ipopt_length The prefixed IP options length in bytes. 150 * @return EOK on success. 151 * @return ENOMEM if there is not enough memory left in the packet. 152 */ 153 int 154 ip_client_prepare_packet(packet_t *packet, ip_protocol_t protocol, ip_ttl_t ttl, 155 ip_tos_t tos, int dont_fragment, size_t ipopt_length) 156 { 157 ip_header_t *header; 158 uint8_t *data; 103 159 size_t padding; 104 160 … … 106 162 // multiple of 4 bytes 107 163 padding = ipopt_length % 4; 108 if (padding){164 if (padding) { 109 165 padding = 4 - padding; 110 166 ipopt_length += padding; … … 113 169 // prefix the header 114 170 data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding); 115 if (! data){171 if (!data) 116 172 return ENOMEM; 117 }118 173 119 174 // add the padding 120 while (padding --){175 while (padding--) 121 176 data[sizeof(ip_header_t) + padding] = IPOPT_NOOP; 122 }123 177 124 178 // set the header 125 header = (ip_header_ref) data; 126 header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length); 127 header->ttl = (ttl ? ttl : IPDEFTTL); //(((ttl) <= MAXTTL) ? ttl : MAXTTL) : IPDEFTTL; 179 header = (ip_header_t *) data; 180 header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + 181 ipopt_length); 182 header->ttl = (ttl ? ttl : IPDEFTTL); 128 183 header->tos = tos; 129 184 header->protocol = protocol; 130 185 131 if (dont_fragment){186 if (dont_fragment) 132 187 header->flags = IPFLAG_DONT_FRAGMENT; 133 } 188 134 189 return EOK; 135 190 } 136 191 137 int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length){ 138 ip_header_ref header; 139 140 header = (ip_header_ref) packet_get_data(packet); 141 if((! header) 142 || (packet_get_data_length(packet) < sizeof(ip_header_t))){ 192 /** Processes the received IP packet. 193 * 194 * Fills set header fields. 195 * Returns the prefixed IP header length. 196 * 197 * @param[in] packet The received packet. 198 * @param[out] protocol The transport protocol. May be NULL if not desired. 199 * @param[out] ttl The time to live counter. May be NULL if not desired. 200 * @param[out] tos The type of service. May be NULL if not desired. 201 * @param[out] dont_fragment The value indicating whether the fragmentation is 202 * disabled. May be NULL if not desired. 203 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not 204 * desired. 205 * @return The prefixed IP header length in bytes on success. 206 * @return ENOMEM if the packet is too short to contain the IP 207 * header. 208 */ 209 int 210 ip_client_process_packet(packet_t *packet, ip_protocol_t *protocol, 211 ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length) 212 { 213 ip_header_t *header; 214 215 header = (ip_header_t *) packet_get_data(packet); 216 if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t))) 143 217 return ENOMEM; 144 } 145 146 if(protocol){ 218 219 if (protocol) 147 220 *protocol = header->protocol; 148 } 149 if(ttl){ 221 if (ttl) 150 222 *ttl = header->ttl; 151 } 152 if(tos){ 223 if (tos) 153 224 *tos = header->tos; 154 } 155 if(dont_fragment){ 156 *dont_fragment = header->flags &IPFLAG_DONT_FRAGMENT; 157 } 158 if(ipopt_length){ 225 if (dont_fragment) 226 *dont_fragment = header->flags & IPFLAG_DONT_FRAGMENT; 227 if (ipopt_length) { 159 228 *ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t); 160 229 return sizeof(ip_header_t); 161 } else{230 } else { 162 231 return IP_HEADER_LENGTH(header); 163 232 } 164 233 } 165 234 166 int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length){ 167 ipv4_pseudo_header_ref header_in; 168 169 if(! header){ 235 /** Updates the IPv4 pseudo header data length field. 236 * 237 * @param[in,out] header The IPv4 pseudo header to be updated. 238 * @param[in] headerlen The length of the IP pseudo header in bytes. 239 * @param[in] data_length The data length to be set. 240 * @return EOK on success. 241 * @return EBADMEM if the header parameter is NULL. 242 * @return EINVAL if the headerlen parameter is not IPv4 pseudo 243 * header length. 244 */ 245 int 246 ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, 247 size_t data_length) 248 { 249 ipv4_pseudo_header_t *header_in; 250 251 if (!header) 170 252 return EBADMEM; 171 } 172 173 if(headerlen == sizeof(ipv4_pseudo_header_t)){ 174 header_in = (ipv4_pseudo_header_ref) header; 253 254 if (headerlen == sizeof(ipv4_pseudo_header_t)) { 255 header_in = (ipv4_pseudo_header_t *) header; 175 256 header_in->data_length = htons(data_length); 176 257 return EOK; 177 258 // TODO IPv6 178 } else{259 } else { 179 260 return EINVAL; 180 261 } -
uspace/lib/net/il/ip_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 40 40 */ 41 41 42 #include <ip_remote.h> 43 #include <ip_interface.h> 44 #include <packet_client.h> 45 #include <generic.h> 46 42 47 #include <ipc/services.h> 43 44 #include <net_messages.h> 45 #include <net_modules.h> 46 #include <net_device.h> 47 #include <inet.h> 48 #include <ip_interface.h> 49 #include <packet/packet_client.h> 50 #include <il_messages.h> 51 #include <ip_messages.h> 52 #include <ip_remote.h> 48 #include <ipc/il.h> 49 #include <ipc/ip.h> 50 51 #include <net/modules.h> 52 #include <net/device.h> 53 #include <net/inet.h> 53 54 54 55 /** Add a route to the device routing table. … … 56 57 * The target network is routed using this device. 57 58 * 58 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 59 * @param[in] device_id The device identifier. 60 * @param[in] address The target network address. 61 * @param[in] netmask The target network mask. 62 * @param[in] gateway The target network gateway. Not used if zero. 63 * 59 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 60 * @param[in] device_id The device identifier. 61 * @param[in] address The target network address. 62 * @param[in] netmask The target network mask. 63 * @param[in] gateway The target network gateway. Not used if zero. 64 64 */ 65 65 int ip_add_route_req_remote(int ip_phone, device_id_t device_id, … … 71 71 } 72 72 73 /** Creates bidirectional connection with the ip module service and registers 74 * the message receiver. 75 * 76 * @param[in] service The IP module service. 77 * @param[in] protocol The transport layer protocol. 78 * @param[in] me The requesting module service. 79 * @param[in] receiver The message receiver. Used for remote connection. 80 * @return The phone of the needed service. 81 * @return EOK on success. 82 * @return Other error codes as defined for the bind_service() 83 * function. 84 */ 73 85 int ip_bind_service(services_t service, int protocol, services_t me, 74 async_client_conn_t receiver , tl_received_msg_t tl_received_msg)86 async_client_conn_t receiver) 75 87 { 76 88 return (int) bind_service(service, (ipcarg_t) protocol, me, service, … … 78 90 } 79 91 92 /** Connects to the IP module. 93 * 94 * @param service The IP module service. Ignored parameter. 95 * @return The IP module phone on success. 96 */ 80 97 int ip_connect_module(services_t service) 81 98 { … … 88 105 * If the device uses ARP registers also the new ARP device. 89 106 * 90 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 91 * @param[in] device_id The new device identifier. 92 * @param[in] netif The underlying device network interface layer service. 93 * 94 * @return EOK on success. 95 * @return ENOMEM if there is not enough memory left. 96 * @return EINVAL if the device configuration is invalid. 97 * @return ENOTSUP if the device uses IPv6. 98 * @return ENOTSUP if the device uses DHCP. 99 * @return Other error codes as defined for the net_get_device_conf_req() 100 * function. 101 * @return Other error codes as defined for the arp_device_req() function. 102 * 107 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 108 * @param[in] device_id The new device identifier. 109 * @param[in] netif The underlying device network interface layer service. 110 * @return EOK on success. 111 * @return ENOMEM if there is not enough memory left. 112 * @return EINVAL if the device configuration is invalid. 113 * @return ENOTSUP if the device uses IPv6. 114 * @return ENOTSUP if the device uses DHCP. 115 * @return Other error codes as defined for the 116 * net_get_device_conf_req() function. 117 * @return Other error codes as defined for the arp_device_req() 118 * function. 103 119 */ 104 120 int ip_device_req_remote(int ip_phone, device_id_t device_id, … … 109 125 } 110 126 111 /** Return the device identifier and the IP pseudo header based on the destination address. 112 * 113 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 114 * @param[in] protocol The transport protocol. 115 * @param[in] destination The destination address. 116 * @param[in] addrlen The destination address length. 117 * @param[out] device_id The device identifier. 118 * @param[out] header The constructed IP pseudo header. 119 * @param[out] headerlen The IP pseudo header length. 127 /** Return the device identifier and the IP pseudo header based on the 128 * destination address. 129 * 130 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 131 * @param[in] protocol The transport protocol. 132 * @param[in] destination The destination address. 133 * @param[in] addrlen The destination address length. 134 * @param[out] device_id The device identifier. 135 * @param[out] header The constructed IP pseudo header. 136 * @param[out] headerlen The IP pseudo header length. 120 137 * 121 138 */ … … 124 141 device_id_t *device_id, void **header, size_t *headerlen) 125 142 { 126 if ( (!destination)|| (addrlen == 0))143 if (!destination || (addrlen == 0)) 127 144 return EINVAL; 128 145 129 if ( (!device_id) || (header) || (headerlen))146 if (!device_id || !header || !headerlen) 130 147 return EBADMEM; 131 148 … … 136 153 (ipcarg_t) protocol, &answer); 137 154 138 if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) 139 && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)140 && (*headerlen > 0)) {155 if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) && 156 (async_data_read_start(ip_phone, headerlen, 157 sizeof(*headerlen)) == EOK) && (*headerlen > 0)) { 141 158 *header = malloc(*headerlen); 142 159 if (*header) { 143 if (async_data_read_start(ip_phone, *header, *headerlen) != EOK) 160 if (async_data_read_start(ip_phone, *header, 161 *headerlen) != EOK) 144 162 free(*header); 145 163 } … … 149 167 async_wait_for(message_id, &result); 150 168 151 if ((result != EOK) && (*header))169 if ((result != EOK) && *header) 152 170 free(*header); 153 171 else … … 159 177 /** Return the device packet dimension for sending. 160 178 * 161 * @param[in] ip_phoneThe IP module phone used for (semi)remote calls.162 * @param[in] device_idThe device identifier.179 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 180 * @param[in] device_id The device identifier. 163 181 * @param[out] packet_dimension The packet dimension. 164 * 165 * @return EOK on success. 166 * @return ENOENT if there is no such device. 167 * @return Other error codes as defined for the 168 * generic_packet_size_req_remote() function. 169 * 182 * @return EOK on success. 183 * @return ENOENT if there is no such device. 184 * @return Other error codes as defined for the 185 * generic_packet_size_req_remote() function. 170 186 */ 171 187 int ip_packet_size_req_remote(int ip_phone, device_id_t device_id, 172 packet_dimension_ refpacket_dimension)173 { 174 return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,175 packet_dimension);188 packet_dimension_t *packet_dimension) 189 { 190 return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, 191 device_id, packet_dimension); 176 192 } 177 193 178 194 /** Notify the IP module about the received error notification packet. 179 195 * 180 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 181 * @param[in] device_id The device identifier. 182 * @param[in] packet The received packet or the received packet queue. 183 * @param[in] target The target internetwork module service to be 184 * delivered to. 185 * @param[in] error The packet error reporting service. Prefixes the 186 * received packet. 187 * 188 * @return EOK on success. 189 * 196 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 197 * @param[in] device_id The device identifier. 198 * @param[in] packet The received packet or the received packet queue. 199 * @param[in] target The target internetwork module service to be 200 * delivered to. 201 * @param[in] error The packet error reporting service. Prefixes the 202 * received packet. 203 * @return EOK on success. 190 204 */ 191 205 int ip_received_error_msg_remote(int ip_phone, device_id_t device_id, 192 packet_t packet, services_t target, services_t error)206 packet_t *packet, services_t target, services_t error) 193 207 { 194 208 return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR, … … 200 214 * The packets may get fragmented if needed. 201 215 * 202 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 203 * @param[in] device_id The device identifier. 204 * @param[in] packet The packet fragments as a packet queue. All the 205 * packets have to have the same destination address. 206 * @param[in] sender The sending module service. 207 * @param[in] error The packet error reporting service. Prefixes the 208 * received packet. 209 * 210 * @return EOK on success. 211 * @return Other error codes as defined for the generic_send_msg() function. 212 * 213 */ 214 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet, 216 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 217 * @param[in] device_id The device identifier. 218 * @param[in] packet The packet fragments as a packet queue. All the 219 * packets have to have the same destination address. 220 * @param[in] sender The sending module service. 221 * @param[in] error The packet error reporting service. Prefixes the 222 * received packet. 223 * @return EOK on success. 224 * @return Other error codes as defined for the generic_send_msg() 225 * function. 226 */ 227 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet, 215 228 services_t sender, services_t error) 216 229 { … … 223 236 * This gateway is used if no other route is found. 224 237 * 225 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 226 * @param[in] device_id The device identifier. 227 * @param[in] gateway The default gateway. 228 * 238 * @param[in] ip_phone The IP module phone used for (semi)remote calls. 239 * @param[in] device_id The device identifier. 240 * @param[in] gateway The default gateway. 229 241 */ 230 242 int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id, -
uspace/lib/net/include/adt/module_map.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Character string to module map.34 * Character string to module map. 35 35 */ 36 36 37 #ifndef __NET_MODULES_MAP_H__38 #define __NET_MODULES_MAP_H__37 #ifndef LIBNET_MODULES_MAP_H_ 38 #define LIBNET_MODULES_MAP_H_ 39 39 40 40 #include <task.h> 41 42 41 #include <ipc/services.h> 43 44 #include <net_modules.h> 45 42 #include <net/modules.h> 46 43 #include <adt/generic_char_map.h> 47 44 48 45 /** Type definition of the module structure. 49 * @see module_struct46 * @see module_struct 50 47 */ 51 typedef struct module_struct module_t; 52 53 /** Type definition of the module structure pointer. 54 * @see module_struct 55 */ 56 typedef module_t * module_ref; 48 typedef struct module_struct module_t; 57 49 58 50 /** Module map. 59 * Sorted by module names.60 * @see generic_char_map.h51 * Sorted by module names. 52 * @see generic_char_map.h 61 53 */ 62 54 GENERIC_CHAR_MAP_DECLARE(modules, module_t) 63 55 64 /** Module structure. 65 */ 66 struct module_struct{ 67 /** Module task identifier if running. 68 */ 56 /** Module structure. */ 57 struct module_struct { 58 /** Module task identifier if running. */ 69 59 task_id_t task_id; 70 /** Module service identifier. 71 */ 60 /** Module service identifier. */ 72 61 services_t service; 73 /** Module phone if running and connected. 74 */ 62 /** Module phone if running and connected. */ 75 63 int phone; 76 /** Usage counter. 77 */ 64 /** Usage counter. */ 78 65 int usage; 79 /** Module name. 80 */ 81 const char * name; 82 /** Module full path filename. 83 */ 84 const char * filename; 85 /** Connecting function. 86 */ 87 connect_module_t * connect_module; 66 /** Module name. */ 67 const char *name; 68 /** Module full path filename. */ 69 const char *filename; 70 /** Connecting function. */ 71 connect_module_t *connect_module; 88 72 }; 89 73 90 /** Adds module to the module map. 91 * @param[out] module The module structure added. 92 * @param[in] modules The module map. 93 * @param[in] name The module name. 94 * @param[in] filename The full path filename. 95 * @param[in] service The module service. 96 * @param[in] task_id The module current task identifier. Zero (0) means not running. 97 * @param[in] connect_module The module connecting function. 98 * @returns EOK on success. 99 * @returns ENOMEM if there is not enough memory left. 100 */ 101 int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module); 102 103 /** Searches and returns the specified module. 104 * If the module is not running, the module filaname is spawned. 105 * If the module is not connected, the connect_function is called. 106 * @param[in] modules The module map. 107 * @param[in] name The module name. 108 * @returns The running module found. It does not have to be connected. 109 * @returns NULL if there is no such module. 110 */ 111 module_ref get_running_module(modules_ref modules, char * name); 112 113 /** Starts the given module. 114 * @param[in] fname The module full or relative path filename. 115 * @returns The new module task identifier on success. 116 * @returns 0 if there is no such module. 117 */ 118 task_id_t spawn(const char * fname); 74 extern int add_module(module_t **, modules_t *, const char *, const char *, 75 services_t, task_id_t, connect_module_t *); 76 extern module_t *get_running_module(modules_t *, char *); 77 extern task_id_t spawn(const char *); 119 78 120 79 #endif -
uspace/lib/net/include/arp_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup arp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_ARP_INTERFACE_H__34 #define __NET_ARP_INTERFACE_H__33 #ifndef LIBNET_ARP_INTERFACE_H_ 34 #define LIBNET_ARP_INTERFACE_H_ 35 35 36 36 #include <adt/measured_strings.h> 37 #include <net_device.h> 37 #include <task.h> 38 39 #include <ipc/services.h> 40 41 #include <net/device.h> 42 #include <net/socket.h> 38 43 39 44 /** @name ARP module interface 40 * This interface is used by other modules.45 * This interface is used by other modules. 41 46 */ 42 47 /*@{*/ 43 48 44 /** Registers the new device and the requesting protocol service. 45 * Connects to the network interface layer service. 46 * Determines the device broadcast address, its address lengths and packet size. 47 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 48 * @param[in] device_id The new device identifier. 49 * @param[in] protocol The requesting protocol service. 50 * @param[in] netif The underlying device network interface layer service. 51 * @param[in] address The local requesting protocol address of the device. 52 * @returns EOK on success. 53 * @returns EEXIST if the device is already used. 54 * @returns ENOMEM if there is not enough memory left. 55 * @returns ENOENT if the network interface service is not known. 56 * @returns EREFUSED if the network interface service is not responding. 57 * @returns Other error codes as defined for the nil_packet_get_size() function. 58 * @returns Other error codes as defined for the nil_get_addr() function. 59 * @returns Other error codes as defined for the nil_get_broadcast_addr() function. 60 */ 61 extern int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address); 62 63 /** Translates the given protocol address to the network interface address. 64 * Broadcasts the ARP request if the mapping is not found. 65 * Allocates and returns the needed memory block as the data parameter. 66 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 67 * @param[in] device_id The device identifier. 68 * @param[in] protocol The requesting protocol service. 69 * @param[in] address The local requesting protocol address. 70 * @param[out] translation The translation of the local protocol address. 71 * @param[out] data The allocated raw translation data container. 72 * @returns EOK on success. 73 * @returns EINVAL if the address parameter is NULL. 74 * @returns EBADMEM if the translation or the data parameters are NULL. 75 * @returns ENOENT if the mapping is not found. 76 */ 77 extern int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data); 78 79 /** Clears the device cache. 80 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 81 * @param[in] device_id The device identifier. 82 * @returns EOK on success. 83 * @returns ENOENT if the device is not found. 84 */ 85 extern int arp_clear_device_req(int arp_phone, device_id_t device_id); 86 87 /** Clears the given protocol address from the cache. 88 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 89 * @param[in] device_id The device identifier. 90 * @param[in] protocol The requesting protocol service. 91 * @param[in] address The protocol address to be cleared. 92 * @returns EOK on success. 93 * @returns ENOENT if the mapping is not found. 94 */ 95 extern int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address); 96 97 /** Cleans the cache. 98 * @param[in] arp_phone The ARP module phone used for (semi)remote calls. 99 * @returns EOK on success. 100 */ 101 extern int arp_clean_cache_req(int arp_phone); 102 103 /** Connects to the ARP module. 104 * @param service The ARP module service. Ignored parameter. 105 * @returns The ARP module phone on success. 106 * @returns 0 if called by the bundle module. 107 */ 108 extern int arp_connect_module(services_t service); 109 110 /** Returns the ARP task identifier. 111 * @returns The current task identifier if called by the bundle module. 112 * @returns 0 if called by the remote module. 113 */ 114 extern task_id_t arp_task_get_id(void); 49 extern int arp_device_req(int, device_id_t, services_t, services_t, 50 measured_string_t *); 51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *, 52 measured_string_t **, char **); 53 extern int arp_clear_device_req(int, device_id_t); 54 extern int arp_clear_address_req(int, device_id_t, services_t, 55 measured_string_t *); 56 extern int arp_clean_cache_req(int); 57 extern int arp_connect_module(services_t); 115 58 116 59 /*@}*/ -
uspace/lib/net/include/ethernet_lsap.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup eth30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Link service access point identifiers.34 * Link service access point identifiers. 35 35 */ 36 36 37 #ifndef __NET_ETHERNET_LSAP_H__38 #define __NET_ETHERNET_LSAP_H__37 #ifndef LIBNET_ETHERNET_LSAP_H_ 38 #define LIBNET_ETHERNET_LSAP_H_ 39 39 40 40 #include <sys/types.h> 41 41 42 /** Ethernet LSAP type definition. 43 */ 44 typedef uint8_t eth_lsap_t; 42 /** Ethernet LSAP type definition. */ 43 typedef uint8_t eth_lsap_t; 45 44 46 /** @name Ethernet LSAP values definitions 47 */ 45 /** @name Ethernet LSAP values definitions */ 48 46 /*@{*/ 49 47 50 /** Null LSAP LSAP identifier. 51 */ 48 /** Null LSAP LSAP identifier. */ 52 49 #define ETH_LSAP_NULL 0x00 53 /** Individual LLC Sublayer Management Function LSAP identifier. 54 */ 55 #define ETH_LSAP_ISLMF 0x02 56 /** Group LLC Sublayer Management Function LSAP identifier. 57 */ 58 #define ETH_LSAP_GSLMI 0x03 59 /** IBM SNA Path Control (individual) LSAP identifier. 60 */ 61 #define ETH_LSAP_ISNA 0x04 62 /** IBM SNA Path Control (group) LSAP identifier. 63 */ 64 #define ETH_LSAP_GSNA 0x05 65 /** ARPANET Internet Protocol (IP) LSAP identifier. 66 */ 50 /** ARPANET Internet Protocol (IP) LSAP identifier. */ 67 51 #define ETH_LSAP_IP 0x06 68 /** SNA LSAP identifier. 69 */ 70 #define ETH_LSAP_SNA 0x08 71 /** SNA LSAP identifier. 72 */ 73 #define ETH_LSAP_SNA2 0x0C 74 /** PROWAY (IEC955) Network Management &Initialization LSAP identifier. 75 */ 76 #define ETH_LSAP_PROWAY_NMI 0x0E 77 /** Texas Instruments LSAP identifier. 78 */ 79 #define ETH_LSAP_TI 0x18 80 /** IEEE 802.1 Bridge Spanning Tree Protocol LSAP identifier. 81 */ 82 #define ETH_LSAP_BRIDGE 0x42 83 /** EIA RS-511 Manufacturing Message Service LSAP identifier. 84 */ 85 #define ETH_LSAP_EIS 0x4E 86 /** ISO 8208 (X.25 over IEEE 802.2 Type 2 LLC) LSAP identifier. 87 */ 88 #define ETH_LSAP_ISO8208 0x7E 89 /** Xerox Network Systems (XNS) LSAP identifier. 90 */ 91 #define ETH_LSAP_XNS 0x80 92 /** Nestar LSAP identifier. 93 */ 94 #define ETH_LSAP_NESTAR 0x86 95 /** PROWAY (IEC 955) Active Station List Maintenance LSAP identifier. 96 */ 97 #define ETH_LSAP_PROWAY_ASLM 0x8E 98 /** ARPANET Address Resolution Protocol (ARP) LSAP identifier. 99 */ 52 /** ARPANET Address Resolution Protocol (ARP) LSAP identifier. */ 100 53 #define ETH_LSAP_ARP 0x98 101 /** Banyan VINES LSAP identifier. 102 */ 103 #define ETH_LSAP_VINES 0xBC 104 /** SubNetwork Access Protocol (SNAP) LSAP identifier. 105 */ 54 /** SubNetwork Access Protocol (SNAP) LSAP identifier. */ 106 55 #define ETH_LSAP_SNAP 0xAA 107 /** Novell NetWare LSAP identifier. 108 */ 109 #define ETH_LSAP_NETWARE 0xE0 110 /** IBM NetBIOS LSAP identifier. 111 */ 112 #define ETH_LSAP_NETBIOS 0xF0 113 /** IBM LAN Management (individual) LSAP identifier. 114 */ 115 #define ETH_LSAP_ILAN 0xF4 116 /** IBM LAN Management (group) LSAP identifier. 117 */ 118 #define ETH_LSAP_GLAN 0xF5 119 /** IBM Remote Program Load (RPL) LSAP identifier. 120 */ 121 #define ETH_LSAP_RPL 0xF8 122 /** Ungermann-Bass LSAP identifier. 123 */ 124 #define ETH_LSAP_UB 0xFA 125 /** ISO Network Layer Protocol LSAP identifier. 126 */ 127 #define ETH_LSAP_ISONLP 0xFE 128 /** Global LSAP LSAP identifier. 129 */ 56 /** Global LSAP LSAP identifier. */ 130 57 #define ETH_LSAP_GLSAP 0xFF 131 58 -
uspace/lib/net/include/ethernet_protocols.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup eth30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Ethernet protocol numbers according to the on-line IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009. 34 * Ethernet protocol numbers according to the on-line IANA - Ethernet numbers 35 * http://www.iana.org/assignments/ethernet-numbers 36 * cited January 17 2009. 35 37 */ 36 38 37 #ifndef __NET_ETHERNET_PROTOCOLS_H__38 #define __NET_ETHERNET_PROTOCOLS_H__39 #ifndef LIBNET_ETHERNET_PROTOCOLS_H_ 40 #define LIBNET_ETHERNET_PROTOCOLS_H_ 39 41 40 42 #include <sys/types.h> 41 43 42 /** Ethernet protocol type definition. 43 */ 44 typedef uint16_t eth_type_t; 44 /** Ethernet protocol type definition. */ 45 typedef uint16_t eth_type_t; 45 46 46 /** @name Ethernet protocols definitions 47 */ 47 /** @name Ethernet protocols definitions */ 48 48 /*@{*/ 49 49 50 50 /** Ethernet minimal protocol number. 51 * According to the IEEE 802.3 specification.51 * According to the IEEE 802.3 specification. 52 52 */ 53 #define ETH_MIN_PROTO 0x0600 /*1536*/53 #define ETH_MIN_PROTO 0x0600 /* 1536 */ 54 54 55 /** Ethernet loopback packet protocol type. 56 */ 57 #define ETH_P_LOOP 0x0060 58 59 /** XEROX PUP (see 0A00) ethernet protocol type. 60 */ 61 #define ETH_P_PUP 0x0200 62 63 /** PUP Addr Trans (see 0A01) ethernet protocol type. 64 */ 65 #define ETH_P_PUPAT 0x0201 66 67 /** Nixdorf ethernet protocol type. 68 */ 69 #define ETH_P_Nixdorf 0x0400 70 71 /** XEROX NS IDP ethernet protocol type. 72 */ 73 #define ETH_P_XEROX_NS_IDP 0x0600 74 75 /** DLOG ethernet protocol type. 76 */ 77 #define ETH_P_DLOG 0x0660 78 79 /** DLOG ethernet protocol type. 80 */ 81 #define ETH_P_DLOG2 0x0661 82 83 /** Internet IP (IPv4) ethernet protocol type. 84 */ 55 /** Internet IP (IPv4) ethernet protocol type. */ 85 56 #define ETH_P_IP 0x0800 86 57 87 /** X.75 Internet ethernet protocol type. 88 */ 89 #define ETH_P_X_75 0x0801 90 91 /** NBS Internet ethernet protocol type. 92 */ 93 #define ETH_P_NBS 0x0802 94 95 /** ECMA Internet ethernet protocol type. 96 */ 97 #define ETH_P_ECMA 0x0803 98 99 /** Chaosnet ethernet protocol type. 100 */ 101 #define ETH_P_Chaosnet 0x0804 102 103 /** X.25 Level 3 ethernet protocol type. 104 */ 105 #define ETH_P_X25 0x0805 106 107 /** ARP ethernet protocol type. 108 */ 58 /** ARP ethernet protocol type. */ 109 59 #define ETH_P_ARP 0x0806 110 111 /** XNS Compatability ethernet protocol type.112 */113 #define ETH_P_XNS_Compatability 0x0807114 115 /** Frame Relay ARP ethernet protocol type.116 */117 #define ETH_P_Frame_Relay_ARP 0x0808118 119 /** Symbolics Private ethernet protocol type.120 */121 #define ETH_P_Symbolics_Private 0x081C122 123 /** Xyplex ethernet protocol type.124 */125 #define ETH_P_Xyplex_MIN 0x0888126 127 /** Xyplex ethernet protocol type.128 */129 #define ETH_P_Xyplex_MAX 0x088A130 131 /** Ungermann-Bass net debugr ethernet protocol type.132 */133 #define ETH_P_Ungermann_Bass_net_debugr 0x0900134 135 /** Xerox IEEE802.3 PUP ethernet protocol type.136 */137 #define ETH_P_IEEEPUP 0x0A00138 139 /** PUP Addr Trans ethernet protocol type.140 */141 #define ETH_P_IEEEPUPAT 0x0A01142 143 /** Banyan VINES ethernet protocol type.144 */145 #define ETH_P_Banyan_VINES 0x0BAD146 147 /** VINES Loopback ethernet protocol type.148 */149 #define ETH_P_VINES_Loopback 0x0BAE150 151 /** VINES Echo ethernet protocol type.152 */153 #define ETH_P_VINES_Echo 0x0BAF154 155 /** Berkeley Trailer nego ethernet protocol type.156 */157 #define ETH_P_Berkeley_Trailer_nego 0x1000158 159 /** Berkeley Trailer encap/IP ethernet protocol type.160 */161 #define ETH_P_Berkeley_Trailer_encapIP_MIN 0x1001162 163 /** Berkeley Trailer encap/IP ethernet protocol type.164 */165 #define ETH_P_Berkeley_Trailer_encapIP_MAX 0x100F166 167 /** Valid Systems ethernet protocol type.168 */169 #define ETH_P_Valid_Systems 0x1600170 171 /** PCS Basic Block Protocol ethernet protocol type.172 */173 #define ETH_P_PCS_Basic_Block_Protocol 0x4242174 175 /** BBN Simnet ethernet protocol type.176 */177 #define ETH_P_BBN_Simnet 0x5208178 179 /** DEC Unassigned (Exp.) ethernet protocol type.180 */181 #define ETH_P_DEC 0x6000182 183 /** DEC MOP Dump/Load ethernet protocol type.184 */185 #define ETH_P_DNA_DL 0x6001186 187 /** DEC MOP Remote Console ethernet protocol type.188 */189 #define ETH_P_DNA_RC 0x6002190 191 /** DEC DECNET Phase IV Route ethernet protocol type.192 */193 #define ETH_P_DNA_RT 0x6003194 195 /** DEC LAT ethernet protocol type.196 */197 #define ETH_P_LAT 0x6004198 199 /** DEC Diagnostic Protocol ethernet protocol type.200 */201 #define ETH_P_DIAG 0x6005202 203 /** DEC Customer Protocol ethernet protocol type.204 */205 #define ETH_P_CUST 0x6006206 207 /** DEC LAVC, SCA ethernet protocol type.208 */209 #define ETH_P_SCA 0x6007210 211 /** DEC Unassigned ethernet protocol type.212 */213 #define ETH_P_DEC_Unassigned_MIN 0x6008214 215 /** DEC Unassigned ethernet protocol type.216 */217 #define ETH_P_DEC_Unassigned_MAX 0x6009218 219 /** Com Corporation ethernet protocol type.220 */221 #define ETH_P_Com_Corporation_MIN 0x6010222 223 /** Com Corporation ethernet protocol type.224 */225 #define ETH_P_Com_Corporation_MAX 0x6014226 227 /** Trans Ether Bridging ethernet protocol type.228 */229 #define ETH_P_Trans_Ether_Bridging 0x6558230 231 /** Raw Frame Relay ethernet protocol type.232 */233 #define ETH_P_Raw_Frame_Relay 0x6559234 235 /** Ungermann-Bass download ethernet protocol type.236 */237 #define ETH_P_Ungermann_Bass_download 0x7000238 239 /** Ungermann-Bass dia/loop ethernet protocol type.240 */241 #define ETH_P_Ungermann_Bass_dialoop 0x7002242 243 /** LRT ethernet protocol type.244 */245 #define ETH_P_LRT_MIN 0x7020246 247 /** LRT ethernet protocol type.248 */249 #define ETH_P_LRT_MAX 0x7029250 251 /** Proteon ethernet protocol type.252 */253 #define ETH_P_Proteon 0x7030254 255 /** Cabletron ethernet protocol type.256 */257 #define ETH_P_Cabletron 0x7034258 259 /** Cronus VLN ethernet protocol type.260 */261 #define ETH_P_Cronus_VLN 0x8003262 263 /** Cronus Direct ethernet protocol type.264 */265 #define ETH_P_Cronus_Direct 0x8004266 267 /** HP Probe ethernet protocol type.268 */269 #define ETH_P_HP_Probe 0x8005270 271 /** Nestar ethernet protocol type.272 */273 #define ETH_P_Nestar 0x8006274 275 /** AT&T ethernet protocol type.276 */277 #define ETH_P_AT_T 0x8008278 279 /** Excelan ethernet protocol type.280 */281 #define ETH_P_Excelan 0x8010282 283 /** SGI diagnostics ethernet protocol type.284 */285 #define ETH_P_SGI_diagnostics 0x8013286 287 /** SGI network games ethernet protocol type.288 */289 #define ETH_P_SGI_network_games 0x8014290 291 /** SGI reserved ethernet protocol type.292 */293 #define ETH_P_SGI_reserved 0x8015294 295 /** SGI bounce server ethernet protocol type.296 */297 #define ETH_P_SGI_bounce_server 0x8016298 299 /** Apollo Domain ethernet protocol type.300 */301 #define ETH_P_Apollo_Domain 0x8019302 303 /** Tymshare ethernet protocol type.304 */305 #define ETH_P_Tymshare 0x802E306 307 /** Tigan, Inc. ethernet protocol type.308 */309 #define ETH_P_Tigan 0x802F310 311 /** Reverse ARP ethernet protocol type.312 */313 #define ETH_P_RARP 0x8035314 315 /** Aeonic Systems ethernet protocol type.316 */317 #define ETH_P_Aeonic_Systems 0x8036318 319 /** DEC LANBridge ethernet protocol type.320 */321 #define ETH_P_DEC_LANBridge 0x8038322 323 /** DEC Unassigned ethernet protocol type.324 */325 #define ETH_P_DEC_Unassigned_MIN1 0x8039326 327 /** DEC Unassigned ethernet protocol type.328 */329 #define ETH_P_DEC_Unassigned_MAX2 0x803C330 331 /** DEC Ethernet Encryption ethernet protocol type.332 */333 #define ETH_P_DEC_Ethernet_Encryption 0x803D334 335 /** DEC Unassigned ethernet protocol type.336 */337 #define ETH_P_DEC_Unassigned 0x803E338 339 /** DEC LAN Traffic Monitor ethernet protocol type.340 */341 #define ETH_P_DEC_LAN_Traffic_Monitor 0x803F342 343 /** DEC Unassigned ethernet protocol type.344 */345 #define ETH_P_DEC_Unassigned_MIN3 0x8040346 347 /** DEC Unassigned ethernet protocol type.348 */349 #define ETH_P_DEC_Unassigned_MAX3 0x8042350 351 /** Planning Research Corp. ethernet protocol type.352 */353 #define ETH_P_Planning_Research_Corp 0x8044354 355 /** AT&T ethernet protocol type.356 */357 #define ETH_P_AT_T2 0x8046358 359 /** AT&T ethernet protocol type.360 */361 #define ETH_P_AT_T3 0x8047362 363 /** ExperData ethernet protocol type.364 */365 #define ETH_P_ExperData 0x8049366 367 /** Stanford V Kernel exp. ethernet protocol type.368 */369 #define ETH_P_Stanford_V_Kernel_exp 0x805B370 371 /** Stanford V Kernel prod. ethernet protocol type.372 */373 #define ETH_P_Stanford_V_Kernel_prod 0x805C374 375 /** Evans &Sutherland ethernet protocol type.376 */377 #define ETH_P_Evans_Sutherland 0x805D378 379 /** Little Machines ethernet protocol type.380 */381 #define ETH_P_Little_Machines 0x8060382 383 /** Counterpoint Computers ethernet protocol type.384 */385 #define ETH_P_Counterpoint_Computers 0x8062386 387 /** Univ. of Mass. @ Amherst ethernet protocol type.388 */389 #define ETH_P_Univ_of_Mass 0x8065390 391 /** Univ. of Mass. @ Amherst ethernet protocol type.392 */393 #define ETH_P_Univ_of_Mass2 0x8066394 395 /** Veeco Integrated Auto. ethernet protocol type.396 */397 #define ETH_P_Veeco_Integrated_Auto 0x8067398 399 /** General Dynamics ethernet protocol type.400 */401 #define ETH_P_General_Dynamics 0x8068402 403 /** AT&T ethernet protocol type.404 */405 #define ETH_P_AT_T4 0x8069406 407 /** Autophon ethernet protocol type.408 */409 #define ETH_P_Autophon 0x806A410 411 /** ComDesign ethernet protocol type.412 */413 #define ETH_P_ComDesign 0x806C414 415 /** Computgraphic Corp. ethernet protocol type.416 */417 #define ETH_P_Computgraphic_Corp 0x806D418 419 /** Landmark Graphics Corp. ethernet protocol type.420 */421 #define ETH_P_Landmark_Graphics_Corp_MIN 0x806E422 423 /** Landmark Graphics Corp. ethernet protocol type.424 */425 #define ETH_P_Landmark_Graphics_Corp_MAX 0x8077426 427 /** Matra ethernet protocol type.428 */429 #define ETH_P_Matra 0x807A430 431 /** Dansk Data Elektronik ethernet protocol type.432 */433 #define ETH_P_Dansk_Data_Elektronik 0x807B434 435 /** Merit Internodal ethernet protocol type.436 */437 #define ETH_P_Merit_Internodal 0x807C438 439 /** Vitalink Communications ethernet protocol type.440 */441 #define ETH_P_Vitalink_Communications_MIN 0x807D442 443 /** Vitalink Communications ethernet protocol type.444 */445 #define ETH_P_Vitalink_Communications_MAX 0x807F446 447 /** Vitalink TransLAN III ethernet protocol type.448 */449 #define ETH_P_Vitalink_TransLAN_III 0x8080450 451 /** Counterpoint Computers ethernet protocol type.452 */453 #define ETH_P_Counterpoint_Computers_MIN 0x8081454 455 /** Counterpoint Computers ethernet protocol type.456 */457 #define ETH_P_Counterpoint_Computers_MAX 0x8083458 459 /** Appletalk ethernet protocol type.460 */461 #define ETH_P_ATALK 0x809B462 463 /** Datability ethernet protocol type.464 */465 #define ETH_P_Datability_MIN 0x809C466 467 /** Datability ethernet protocol type.468 */469 #define ETH_P_Datability_MAX 0x809E470 471 /** Spider Systems Ltd. ethernet protocol type.472 */473 #define ETH_P_Spider_Systems_Ltd 0x809F474 475 /** Nixdorf Computers ethernet protocol type.476 */477 #define ETH_P_Nixdorf_Computers 0x80A3478 479 /** Siemens Gammasonics Inc. ethernet protocol type.480 */481 #define ETH_P_Siemens_Gammasonics_Inc_MIN 0x80A4482 483 /** Siemens Gammasonics Inc. ethernet protocol type.484 */485 #define ETH_P_Siemens_Gammasonics_Inc_MAX 0x80B3486 487 /** DCA Data Exchange Cluster ethernet protocol type.488 */489 #define ETH_P_DCA_Data_Exchange_Cluster_MIN 0x80C0490 491 /** DCA Data Exchange Cluster ethernet protocol type.492 */493 #define ETH_P_DCA_Data_Exchange_Cluster_MAX 0x80C3494 495 /** Banyan Systems ethernet protocol type.496 */497 #define ETH_P_Banyan_Systems 0x80C4498 499 /** Banyan Systems ethernet protocol type.500 */501 #define ETH_P_Banyan_Systems2 0x80C5502 503 /** Pacer Software ethernet protocol type.504 */505 #define ETH_P_Pacer_Software 0x80C6506 507 /** Applitek Corporation ethernet protocol type.508 */509 #define ETH_P_Applitek_Corporation 0x80C7510 511 /** Intergraph Corporation ethernet protocol type.512 */513 #define ETH_P_Intergraph_Corporation_MIN 0x80C8514 515 /** Intergraph Corporation ethernet protocol type.516 */517 #define ETH_P_Intergraph_Corporation_MAX 0x80CC518 519 /** Harris Corporation ethernet protocol type.520 */521 #define ETH_P_Harris_Corporation_MIN 0x80CD522 523 /** Harris Corporation ethernet protocol type.524 */525 #define ETH_P_Harris_Corporation_MAX 0x80CE526 527 /** Taylor Instrument ethernet protocol type.528 */529 #define ETH_P_Taylor_Instrument_MIN 0x80CF530 531 /** Taylor Instrument ethernet protocol type.532 */533 #define ETH_P_Taylor_Instrument_MAX 0x80D2534 535 /** Rosemount Corporation ethernet protocol type.536 */537 #define ETH_P_Rosemount_Corporation_MIN 0x80D3538 539 /** Rosemount Corporation ethernet protocol type.540 */541 #define ETH_P_Rosemount_Corporation_MAX 0x80D4542 543 /** IBM SNA Service on Ether ethernet protocol type.544 */545 #define ETH_P_IBM_SNA_Service_on_Ether 0x80D5546 547 /** Varian Associates ethernet protocol type.548 */549 #define ETH_P_Varian_Associates 0x80DD550 551 /** Integrated Solutions TRFS ethernet protocol type.552 */553 #define ETH_P_Integrated_Solutions_TRFS_MIN 0x80DE554 555 /** Integrated Solutions TRFS ethernet protocol type.556 */557 #define ETH_P_Integrated_Solutions_TRFS_MAX 0x80DF558 559 /** Allen-Bradley ethernet protocol type.560 */561 #define ETH_P_Allen_Bradley_MIN 0x80E0562 563 /** Allen-Bradley ethernet protocol type.564 */565 #define ETH_P_Allen_Bradley_MAX 0x80E3566 567 /** Datability ethernet protocol type.568 */569 #define ETH_P_Datability_MIN2 0x80E4570 571 /** Datability ethernet protocol type.572 */573 #define ETH_P_Datability_MAX2 0x80F0574 575 /** Retix ethernet protocol type.576 */577 #define ETH_P_Retix 0x80F2578 579 /** AppleTalk AARP (Kinetics) ethernet protocol type.580 */581 #define ETH_P_AARP 0x80F3582 583 /** Kinetics ethernet protocol type.584 */585 #define ETH_P_Kinetics_MIN 0x80F4586 587 /** Kinetics ethernet protocol type.588 */589 #define ETH_P_Kinetics_MAX 0x80F5590 591 /** Apollo Computer ethernet protocol type.592 */593 #define ETH_P_Apollo_Computer 0x80F7594 595 /** Wellfleet Communications ethernet protocol type.596 */597 #define ETH_P_Wellfleet_Communications 0x80FF598 599 /** IEEE 802.1Q VLAN-tagged frames (initially Wellfleet) ethernet protocol type.600 */601 #define ETH_P_8021Q 0x8100602 603 /** Wellfleet Communications ethernet protocol type.604 */605 #define ETH_P_Wellfleet_Communications_MIN 0x8101606 607 /** Wellfleet Communications ethernet protocol type.608 */609 #define ETH_P_Wellfleet_Communications_MAX 0x8103610 611 /** Symbolics Private ethernet protocol type.612 */613 #define ETH_P_Symbolics_Private_MIN 0x8107614 615 /** Symbolics Private ethernet protocol type.616 */617 #define ETH_P_Symbolics_Private_MAX 0x8109618 619 /** Hayes Microcomputers ethernet protocol type.620 */621 #define ETH_P_Hayes_Microcomputers 0x8130622 623 /** VG Laboratory Systems ethernet protocol type.624 */625 #define ETH_P_VG_Laboratory_Systems 0x8131626 627 /** Bridge Communications ethernet protocol type.628 */629 #define ETH_P_Bridge_Communications_MIN 0x8132630 631 /** Bridge Communications ethernet protocol type.632 */633 #define ETH_P_Bridge_Communications_MAX 0x8136634 635 /** Novell, Inc. ethernet protocol type.636 */637 #define ETH_P_Novell_Inc_MIN 0x8137638 639 /** Novell, Inc. ethernet protocol type.640 */641 #define ETH_P_Novell_Inc_MAX 0x8138642 643 /** KTI ethernet protocol type.644 */645 #define ETH_P_KTI_MIN 0x8139646 647 /** KTI ethernet protocol type.648 */649 #define ETH_P_KTI_MAX 0x813D650 651 /** Logicraft ethernet protocol type.652 */653 #define ETH_P_Logicraft 0x8148654 655 /** Network Computing Devices ethernet protocol type.656 */657 #define ETH_P_Network_Computing_Devices 0x8149658 659 /** Alpha Micro ethernet protocol type.660 */661 #define ETH_P_Alpha_Micro 0x814A662 663 /** SNMP ethernet protocol type.664 */665 #define ETH_P_SNMP 0x814C666 667 /** BIIN ethernet protocol type.668 */669 #define ETH_P_BIIN 0x814D670 671 /** BIIN ethernet protocol type.672 */673 #define ETH_P_BIIN2 0x814E674 675 /** Technically Elite Concept ethernet protocol type.676 */677 #define ETH_P_Technically_Elite_Concept 0x814F678 679 /** Rational Corp ethernet protocol type.680 */681 #define ETH_P_Rational_Corp 0x8150682 683 /** Qualcomm ethernet protocol type.684 */685 #define ETH_P_Qualcomm_MIN 0x8151686 687 /** Qualcomm ethernet protocol type.688 */689 #define ETH_P_Qualcomm_MAX 0x8153690 691 /** Computer Protocol Pty Ltd ethernet protocol type.692 */693 #define ETH_P_Computer_Protocol_Pty_Ltd_MIN 0x815C694 695 /** Computer Protocol Pty Ltd ethernet protocol type.696 */697 #define ETH_P_Computer_Protocol_Pty_Ltd_MAX 0x815E698 699 /** Charles River Data System ethernet protocol type.700 */701 #define ETH_P_Charles_River_Data_System_MIN 0x8164702 703 /** Charles River Data System ethernet protocol type.704 */705 #define ETH_P_Charles_River_Data_System_MAX 0x8166706 707 /** XTP ethernet protocol type.708 */709 #define ETH_P_XTP 0x817D710 711 /** SGI/Time Warner prop. ethernet protocol type.712 */713 #define ETH_P_SGITime_Warner_prop 0x817E714 715 /** HIPPI-FP encapsulation ethernet protocol type.716 */717 #define ETH_P_HIPPI_FP_encapsulation 0x8180718 719 /** STP, HIPPI-ST ethernet protocol type.720 */721 #define ETH_P_STP_HIPPI_ST 0x8181722 723 /** Reserved for HIPPI-6400 ethernet protocol type.724 */725 #define ETH_P_Reserved_for_HIPPI_6400 0x8182726 727 /** Reserved for HIPPI-6400 ethernet protocol type.728 */729 #define ETH_P_Reserved_for_HIPPI_64002 0x8183730 731 /** Silicon Graphics prop. ethernet protocol type.732 */733 #define ETH_P_Silicon_Graphics_prop_MIN 0x8184734 735 /** Silicon Graphics prop. ethernet protocol type.736 */737 #define ETH_P_Silicon_Graphics_prop_MAX 0x818C738 739 /** Motorola Computer ethernet protocol type.740 */741 #define ETH_P_Motorola_Computer 0x818D742 743 /** Qualcomm ethernet protocol type.744 */745 #define ETH_P_Qualcomm_MIN2 0x819A746 747 /** Qualcomm ethernet protocol type.748 */749 #define ETH_P_Qualcomm_MAX2 0x81A3750 751 /** ARAI Bunkichi ethernet protocol type.752 */753 #define ETH_P_ARAI_Bunkichi 0x81A4754 755 /** RAD Network Devices ethernet protocol type.756 */757 #define ETH_P_RAD_Network_Devices_MIN 0x81A5758 759 /** RAD Network Devices ethernet protocol type.760 */761 #define ETH_P_RAD_Network_Devices_MAX 0x81AE762 763 /** Xyplex ethernet protocol type.764 */765 #define ETH_P_Xyplex_MIN2 0x81B7766 767 /** Xyplex ethernet protocol type.768 */769 #define ETH_P_Xyplex_MAX2 0x81B9770 771 /** Apricot Computers ethernet protocol type.772 */773 #define ETH_P_Apricot_Computers_MIN 0x81CC774 775 /** Apricot Computers ethernet protocol type.776 */777 #define ETH_P_Apricot_Computers_MAX 0x81D5778 779 /** Artisoft ethernet protocol type.780 */781 #define ETH_P_Artisoft_MIN 0x81D6782 783 /** Artisoft ethernet protocol type.784 */785 #define ETH_P_Artisoft_MAX 0x81DD786 787 /** Polygon ethernet protocol type.788 */789 #define ETH_P_Polygon_MIN 0x81E6790 791 /** Polygon ethernet protocol type.792 */793 #define ETH_P_Polygon_MAX 0x81EF794 795 /** Comsat Labs ethernet protocol type.796 */797 #define ETH_P_Comsat_Labs_MIN 0x81F0798 799 /** Comsat Labs ethernet protocol type.800 */801 #define ETH_P_Comsat_Labs_MAX 0x81F2802 803 /** SAIC ethernet protocol type.804 */805 #define ETH_P_SAIC_MIN 0x81F3806 807 /** SAIC ethernet protocol type.808 */809 #define ETH_P_SAIC_MAX 0x81F5810 811 /** VG Analytical ethernet protocol type.812 */813 #define ETH_P_VG_Analytical_MIN 0x81F6814 815 /** VG Analytical ethernet protocol type.816 */817 #define ETH_P_VG_Analytical_MAX 0x81F8818 819 /** Quantum Software ethernet protocol type.820 */821 #define ETH_P_Quantum_Software_MIN 0x8203822 823 /** Quantum Software ethernet protocol type.824 */825 #define ETH_P_Quantum_Software_MAX 0x8205826 827 /** Ascom Banking Systems ethernet protocol type.828 */829 #define ETH_P_Ascom_Banking_Systems_MIN 0x8221830 831 /** Ascom Banking Systems ethernet protocol type.832 */833 #define ETH_P_Ascom_Banking_Systems_MAX 0x8222834 835 /** Advanced Encryption Syste ethernet protocol type.836 */837 #define ETH_P_Advanced_Encryption_Syste_MIN 0x823E838 839 /** Advanced Encryption Syste ethernet protocol type.840 */841 #define ETH_P_Advanced_Encryption_Syste_MAX 0x8240842 843 /** Athena Programming ethernet protocol type.844 */845 #define ETH_P_Athena_Programming_MIN 0x827F846 847 /** Athena Programming ethernet protocol type.848 */849 #define ETH_P_Athena_Programming_MAX 0x8282850 851 /** Charles River Data System ethernet protocol type.852 */853 #define ETH_P_Charles_River_Data_System_MIN2 0x8263854 855 /** Charles River Data System ethernet protocol type.856 */857 #define ETH_P_Charles_River_Data_System_MAX2 0x826A858 859 /** Inst Ind Info Tech ethernet protocol type.860 */861 #define ETH_P_Inst_Ind_Info_Tech_MIN 0x829A862 863 /** Inst Ind Info Tech ethernet protocol type.864 */865 #define ETH_P_Inst_Ind_Info_Tech_MAX 0x829B866 867 /** Taurus Controls ethernet protocol type.868 */869 #define ETH_P_Taurus_Controls_MIN 0x829C870 871 /** Taurus Controls ethernet protocol type.872 */873 #define ETH_P_Taurus_Controls_MAX 0x82AB874 875 /** Walker Richer &Quinn ethernet protocol type.876 */877 #define ETH_P_Walker_Richer_Quinn_MIN 0x82AC878 879 /** Walker Richer &Quinn ethernet protocol type.880 */881 #define ETH_P_Walker_Richer_Quinn_MAX 0x8693882 883 /** Idea Courier ethernet protocol type.884 */885 #define ETH_P_Idea_Courier_MIN 0x8694886 887 /** Idea Courier ethernet protocol type.888 */889 #define ETH_P_Idea_Courier_MAX 0x869D890 891 /** Computer Network Tech ethernet protocol type.892 */893 #define ETH_P_Computer_Network_Tech_MIN 0x869E894 895 /** Computer Network Tech ethernet protocol type.896 */897 #define ETH_P_Computer_Network_Tech_MAX 0x86A1898 899 /** Gateway Communications ethernet protocol type.900 */901 #define ETH_P_Gateway_Communications_MIN 0x86A3902 903 /** Gateway Communications ethernet protocol type.904 */905 #define ETH_P_Gateway_Communications_MAX 0x86AC906 907 /** SECTRA ethernet protocol type.908 */909 #define ETH_P_SECTRA 0x86DB910 911 /** Delta Controls ethernet protocol type.912 */913 #define ETH_P_Delta_Controls 0x86DE914 915 /** IPv6 ethernet protocol type.916 */917 #define ETH_P_IPV6 0x86DD918 919 /** ATOMIC ethernet protocol type.920 */921 #define ETH_P_ATOMIC 0x86DF922 923 /** Landis &Gyr Powers ethernet protocol type.924 */925 #define ETH_P_Landis_Gyr_Powers_MIN 0x86E0926 927 /** Landis &Gyr Powers ethernet protocol type.928 */929 #define ETH_P_Landis_Gyr_Powers_MAX 0x86EF930 931 /** Motorola ethernet protocol type.932 */933 #define ETH_P_Motorola_MIN 0x8700934 935 /** Motorola ethernet protocol type.936 */937 #define ETH_P_Motorola_MAX 0x8710938 939 /** TCP/IP Compression ethernet protocol type.940 */941 #define ETH_P_TCPIP_Compression 0x876B942 943 /** IP Autonomous Systems ethernet protocol type.944 */945 #define ETH_P_IP_Autonomous_Systems 0x876C946 947 /** Secure Data ethernet protocol type.948 */949 #define ETH_P_Secure_Data 0x876D950 951 /** PPP ethernet protocol type.952 */953 #define ETH_P_PPP 0x880B954 955 /** MPLS ethernet protocol type.956 */957 #define ETH_P_MPLS_UC 0x8847958 959 /** MPLS with upstream-assigned label ethernet protocol type.960 */961 #define ETH_P_MPLS_MC 0x8848962 963 /** Invisible Software ethernet protocol type.964 */965 #define ETH_P_Invisible_Software_MIN 0x8A96966 967 /** Invisible Software ethernet protocol type.968 */969 #define ETH_P_Invisible_Software_MAX 0x8A97970 971 /** PPPoE Discovery Stage ethernet protocol type.972 */973 #define ETH_P_PPP_DISC 0x8863974 975 /** PPPoE Session Stage ethernet protocol type.976 */977 #define ETH_P_PPP_SES 0x8864978 979 /** Loopback ethernet protocol type.980 */981 #define ETH_P_Loopback 0x9000982 983 /** Com(Bridge) XNS Sys Mgmt ethernet protocol type.984 */985 #define ETH_P_Com_XNS_Sys_Mgmt 0x9001986 987 /** Com(Bridge) TCP-IP Sys ethernet protocol type.988 */989 #define ETH_P_Com_TCP_IP_Sys 0x9002990 991 /** Com(Bridge) loop detect ethernet protocol type.992 */993 #define ETH_P_Com_loop_detect 0x9003994 995 /** BBN VITAL-LanBridge cache ethernet protocol type.996 */997 #define ETH_P_BBN_VITAL_LanBridge_cache 0xFF00998 999 /** ISC Bunker Ramo ethernet protocol type.1000 */1001 #define ETH_P_ISC_Bunker_Ramo_MIN 0xFF001002 1003 /** ISC Bunker Ramo ethernet protocol type.1004 */1005 #define ETH_P_ISC_Bunker_Ramo_MAX 0xFF0F1006 60 1007 61 /*@}*/ -
uspace/lib/net/include/generic.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP application interface implementation. 35 * @see icmp_api.h 34 * Generic communication interfaces for networking. 36 35 */ 37 36 37 #ifndef LIBNET_GENERIC_H_ 38 #define LIBNET_GENERIC_H_ 39 38 40 #include <async.h> 39 40 41 #include <ipc/ipc.h> 41 42 #include <ipc/services.h> 42 43 43 #include <sys/types.h> 44 #include <net/device.h> 45 #include <adt/measured_strings.h> 46 #include <net/packet.h> 44 47 45 #include <net_modules.h> 46 #include <icmp_api.h> 47 #include <inet.h> 48 #include <ip_codes.h> 49 #include <socket_codes.h> 50 #include <icmp_messages.h> 48 extern int generic_device_state_msg_remote(int, int, device_id_t, int, 49 services_t); 50 extern int generic_device_req_remote(int, int, device_id_t, int, services_t); 51 extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **, 52 char **); 53 extern int generic_packet_size_req_remote(int, int, device_id_t, 54 packet_dimension_t *); 55 extern int generic_received_msg_remote(int, int, device_id_t, packet_id_t, 56 services_t, services_t); 57 extern int generic_send_msg_remote(int, int, device_id_t, packet_id_t, 58 services_t, services_t); 59 extern int generic_translate_req(int, int, device_id_t, services_t, 60 measured_string_t *, size_t, measured_string_t **, char **); 51 61 52 int icmp_echo_msg(int icmp_phone, size_t size, mseconds_t timeout, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, const struct sockaddr * addr, socklen_t addrlen){ 53 aid_t message_id; 54 ipcarg_t result; 55 56 if(addrlen <= 0){ 57 return EINVAL; 58 } 59 message_id = async_send_5(icmp_phone, NET_ICMP_ECHO, size, timeout, ttl, tos, (ipcarg_t) dont_fragment, NULL); 60 // send the address 61 async_data_write_start(icmp_phone, addr, (size_t) addrlen); 62 // timeout version may cause inconsistency - there is also an inner timer 63 // return async_wait_timeout(message_id, &result, timeout); 64 async_wait_for(message_id, &result); 65 return (int) result; 66 } 62 #endif 67 63 68 64 /** @} -
uspace/lib/net/include/icmp_client.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP client interface.34 * ICMP client interface. 35 35 */ 36 36 37 #ifndef __NET_ICMP_CLIENT_H__38 #define __NET_ICMP_CLIENT_H__37 #ifndef LIBNET_ICMP_CLIENT_H_ 38 #define LIBNET_ICMP_CLIENT_H_ 39 39 40 #include < icmp_codes.h>41 #include < packet/packet.h>40 #include <net/icmp_codes.h> 41 #include <net/packet.h> 42 42 43 /** Processes the received packet prefixed with an ICMP header. 44 * @param[in] packet The received packet. 45 * @param[out] type The ICMP header type. 46 * @param[out] code The ICMP header code. 47 * @param[out] pointer The ICMP header pointer. 48 * @param[out] mtu The ICMP header MTU. 49 * @returns The ICMP header length. 50 * @returns Zero (0) if the packet contains no data. 51 */ 52 extern int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu); 53 54 /** Returns the ICMP header length. 55 * @param[in] packet The packet. 56 * @returns The ICMP header length in bytes. 57 */ 58 extern size_t icmp_client_header_length(packet_t packet); 43 extern int icmp_client_process_packet(packet_t *, icmp_type_t *, icmp_code_t *, 44 icmp_param_t *, icmp_param_t *); 45 extern size_t icmp_client_header_length(packet_t *); 59 46 60 47 #endif -
uspace/lib/net/include/icmp_header.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP header definition.35 * Based on the RFC~792.34 * ICMP header definition. 35 * Based on the RFC 792. 36 36 */ 37 37 38 #ifndef __NET_ICMP_HEADER_H__39 #define __NET_ICMP_HEADER_H__38 #ifndef LIBNET_ICMP_HEADER_H_ 39 #define LIBNET_ICMP_HEADER_H_ 40 40 41 41 #include <sys/types.h> 42 42 43 #include < in.h>44 #include < icmp_codes.h>43 #include <net/in.h> 44 #include <net/icmp_codes.h> 45 45 46 /** ICMP header size in bytes. 47 */ 48 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 46 /** ICMP header size in bytes. */ 47 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 49 48 50 49 /** Type definition of the echo specific data. 51 * @see icmp_echo50 * @see icmp_echo 52 51 */ 53 typedef struct icmp_echo icmp_echo_t;52 typedef struct icmp_echo icmp_echo_t; 54 53 55 /** Type definition of the echo specific data pointer. 56 * @see icmp_echo 57 */ 58 typedef icmp_echo_t * icmp_echo_ref; 59 60 /** Echo specific data. 61 */ 62 struct icmp_echo{ 63 /** Message idintifier. 64 */ 54 /** Echo specific data. */ 55 struct icmp_echo { 56 /** Message idintifier. */ 65 57 icmp_param_t identifier; 66 /** Message sequence number. 67 */ 58 /** Message sequence number. */ 68 59 icmp_param_t sequence_number; 69 60 } __attribute__ ((packed)); 70 61 71 62 /** Type definition of the internet control message header. 72 * @see icmp_header63 * @see icmp_header 73 64 */ 74 typedef struct icmp_header icmp_header_t;65 typedef struct icmp_header icmp_header_t; 75 66 76 /** Type definition of the internet control message header pointer. 77 * @see icmp_header 78 */ 79 typedef icmp_header_t * icmp_header_ref; 80 81 /** Internet control message header. 82 */ 83 struct icmp_header{ 84 /** The type of the message. 85 */ 67 /** Internet control message header. */ 68 struct icmp_header { 69 /** The type of the message. */ 86 70 uint8_t type; 87 /** The error code for the datagram reported by the ICMP message. 88 * The interpretation is dependent on the message type. 71 72 /** 73 * The error code for the datagram reported by the ICMP message. 74 * The interpretation is dependent on the message type. 89 75 */ 90 76 uint8_t code; 91 /** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type. 92 * For computing the checksum, the checksum field should be zero. 93 * If the checksum does not match the contents, the datagram is discarded. 77 78 /** 79 * The checksum is the 16-bit ones's complement of the one's complement 80 * sum of the ICMP message starting with the ICMP Type. For computing 81 * the checksum, the checksum field should be zero. If the checksum does 82 * not match the contents, the datagram is discarded. 94 83 */ 95 84 uint16_t checksum; 96 /** Message specific data. 97 */ 98 union{ 99 /** Echo specific data. 100 */ 85 86 /** Message specific data. */ 87 union { 88 /** Echo specific data. */ 101 89 icmp_echo_t echo; 102 /** Proposed gateway value. 103 */ 90 /** Proposed gateway value. */ 104 91 in_addr_t gateway; 105 /** Fragmentation needed specific data. 106 */ 107 struct{ 108 /** Reserved field. 109 * Must be zero. 110 */ 92 93 /** Fragmentation needed specific data. */ 94 struct { 95 /** Reserved field. Must be zero. */ 111 96 icmp_param_t reserved; 112 /** Proposed MTU. 113 */ 97 /** Proposed MTU. */ 114 98 icmp_param_t mtu; 115 99 } frag; 116 /** Parameter problem specific data. 117 */ 118 struct{ 119 /** Problem pointer. 120 */ 100 101 /** Parameter problem specific data. */ 102 struct { 103 /** Problem pointer. */ 121 104 icmp_param_t pointer; 122 /** Reserved field. 123 * Must be zero. 124 */ 105 /** Reserved field. Must be zero. */ 125 106 icmp_param_t reserved; 126 107 } param; -
uspace/lib/net/include/icmp_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_ICMP_INTERFACE_H__34 #define __NET_ICMP_INTERFACE_H__33 #ifndef LIBNET_ICMP_INTERFACE_H_ 34 #define LIBNET_ICMP_INTERFACE_H_ 35 35 36 #include <net/socket_codes.h> 36 37 #include <sys/types.h> 37 38 38 #include <net _device.h>39 #include <net/device.h> 39 40 #include <adt/measured_strings.h> 40 #include <packet/packet.h> 41 #include <inet.h> 42 #include <ip_codes.h> 43 #include <socket_codes.h> 44 #include <icmp_codes.h> 45 #include <icmp_common.h> 41 #include <net/packet.h> 42 #include <net/inet.h> 43 #include <net/ip_codes.h> 44 #include <net/icmp_codes.h> 45 #include <net/icmp_common.h> 46 46 47 47 /** @name ICMP module interface 48 * This interface is used by other modules.48 * This interface is used by other modules. 49 49 */ 50 50 /*@{*/ 51 51 52 /** Sends the Destination Unreachable error notification packet. 53 * Beginning of the packet is sent as the notification packet data. 54 * The source and the destination addresses should be set in the original packet. 55 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 56 * @param[in] code The error specific code. 57 * @param[in] mtu The error MTU value. 58 * @param[in] packet The original packet. 59 * @returns EOK on success. 60 * @returns EPERM if the ICMP error notifications are disabled. 61 * @returns ENOMEM if there is not enough memory left. 62 */ 63 extern int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet); 64 65 /** Sends the Source Quench error notification packet. 66 * Beginning of the packet is sent as the notification packet data. 67 * The source and the destination addresses should be set in the original packet. 68 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 69 * @param[in] packet The original packet. 70 * @returns EOK on success. 71 * @returns EPERM if the ICMP error notifications are disabled. 72 * @returns ENOMEM if there is not enough memory left. 73 */ 74 extern int icmp_source_quench_msg(int icmp_phone, packet_t packet); 75 76 /** Sends the Time Exceeded error notification packet. 77 * Beginning of the packet is sent as the notification packet data. 78 * The source and the destination addresses should be set in the original packet. 79 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 80 * @param[in] code The error specific code. 81 * @param[in] packet The original packet. 82 * @returns EOK on success. 83 * @returns EPERM if the ICMP error notifications are disabled. 84 * @returns ENOMEM if there is not enough memory left. 85 */ 86 extern int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet); 87 88 /** Sends the Parameter Problem error notification packet. 89 * Beginning of the packet is sent as the notification packet data. 90 * The source and the destination addresses should be set in the original packet. 91 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 92 * @param[in] code The error specific code. 93 * @param[in] pointer The problematic parameter offset. 94 * @param[in] packet The original packet. 95 * @returns EOK on success. 96 * @returns EPERM if the ICMP error notifications are disabled. 97 * @returns ENOMEM if there is not enough memory left. 98 */ 99 extern int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet); 52 extern int icmp_destination_unreachable_msg(int, icmp_code_t, icmp_param_t, 53 packet_t *); 54 extern int icmp_source_quench_msg(int, packet_t *); 55 extern int icmp_time_exceeded_msg(int, icmp_code_t, packet_t *); 56 extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t, packet_t *); 100 57 101 58 /*@}*/ -
uspace/lib/net/include/il_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_il30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Internetwork layer module interface for the underlying network interface layer.35 * This interface is always called by the remote modules.34 * Internetwork layer module interface for the underlying network interface 35 * layer. This interface is always called by the remote modules. 36 36 */ 37 37 38 #ifndef __NET_IL_INTERFACE_H__ 39 #define __NET_IL_INTERFACE_H__ 40 41 #include <async.h> 38 #ifndef LIBNET_IL_INTERFACE_H_ 39 #define LIBNET_IL_INTERFACE_H_ 42 40 43 41 #include <ipc/services.h> 42 #include <sys/types.h> 44 43 45 #include <net_messages.h> 46 #include <net_device.h> 47 #include <packet/packet.h> 48 #include <packet/packet_client.h> 49 #include <il_messages.h> 44 #include <net/device.h> 45 #include <net/packet.h> 50 46 51 47 /** @name Internetwork layer module interface … … 54 50 /*@{*/ 55 51 56 /** Notify the internetwork layer modules about the device state change. 57 * 58 * @param[in] il_phone The internetwork layer module phone used for 59 * (semi)remote calls. 60 * @param[in] device_id The device identifier. 61 * @param[in] state The new device state. 62 * @param[in] target The target internetwork module service to be 63 * delivered to. 64 * 65 * @return EOK on success. 66 * 67 */ 68 static inline int il_device_state_msg(int il_phone, device_id_t device_id, 69 device_state_t state, services_t target) 70 { 71 return generic_device_state_msg_remote(il_phone, NET_IL_DEVICE_STATE, 72 device_id, state, target); 73 } 74 75 /** Notify the internetwork layer modules about the received packet/s. 76 * 77 * @param[in] il_phone The internetwork layer module phone used for 78 * (semi)remote calls. 79 * @param[in] device_id The device identifier. 80 * @param[in] packet The received packet or the received packet queue. 81 * @param[in] target The target internetwork module service to be 82 * delivered to. 83 * 84 * @return EOK on success. 85 * 86 */ 87 inline static int il_received_msg(int il_phone, device_id_t device_id, 88 packet_t packet, services_t target) 89 { 90 return generic_received_msg_remote(il_phone, NET_IL_RECEIVED, device_id, 91 packet_get_id(packet), target, 0); 92 } 93 94 /** Notify the internetwork layer modules about the mtu change. 95 * 96 * @param[in] il_phone The internetwork layer module phone used for 97 * (semi)remote calls. 98 * @param[in] device_id The device identifier. 99 * @param[in] mtu The new mtu value. 100 * @param[in] target The target internetwork module service to be 101 * delivered to. 102 * 103 * @return EOK on success. 104 * 105 */ 106 inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id, 107 size_t mtu, services_t target) 108 { 109 return generic_device_state_msg_remote(il_phone, NET_IL_MTU_CHANGED, 110 device_id, (int) mtu, target); 111 } 52 extern int il_device_state_msg(int, device_id_t, device_state_t, services_t); 53 extern int il_received_msg(int, device_id_t, packet_t *, services_t); 54 extern int il_mtu_changed_msg(int, device_id_t, size_t, services_t); 112 55 113 56 /*@}*/ -
uspace/lib/net/include/il_local.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup il_local30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __IL_LOCAL_H__34 #define __IL_LOCAL_H__33 #ifndef LIBNET_IL_LOCAL_H_ 34 #define LIBNET_IL_LOCAL_H_ 35 35 36 36 #include <ipc/ipc.h> 37 37 #include <async.h> 38 38 39 /** Processes the Internet layer module message. 40 * 41 * @param[in] callid The message identifier. 42 * @param[in] call The message parameters. 43 * @param[out] answer The message answer parameters. 44 * @param[out] answer_count The last parameter for the actual answer in 45 * the answer parameter. 46 * @return EOK on success. 47 * @return Other error codes as defined for the arp_message() 48 * function. 49 */ 39 50 extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call, 40 51 ipc_call_t *answer, int *answer_count); 52 53 /** Starts the Internet layer module. 54 * 55 * Initializes the client connection servicing function, initializes the module, 56 * registers the module service and starts the async manager, processing IPC 57 * messages in an infinite loop. 58 * 59 * @param[in] client_connection The client connection processing function. The 60 * module skeleton propagates its own one. 61 * @return EOK on successful module termination. 62 * @return Other error codes as defined for the arp_initialize() 63 * function. 64 * @return Other error codes as defined for the REGISTER_ME() macro 65 * function. 66 */ 41 67 extern int il_module_start_standalone(async_client_conn_t client_connection); 42 68 -
uspace/lib/net/include/ip_client.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * IP client interface.34 * IP client interface. 35 35 */ 36 36 37 #ifndef __NET_IP_CLIENT_H__38 #define __NET_IP_CLIENT_H__37 #ifndef LIBNET_IP_CLIENT_H_ 38 #define LIBNET_IP_CLIENT_H_ 39 39 40 #include <net/socket_codes.h> 40 41 #include <sys/types.h> 41 42 42 #include < packet/packet.h>43 #include < ip_codes.h>43 #include <net/packet.h> 44 #include <net/ip_codes.h> 44 45 #include <ip_interface.h> 45 #include <socket_codes.h>46 46 47 /** Prepares the packet to be transfered via IP. 48 * The IP header is prefixed. 49 * @param[in,out] packet The packet to be prepared. 50 * @param[in] protocol The transport protocol. 51 * @param[in] ttl The time to live counter. The IPDEFTTL is set if zero (0). 52 * @param[in] tos The type of service. 53 * @param[in] dont_fragment The value indicating whether fragmentation is disabled. 54 * @param[in] ipopt_length The prefixed IP options length in bytes. 55 * @returns EOK on success. 56 * @returns ENOMEM if there is not enough memory left in the packet. 57 */ 58 extern int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length); 59 60 /** Processes the received IP packet. 61 * Fills set header fields. 62 * Returns the prefixed IP header length. 63 * @param[in] packet The received packet. 64 * @param[out] protocol The transport protocol. May be NULL if not desired. 65 * @param[out] ttl The time to live counter. May be NULL if not desired. 66 * @param[out] tos The type of service. May be NULL if not desired. 67 * @param[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired. 68 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not desired. 69 * @returns The prefixed IP header length in bytes on success. 70 * @returns ENOMEM if the packet is too short to contain the IP header. 71 */ 72 extern int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length); 73 74 /** Returns the IP header length. 75 * @param[in] packet The packet. 76 * @returns The IP header length in bytes. 77 * @returns Zero (0) if there is no IP header. 78 */ 79 extern size_t ip_client_header_length(packet_t packet); 80 81 /** Updates the IPv4 pseudo header data length field. 82 * @param[in,out] header The IPv4 pseudo header to be updated. 83 * @param[in] headerlen The length of the IP pseudo header in bytes. 84 * @param[in] data_length The data length to be set. 85 * @returns EOK on success. 86 * @returns EBADMEM if the header parameter is NULL. 87 * @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length. 88 */ 89 extern int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length); 90 91 /** Constructs the IPv4 pseudo header. 92 * @param[in] protocol The transport protocol. 93 * @param[in] src The source address. 94 * @param[in] srclen The source address length. 95 * @param[in] dest The destination address. 96 * @param[in] destlen The destination address length. 97 * @param[in] data_length The data length to be set. 98 * @param[out] header The constructed IPv4 pseudo header. 99 * @param[out] headerlen The length of the IP pseudo header in bytes. 100 * @returns EOK on success. 101 * @returns EBADMEM if the header and/or the headerlen parameter is NULL. 102 * @returns EINVAL if the source address and/or the destination address parameter is NULL. 103 * @returns EINVAL if the source address length is less than struct sockaddr length. 104 * @returns EINVAL if the source address length differs from the destination address length. 105 * @returns EINVAL if the source address family differs from the destination family. 106 * @returns EAFNOSUPPORT if the address family is not supported. 107 * @returns ENOMEM if there is not enough memory left. 108 */ 109 extern int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen); 47 extern int ip_client_prepare_packet(packet_t *, ip_protocol_t, ip_ttl_t, 48 ip_tos_t, int, size_t); 49 extern int ip_client_process_packet(packet_t *, ip_protocol_t *, ip_ttl_t *, 50 ip_tos_t *, int *, size_t *); 51 extern size_t ip_client_header_length(packet_t *); 52 extern int ip_client_set_pseudo_header_data_length(void *, size_t, size_t); 53 extern int ip_client_get_pseudo_header(ip_protocol_t, struct sockaddr *, 54 socklen_t, struct sockaddr *, socklen_t, size_t, void **, size_t *); 110 55 111 56 // TODO ipopt manipulation -
uspace/lib/net/include/ip_header.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * IP header and options definitions.35 * Based on the RFC~791.36 */ 37 38 #ifndef __NET_IP_HEADER_H__39 #define __NET_IP_HEADER_H__34 * IP header and options definitions. 35 * Based on the RFC 791. 36 */ 37 38 #ifndef LIBNET_IP_HEADER_H_ 39 #define LIBNET_IP_HEADER_H_ 40 40 41 41 #include <byteorder.h> … … 43 43 44 44 /** Returns the fragment offest high bits. 45 * @param[in] length The prefixed data total length. 46 */ 47 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8) 45 * @param[in] length The prefixed data total length. 46 */ 47 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) \ 48 ((((length) / 8U) & 0x1f00) >> 8) 48 49 49 50 /** Returns the fragment offest low bits. 50 * @param[in] length The prefixed data total length. 51 */ 52 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF) 51 * @param[in] length The prefixed data total length. 52 */ 53 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) \ 54 (((length) / 8U) & 0xff) 53 55 54 56 /** Returns the IP header length. 55 * @param[in] length The IP header length in bytes. 56 */ 57 #define IP_COMPUTE_HEADER_LENGTH(length) ((uint8_t) ((length) / 4u)) 57 * @param[in] length The IP header length in bytes. 58 */ 59 #define IP_COMPUTE_HEADER_LENGTH(length) \ 60 ((uint8_t) ((length) / 4U)) 58 61 59 62 /** Returns the fragment offest. 60 * @param[in] header The IP packet header. 61 */ 62 #define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u) 63 * @param[in] header The IP packet header. 64 */ 65 #define IP_FRAGMENT_OFFSET(header) \ 66 ((((header)->fragment_offset_high << 8) + \ 67 (header)->fragment_offset_low) * 8U) 63 68 64 69 /** Returns the IP packet header checksum. 65 70 * @param[in] header The IP packet header. 66 71 */ 67 #define IP_HEADER_CHECKSUM(header) (htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header)))) 72 #define IP_HEADER_CHECKSUM(header) \ 73 (htons(ip_checksum((uint8_t *) (header), IP_HEADER_LENGTH(header)))) 68 74 69 75 /** Returns the actual IP packet data length. 70 * @param[in] header The IP packet header. 71 */ 72 #define IP_HEADER_DATA_LENGTH(header) (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header)) 76 * @param[in] header The IP packet header. 77 */ 78 #define IP_HEADER_DATA_LENGTH(header) \ 79 (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header)) 73 80 74 81 /** Returns the actual IP header length in bytes. 75 * @param[in] header The IP packet header. 76 */ 77 #define IP_HEADER_LENGTH(header) ((header)->header_length * 4u) 82 * @param[in] header The IP packet header. 83 */ 84 #define IP_HEADER_LENGTH(header) \ 85 ((header)->header_length * 4U) 78 86 79 87 /** Returns the actual IP packet total length. 80 * @param[in] header The IP packet header.81 */ 82 #define IP_TOTAL_LENGTH(header) ntohs((header)->total_length)83 84 /** @name IP flags definitions 85 */88 * @param[in] header The IP packet header. 89 */ 90 #define IP_TOTAL_LENGTH(header) \ 91 ntohs((header)->total_length) 92 93 /** @name IP flags definitions */ 86 94 /*@{*/ 87 95 88 /** Fragment flag field shift. 89 */ 90 #define IPFLAG_FRAGMENT_SHIFT 1 91 92 /** Fragmented flag field shift. 93 */ 94 #define IPFLAG_FRAGMENTED_SHIFT 0 96 /** Fragment flag field shift. */ 97 #define IPFLAG_FRAGMENT_SHIFT 1 98 99 /** Fragmented flag field shift. */ 100 #define IPFLAG_FRAGMENTED_SHIFT 0 95 101 96 102 /** Don't fragment flag value. 97 * Permits the packet fragmentation.98 */ 99 #define IPFLAG_DONT_FRAGMENT (0x1 << IPFLAG_FRAGMENT_SHIFT)103 * Permits the packet fragmentation. 104 */ 105 #define IPFLAG_DONT_FRAGMENT (0x1 << IPFLAG_FRAGMENT_SHIFT) 100 106 101 107 /** Last fragment flag value. 102 * Indicates the last packet fragment.103 */ 104 #define IPFLAG_LAST_FRAGMENT (0x0 << IPFLAG_FRAGMENTED_SHIFT)108 * Indicates the last packet fragment. 109 */ 110 #define IPFLAG_LAST_FRAGMENT (0x0 << IPFLAG_FRAGMENTED_SHIFT) 105 111 106 112 /** May fragment flag value. 107 * Allows the packet fragmentation.108 */ 109 #define IPFLAG_MAY_FRAGMENT (0x0 << IPFLAG_FRAGMENT_SHIFT)113 * Allows the packet fragmentation. 114 */ 115 #define IPFLAG_MAY_FRAGMENT (0x0 << IPFLAG_FRAGMENT_SHIFT) 110 116 111 117 /** More fragments flag value. 112 * Indicates that more packet fragments follow.113 */ 114 #define IPFLAG_MORE_FRAGMENTS (0x1 << IPFLAG_FRAGMENTED_SHIFT)118 * Indicates that more packet fragments follow. 119 */ 120 #define IPFLAG_MORE_FRAGMENTS (0x1 << IPFLAG_FRAGMENTED_SHIFT) 115 121 116 122 /*@}*/ 117 123 118 124 /** Type definition of the internet header. 119 * @see ip_header 120 */ 121 typedef struct ip_header ip_header_t; 122 123 /** Type definition of the internet header pointer. 124 * @see ip_header 125 */ 126 typedef ip_header_t * ip_header_ref; 125 * @see ip_header 126 */ 127 typedef struct ip_header ip_header_t; 127 128 128 129 /** Type definition of the internet option header. 129 * @see ip_header 130 */ 131 typedef struct ip_option ip_option_t; 132 133 /** Type definition of the internet option header pointer. 134 * @see ip_header 135 */ 136 typedef ip_option_t * ip_option_ref; 130 * @see ip_header 131 */ 132 typedef struct ip_option ip_option_t; 137 133 138 134 /** Type definition of the internet version 4 pseudo header. 139 * @see ipv4_pseudo_header 140 */ 141 typedef struct ipv4_pseudo_header ipv4_pseudo_header_t; 142 143 /** Type definition of the internet version 4 pseudo header pointer. 144 * @see ipv4_pseudo_header 145 */ 146 typedef ipv4_pseudo_header_t * ipv4_pseudo_header_ref; 135 * @see ipv4_pseudo_header 136 */ 137 typedef struct ipv4_pseudo_header ipv4_pseudo_header_t; 147 138 148 139 /** Internet header. 149 * The variable options should be included after the header itself and indicated by the increased header length value. 150 */ 151 struct ip_header{ 140 * 141 * The variable options should be included after the header itself and 142 * indicated by the increased header length value. 143 */ 144 struct ip_header { 152 145 #ifdef ARCH_IS_BIG_ENDIAN 153 /** The Version field indicates the format of the internet header. 154 */ 155 uint8_t version:4; 156 /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. 157 * Note that the minimum value for a~correct header is~5. 158 */ 159 uint8_t header_length:4; 146 uint8_t version : 4; 147 uint8_t header_length : 4; 160 148 #else 161 /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data. 162 * Note that the minimum value for a~correct header is~5. 163 */ 164 uint8_t header_length:4; 165 /** The Version field indicates the format of the internet header. 166 */ 167 uint8_t version:4; 168 #endif 169 /** The Type of Service provides an indication of the abstract parameters of the quality of service desired. 170 * These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network. 171 * Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load). 172 * The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput. 173 */ 149 uint8_t header_length : 4; 150 uint8_t version : 4; 151 #endif 152 174 153 uint8_t tos; 175 /** Total Length is the length of the datagram, measured in octets, including internet header and data.176 * This field allows the length of a~datagram to be up to 65,535~octets.177 */178 154 uint16_t total_length; 179 /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.180 */181 155 uint16_t identification; 156 182 157 #ifdef ARCH_IS_BIG_ENDIAN 183 /** Various control flags. 184 */ 185 uint8_t flags:3; 186 /** This field indicates where in the datagram this fragment belongs. 187 * High bits. 188 */ 189 uint8_t fragment_offset_high:5; 158 uint8_t flags : 3; 159 uint8_t fragment_offset_high : 5; 190 160 #else 191 /** This field indicates where in the datagram this fragment belongs. 192 * High bits. 193 */ 194 uint8_t fragment_offset_high:5; 195 /** Various control flags. 196 */ 197 uint8_t flags:3; 198 #endif 199 /** This field indicates where in the datagram this fragment belongs. 200 * Low bits. 201 */ 161 uint8_t fragment_offset_high : 5; 162 uint8_t flags : 3; 163 #endif 164 202 165 uint8_t fragment_offset_low; 203 /** This field indicates the maximum time the datagram is allowed to remain in the internet system.204 * If this field contains the value zero, then the datagram must be destroyed.205 * This field is modified in internet header processing.206 * The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist.207 * The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.208 */209 166 uint8_t ttl; 210 /** This field indicates the next level protocol used in the data portion of the internet datagram.211 */212 167 uint8_t protocol; 213 /** A checksum of the header only.214 * Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.215 * The checksum algorithm is: The checksum field is the 16~bit one's complement of the one's complement sum of all 16~bit words in the header.216 * For purposes of computing the checksum, the value of the checksum field is zero.217 */218 168 uint16_t header_checksum; 219 /** The source address.220 */221 169 uint32_t source_address; 222 /** The destination address.223 */224 170 uint32_t destination_address; 225 171 } __attribute__ ((packed)); 226 172 227 173 /** Internet option header. 228 * Only type field is always valid. 229 * Other fields' validity depends on the option type. 230 */ 231 struct ip_option{ 232 /** A single octet of option-type. 233 */ 174 * 175 * Only type field is always valid. 176 * Other fields' validity depends on the option type. 177 */ 178 struct ip_option { 234 179 uint8_t type; 235 /** An option length octet.236 */237 180 uint8_t length; 238 /** A~pointer.239 */240 181 uint8_t pointer; 182 241 183 #ifdef ARCH_IS_BIG_ENDIAN 242 /** The number of IP modules that cannot register timestamps due to lack of space. 243 */ 244 uint8_t overflow:4; 245 /** Various internet timestamp control flags. 246 */ 247 uint8_t flags:4; 184 uint8_t overflow : 4; 185 uint8_t flags : 4; 248 186 #else 249 /** Various internet timestamp control flags. 250 */ 251 uint8_t flags:4; 252 /** The number of IP modules that cannot register timestamps due to lack of space. 253 */ 254 uint8_t overflow:4; 187 uint8_t flags : 4; 188 uint8_t overflow : 4; 255 189 #endif 256 190 } __attribute__ ((packed)); 257 191 258 /** Internet version 4 pseudo header. 259 */ 260 struct ipv4_pseudo_header{ 261 /** The source address. 262 */ 192 /** Internet version 4 pseudo header. */ 193 struct ipv4_pseudo_header { 263 194 uint32_t source_address; 264 /** The destination address.265 */266 195 uint32_t destination_address; 267 /** Reserved byte.268 * Must be zero.269 */270 196 uint8_t reserved; 271 /** This field indicates the next level protocol used in the data portion of the internet datagram.272 */273 197 uint8_t protocol; 274 /** Data length is the length of the datagram, measured in octets.275 */276 198 uint16_t data_length; 277 199 } __attribute__ ((packed)); -
uspace/lib/net/include/ip_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_IP_INTERFACE_H__34 #define __NET_IP_INTERFACE_H__33 #ifndef LIBNET_IP_INTERFACE_H_ 34 #define LIBNET_IP_INTERFACE_H_ 35 35 36 #include <net/socket_codes.h> 36 37 #include <async.h> 37 38 #include <ipc/services.h> 38 39 39 #include <net _device.h>40 #include < packet/packet.h>40 #include <net/device.h> 41 #include <net/packet.h> 41 42 42 #include <in.h> 43 #include <ip_codes.h> 44 #include <socket_codes.h> 45 46 #ifdef CONFIG_IL_TL_BUNDLE 47 48 #include <ip_local.h> 49 50 #define ip_received_error_msg ip_received_error_msg_local 51 #define ip_set_gateway_req ip_set_gateway_req_local 52 #define ip_packet_size_req ip_packet_size_req_local 53 #define ip_device_req ip_device_req_local 54 #define ip_add_route_req ip_add_route_req_local 55 #define ip_send_msg ip_send_msg_local 56 #define ip_get_route_req ip_get_route_req_local 57 58 #else 43 #include <net/in.h> 44 #include <net/ip_codes.h> 59 45 60 46 #include <ip_remote.h> … … 68 54 #define ip_get_route_req ip_get_route_req_remote 69 55 70 #endif71 72 56 /** @name IP module interface 73 * This interface is used by other modules.57 * This interface is used by other modules. 74 58 */ 75 59 /*@{*/ 76 60 77 61 /** The transport layer notification function type definition. 78 * Notifies the transport layer modules about the received packet/s. 79 * @param[in] device_id The device identifier. 80 * @param[in] packet The received packet or the received packet queue. 81 * @param[in] receiver The receiving module service. 82 * @param[in] error The packet error reporting service. Prefixes the received packet. 83 * @returns EOK on success. 62 * 63 * Notifies the transport layer modules about the received packet/s. 64 * 65 * @param[in] device_id The device identifier. 66 * @param[in] packet The received packet or the received packet queue. 67 * @param[in] receiver The receiving module service. 68 * @param[in] error The packet error reporting service. Prefixes the 69 * received packet. 70 * @return EOK on success. 84 71 */ 85 typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t packet, services_t receiver, services_t error); 72 typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t *packet, 73 services_t receiver, services_t error); 86 74 87 /** Creates bidirectional connection with the ip module service and registers the message receiver. 88 * @param[in] service The IP module service. 89 * @param[in] protocol The transport layer protocol. 90 * @param[in] me The requesting module service. 91 * @param[in] receiver The message receiver. Used for remote connection. 92 * @param[in] tl_received_msg The message processing function. Used if bundled together. 93 * @returns The phone of the needed service. 94 * @returns EOK on success. 95 * @returns Other error codes as defined for the bind_service() function. 96 */ 97 extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg); 98 99 /** Connects to the IP module. 100 * @param service The IP module service. Ignored parameter. 101 * @returns The IP module phone on success. 102 * @returns 0 if called by the bundle module. 103 */ 104 extern int ip_connect_module(services_t service); 75 extern int ip_bind_service(services_t, int, services_t, async_client_conn_t); 76 extern int ip_connect_module(services_t); 105 77 106 78 /*@}*/ -
uspace/lib/net/include/ip_remote.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup ip29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_IP_REMOTE_H__34 #define __NET_IP_REMOTE_H__33 #ifndef LIBNET_IP_REMOTE_H_ 34 #define LIBNET_IP_REMOTE_H_ 35 35 36 #include <async.h>37 36 #include <ipc/services.h> 38 37 39 #include <ip_codes.h> 40 #include <inet.h> 41 #include <in.h> 42 #include <socket.h> 38 #include <net/ip_codes.h> 39 #include <net/inet.h> 40 #include <net/in.h> 41 #include <net/packet.h> 42 #include <net/device.h> 43 #include <net/socket.h> 43 44 44 45 extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t); 45 extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_ ref);46 extern int ip_received_error_msg_remote(int, device_id_t, packet_t , services_t,46 extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_t *); 47 extern int ip_received_error_msg_remote(int, device_id_t, packet_t *, services_t, 47 48 services_t); 48 49 extern int ip_device_req_remote(int, device_id_t, services_t); 49 50 extern int ip_add_route_req_remote(int, device_id_t, in_addr_t, in_addr_t, 50 51 in_addr_t); 51 extern int ip_send_msg_remote(int, device_id_t, packet_t , services_t,52 extern int ip_send_msg_remote(int, device_id_t, packet_t *, services_t, 52 53 services_t); 53 54 extern int ip_get_route_req_remote(int, ip_protocol_t, const struct sockaddr *, -
uspace/lib/net/include/net_checksum.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * General CRC and checksum computation.34 * General CRC and checksum computation. 35 35 */ 36 36 37 #ifndef __NET_CHECKSUM_H__38 #define __NET_CHECKSUM_H__37 #ifndef LIBNET_CHECKSUM_H_ 38 #define LIBNET_CHECKSUM_H_ 39 39 40 40 #include <byteorder.h> 41 42 41 #include <sys/types.h> 43 42 44 43 /** IP checksum value for computed zero checksum. 45 * Zero is returned as 0xFFFF (not flipped)44 * Zero is returned as 0xFFFF (not flipped) 46 45 */ 47 #define IP_CHECKSUM_ZERO 0xFFFFu46 #define IP_CHECKSUM_ZERO 0xffffU 48 47 49 /** Computes CRC32 value.50 * @param[in] seed Initial value. Often used as 0 or ~0.51 * @param[in] data Pointer to the beginning of data to process.52 * @param[in] length Length of the data in bits.53 * @returns The computed CRC32 of the length bits of the data.54 */55 48 #ifdef ARCH_IS_BIG_ENDIAN 56 #define compute_crc32(seed, data, length) compute_crc32_be(seed, (uint8_t *) data, length) 49 #define compute_crc32(seed, data, length) \ 50 compute_crc32_be(seed, (uint8_t *) data, length) 57 51 #else 58 #define compute_crc32(seed, data, length) compute_crc32_le(seed, (uint8_t *) data, length) 52 #define compute_crc32(seed, data, length) \ 53 compute_crc32_le(seed, (uint8_t *) data, length) 59 54 #endif 60 55 61 /** Computes CRC32 value in the little-endian environment. 62 * @param[in] seed Initial value. Often used as 0 or ~0. 63 * @param[in] data Pointer to the beginning of data to process. 64 * @param[in] length Length of the data in bits. 65 * @returns The computed CRC32 of the length bits of the data. 66 */ 67 extern uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length); 68 69 /** Computes CRC32 value in the big-endian environment. 70 * @param[in] seed Initial value. Often used as 0 or ~0. 71 * @param[in] data Pointer to the beginning of data to process. 72 * @param[in] length Length of the data in bits. 73 * @returns The computed CRC32 of the length bits of the data. 74 */ 75 extern uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length); 76 77 /** Computes sum of the 2 byte fields. 78 * Padds one zero (0) byte if odd. 79 * @param[in] seed Initial value. Often used as 0 or ~0. 80 * @param[in] data Pointer to the beginning of data to process. 81 * @param[in] length Length of the data in bytes. 82 * @returns The computed checksum of the length bytes of the data. 83 */ 84 extern uint32_t compute_checksum(uint32_t seed, uint8_t * data, size_t length); 85 86 /** Compacts the computed checksum to the 16 bit number adding the carries. 87 * @param[in] sum Computed checksum. 88 * @returns Compacted computed checksum to the 16 bits. 89 */ 90 extern uint16_t compact_checksum(uint32_t sum); 91 92 /** Returns or flips the checksum if zero. 93 * @param[in] checksum The computed checksum. 94 * @returns The internet protocol header checksum. 95 * @returns 0xFFFF if the computed checksum is zero. 96 */ 97 extern uint16_t flip_checksum(uint16_t checksum); 98 99 /** Computes the ip header checksum. 100 * To compute the checksum of a new packet, the checksum header field must be zero. 101 * To check the checksum of a received packet, the checksum may be left set. 102 * The zero (0) value will be returned in this case if valid. 103 * @param[in] data The header data. 104 * @param[in] length The header length in bytes. 105 * @returns The internet protocol header checksum. 106 * @returns 0xFFFF if the computed checksum is zero. 107 */ 108 extern uint16_t ip_checksum(uint8_t * data, size_t length); 56 extern uint32_t compute_crc32_le(uint32_t, uint8_t *, size_t); 57 extern uint32_t compute_crc32_be(uint32_t, uint8_t *, size_t); 58 extern uint32_t compute_checksum(uint32_t, uint8_t *, size_t); 59 extern uint16_t compact_checksum(uint32_t); 60 extern uint16_t flip_checksum(uint16_t); 61 extern uint16_t ip_checksum(uint8_t *, size_t); 109 62 110 63 #endif -
uspace/lib/net/include/net_hardware.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Hardware types according to the on-line IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009. 34 * Hardware types according to the on-line IANA - Address Resolution Protocol 35 * (ARP) Parameters 36 * http://www.iana.org/assignments/arp-parameters/arp-parameters.xml, 37 * cited January 14 2009. 35 38 */ 36 39 37 #ifndef __NET_HW_TYPES_H__38 #define __NET_HW_TYPES_H__40 #ifndef LIBNET_NET_HARDWARE_H_ 41 #define LIBNET_NET_HARDWARE_H_ 39 42 40 43 #include <sys/types.h> 41 44 42 /** Network interface layer type type definition. 43 */ 44 typedef uint8_t hw_type_t; 45 /** Network interface layer type type definition. */ 46 typedef uint8_t hw_type_t; 45 47 46 /** @name Network interface layer types definitions 47 */ 48 /** @name Network interface layer types definitions */ 48 49 /*@{*/ 49 50 50 /** Ethernet (10Mb) hardware type. 51 */ 51 /** Ethernet (10Mb) hardware type. */ 52 52 #define HW_ETHER 1 53 54 /** Experimental Ethernet (3Mb) hardware type.55 */56 #define HW_EETHER 257 58 /** Amateur Radio AX.25 hardware type.59 */60 #define HW_AX25 361 62 /** Proteon ProNET Token Ring hardware type.63 */64 #define HW_PRONET 465 66 /** Chaos hardware type.67 */68 #define HW_CHAOS 569 70 /** IEEE 802 Networks hardware type.71 */72 #define HW_IEEE802 673 74 /** ARCNET hardware type.75 */76 #define HW_ARCNET 777 78 /** Hyperchannel hardware type.79 */80 #define HW_Hyperchannel 881 82 /** Lanstar hardware type.83 */84 #define HW_Lanstar 985 86 /** Autonet Short Address hardware type.87 */88 #define HW_ASA 1089 90 /** LocalTalk hardware type.91 */92 #define HW_LocalTalk 1193 94 /** LocalNet (IBM PCNet or SYTEK LocalNET) hardware type.95 */96 #define HW_LocalNet 1297 98 /** Ultra link hardware type.99 */100 #define HW_Ultra_link 13101 102 /** SMDS hardware type.103 */104 #define HW_SMDS 14105 106 /** Frame Relay DLCI hardware type.107 */108 #define HW_DLCI 15109 110 /** Asynchronous Transmission Mode (ATM) hardware type.111 */112 #define HW_ATM 16113 114 /** HDLC hardware type.115 */116 #define HW_HDLC 17117 118 /** Fibre Channel hardware type.119 */120 #define HW_Fibre_Channel 18121 122 /** Asynchronous Transmission Mode (ATM) hardware type.123 */124 #define HW_ATM2 19125 126 /** Serial Line hardware type.127 */128 #define HW_Serial_Line 20129 130 /** Asynchronous Transmission Mode (ATM) hardware type.131 */132 #define HW_ATM3 21133 134 /** MIL-STD-188-220 hardware type.135 */136 #define HW_MIL_STD_188_220 22137 138 /** Metricom hardware type.139 */140 #define HW_METRICOM 23141 142 /** IEEE 1394.1995 hardware type.143 */144 #define HW_IEEE1394 24145 146 /** MAPOS hardware type.147 */148 #define HW_MAPOS 25149 150 /** Twinaxial hardware type.151 */152 #define HW_Twinaxial 26153 154 /** EUI-64 hardware type.155 */156 #define HW_EUI64 27157 158 /** HIPARP hardware type.159 */160 #define HW_HIPARP 28161 162 /** IP and ARP over ISO 7816-3 hardware type.163 */164 #define HW_ISO_7816_3 29165 166 /** ARPSec hardware type.167 */168 #define HW_ARPSec 30169 170 /** IPsec tunnel hardware type.171 */172 #define HW_IPsec_tunnel 31173 174 /** InfiniBand (TM) hardware type.175 */176 #define HW_INFINIBAND 32177 178 /** TIA-102 Project 25 Common Air Interface (CAI) hardware type.179 */180 #define HW_CAI 33181 182 /** Wiegand Interface hardware type.183 */184 #define HW_Wiegand 34185 186 /** Pure IP hardware type.187 */188 #define HW_Pure_IP 35189 53 190 54 /*@}*/ … … 194 58 /** @} 195 59 */ 60 -
uspace/lib/net/include/net_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_NET_INTERFACE_H__34 #define __NET_NET_INTERFACE_H__33 #ifndef LIBNET_NET_INTERFACE_H_ 34 #define LIBNET_NET_INTERFACE_H_ 35 35 36 36 #include <ipc/services.h> 37 37 38 #include <net _device.h>38 #include <net/device.h> 39 39 #include <adt/measured_strings.h> 40 40 41 41 /** @name Networking module interface 42 * This interface is used by other modules.42 * This interface is used by other modules. 43 43 */ 44 44 /*@{*/ 45 45 46 /** Returns the device specific configuration. 47 * Returns the global configuration if the device specific is not found. 48 * The configuration names are read and the appropriate settings are set instead. 49 * Call net_free_settings() function to release the returned configuration. 50 * @param[in] net_phone The networking module phone. 51 * @param[in] device_id The device identifier. 52 * @param[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead. 53 * @param[in] count The configuration entries count. 54 * @param[in,out] data The configuration and settings data. 55 * @returns EOK on success. 56 * @returns EINVAL if the configuration is NULL. 57 * @returns EINVAL if the count is zero (0). 58 * @returns Other error codes as defined for the generic_translate_req() function. 59 */ 60 extern int net_get_device_conf_req(int net_phone, device_id_t device_id, measured_string_ref * configuration, size_t count, char ** data); 61 62 /** Returns the global configuration. 63 * The configuration names are read and the appropriate settings are set instead. 64 * Call net_free_settings() function to release the returned configuration. 65 * @param[in] net_phone The networking module phone. 66 * @param[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead. 67 * @param[in] count The configuration entries count. 68 * @param[in,out] data The configuration and settings data. 69 * @returns EOK on success. 70 * @returns EINVAL if the configuration is NULL. 71 * @returns EINVAL if the count is zero (0). 72 * @returns Other error codes as defined for the generic_translate_req() function. 73 */ 74 extern int net_get_conf_req(int net_phone, measured_string_ref * configuration, size_t count, char ** data); 75 76 /** Frees the received settings. 77 * @param[in] settings The received settings. 78 * @param[in] data The received settings data. 79 * @see net_get_device_conf_req() 80 * @see net_get_conf_req() 81 */ 82 extern void net_free_settings(measured_string_ref settings, char * data); 83 84 /** Connects to the networking module. 85 * @param service The networking module service. Ignored parameter. 86 * @returns The networking module phone on success. 87 * @returns 0 if called by the bundle module. 88 */ 89 extern int net_connect_module(services_t service); 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **, 47 size_t, char **); 48 extern int net_get_conf_req(int, measured_string_t **, size_t, char **); 49 extern void net_free_settings(measured_string_t *, char *); 50 extern int net_connect_module(void); 90 51 91 52 /*@}*/ -
uspace/lib/net/include/netif_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_NETIF_INTERFACE_H__ 34 #define __NET_NETIF_INTERFACE_H__ 35 36 #ifdef CONFIG_NETIF_NIL_BUNDLE 37 38 #include <netif_local.h> 39 #include <netif_nil_bundle.h> 40 #include <packet/packet_server.h> 41 42 #define netif_module_message netif_nil_module_message 43 #define netif_module_start netif_nil_module_start 44 #define netif_get_addr_req netif_get_addr_req_local 45 #define netif_probe_req netif_probe_req_local 46 #define netif_send_msg netif_send_msg_local 47 #define netif_start_req netif_start_req_local 48 #define netif_stop_req netif_stop_req_local 49 #define netif_stats_req netif_stats_req_local 50 #define netif_bind_service netif_bind_service_local 51 52 #else /* CONFIG_NETIF_NIL_BUNDLE */ 33 #ifndef LIBNET_NETIF_INTERFACE_H_ 34 #define LIBNET_NETIF_INTERFACE_H_ 53 35 54 36 #include <netif_remote.h> 55 #include <packet /packet_client.h>37 #include <packet_client.h> 56 38 57 39 #define netif_module_message netif_module_message_standalone … … 65 47 #define netif_bind_service netif_bind_service_remote 66 48 67 #endif /* CONFIG_NETIF_NIL_BUNDLE */68 69 49 #endif 70 50 -
uspace/lib/net/include/netif_local.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 34 34 * Network interface module skeleton. 35 35 * The skeleton has to be part of each network interface module. 36 * The skeleton can be also part of the module bundled with the network interface layer. 37 */ 38 39 #ifndef __NET_NETIF_LOCAL_H__ 40 #define __NET_NETIF_LOCAL_H__ 36 */ 37 38 #ifndef NET_NETIF_LOCAL_H_ 39 #define NET_NETIF_LOCAL_H_ 41 40 42 41 #include <async.h> … … 46 45 47 46 #include <adt/measured_strings.h> 48 #include <net_err.h> 49 #include <net_device.h> 50 #include <packet/packet.h> 51 52 /** Network interface device specific data. 53 * 54 */ 47 #include <net/device.h> 48 #include <net/packet.h> 49 50 /** Network interface device specific data. */ 55 51 typedef struct { 56 52 device_id_t device_id; /**< Device identifier. */ … … 68 64 DEVICE_MAP_DECLARE(netif_device_map, netif_device_t); 69 65 70 /** Network interface module skeleton global data. 71 * 72 */ 66 /** Network interface module skeleton global data. */ 73 67 typedef struct { 74 68 int net_phone; /**< Networking module phone. */ … … 82 76 * 83 77 * This function has to be implemented in user code. 84 *85 78 */ 86 79 extern int netif_initialize(void); … … 90 83 * This has to be implemented in user code. 91 84 * 92 * @param[in] device_id The device identifier.93 * @param[in] irq The device interrupt number.94 * @param[in] io The device input/output address.95 * 96 * @return EOK on success.97 * @return Other error codes as defined for the find_device() function.98 * @return Other error codes as defined for the specific module message99 * implementation.100 * 85 * @param[in] device_id The device identifier. 86 * @param[in] irq The device interrupt number. 87 * @param[in] io The device input/output address. 88 * 89 * @return EOK on success. 90 * @return Other error codes as defined for the find_device() 91 * function. 92 * @return Other error codes as defined for the specific module 93 * message implementation. 101 94 */ 102 95 extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io); … … 106 99 * This has to be implemented in user code. 107 100 * 108 * @param[in] device_id The device identifier. 109 * @param[in] packet The packet queue. 110 * @param[in] sender The sending module service. 111 * 112 * @return EOK on success. 113 * @return EFORWARD if the device is not active (in the NETIF_ACTIVE state). 114 * @return Other error codes as defined for the find_device() function. 115 * @return Other error codes as defined for the specific module message 116 * implementation. 117 * 118 */ 119 extern int netif_send_message(device_id_t device_id, packet_t packet, 101 * @param[in] device_id The device identifier. 102 * @param[in] packet The packet queue. 103 * @param[in] sender The sending module service. 104 * 105 * @return EOK on success. 106 * @return EFORWARD if the device is not active (in the 107 * NETIF_ACTIVE state). 108 * @return Other error codes as defined for the find_device() 109 * function. 110 * @return Other error codes as defined for the specific module 111 * message implementation. 112 */ 113 extern int netif_send_message(device_id_t device_id, packet_t *packet, 120 114 services_t sender); 121 115 … … 124 118 * This has to be implemented in user code. 125 119 * 126 * @param[in] device The device structure.127 * 128 * @return EOK on success.129 * @return Other error codes as defined for the find_device() function.130 * @return Other error codes as defined for the specific module message131 * implementation.132 * 120 * @param[in] device The device structure. 121 * 122 * @return EOK on success. 123 * @return Other error codes as defined for the find_device() 124 * function. 125 * @return Other error codes as defined for the specific module 126 * message implementation. 133 127 */ 134 128 extern int netif_start_message(netif_device_t *device); … … 138 132 * This has to be implemented in user code. 139 133 * 140 * @param[in] device The device structure.141 * 142 * @return EOK on success.143 * @return Other error codes as defined for the find_device() function.144 * @return Other error codes as defined for the specific module message145 * implementation.146 * 134 * @param[in] device The device structure. 135 * 136 * @return EOK on success. 137 * @return Other error codes as defined for the find_device() 138 * function. 139 * @return Other error codes as defined for the specific module 140 * message implementation. 147 141 */ 148 142 extern int netif_stop_message(netif_device_t *device); … … 152 146 * This has to be implemented in user code. 153 147 * 154 * @param[in] device_idThe device identifier.155 * @param[out] address The device local hardware address.156 * 157 * @return EOK on success.158 * @return EBADMEM if the address parameter is NULL.159 * @return ENOENT if there no such device.160 * @return Other error codes as defined for the find_device() function.161 * @return Other error codes as defined for the specific module message162 * implementation.163 * 148 * @param[in] device_id The device identifier. 149 * @param[out] address The device local hardware address. 150 * 151 * @return EOK on success. 152 * @return EBADMEM if the address parameter is NULL. 153 * @return ENOENT if there no such device. 154 * @return Other error codes as defined for the find_device() 155 * function. 156 * @return Other error codes as defined for the specific module 157 * message implementation. 164 158 */ 165 159 extern int netif_get_addr_message(device_id_t device_id, 166 measured_string_ refaddress);160 measured_string_t *address); 167 161 168 162 /** Process the netif driver specific message. … … 171 165 * skeleton. This has to be implemented in user code. 172 166 * 173 * @param[in] callidThe message identifier.174 * @param[in] callThe message parameters.175 * @param[out] answer The message answer parameters.167 * @param[in] callid The message identifier. 168 * @param[in] call The message parameters. 169 * @param[out] answer The message answer parameters. 176 170 * @param[out] answer_count The last parameter for the actual answer in 177 * the answer parameter. 178 * 179 * @return EOK on success. 180 * @return ENOTSUP if the message is not known. 181 * @return Other error codes as defined for the specific module message 182 * implementation. 183 * 171 * the answer parameter. 172 * 173 * @return EOK on success. 174 * @return ENOTSUP if the message is not known. 175 * @return Other error codes as defined for the specific module 176 * message implementation. 184 177 */ 185 178 extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call, … … 190 183 * This has to be implemented in user code. 191 184 * 192 * @param[in] device_idThe device identifier.193 * @param[out] stats The device usage statistics.194 * 195 * @return EOK on success.196 * @return Other error codes as defined for the find_device() function.197 * @return Other error codes as defined for the specific module message198 * implementation.199 * 185 * @param[in] device_id The device identifier. 186 * @param[out] stats The device usage statistics. 187 * 188 * @return EOK on success. 189 * @return Other error codes as defined for the find_device() 190 * function. 191 * @return Other error codes as defined for the specific module 192 * message implementation. 200 193 */ 201 194 extern int netif_get_device_stats(device_id_t device_id, 202 device_stats_ refstats);203 204 extern int netif_get_addr_req_local(int, device_id_t, measured_string_ ref*,195 device_stats_t *stats); 196 197 extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **, 205 198 char **); 206 199 extern int netif_probe_req_local(int, device_id_t, int, int); 207 extern int netif_send_msg_local(int, device_id_t, packet_t , services_t);200 extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t); 208 201 extern int netif_start_req_local(int, device_id_t); 209 202 extern int netif_stop_req_local(int, device_id_t); 210 extern int netif_stats_req_local(int, device_id_t, device_stats_ ref);203 extern int netif_stats_req_local(int, device_id_t, device_stats_t *); 211 204 extern int netif_bind_service_local(services_t, device_id_t, services_t, 212 205 async_client_conn_t); 213 206 214 207 extern int find_device(device_id_t, netif_device_t **); 215 extern void null_device_stats(device_stats_ ref);208 extern void null_device_stats(device_stats_t *); 216 209 extern void netif_pq_release(packet_id_t); 217 extern packet_t netif_packet_get_1(size_t);210 extern packet_t *netif_packet_get_1(size_t); 218 211 extern int netif_init_module(async_client_conn_t); 219 212 -
uspace/lib/net/include/netif_remote.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_NETIF_REMOTE_H__34 #define __NET_NETIF_REMOTE_H__33 #ifndef LIBNET_NETIF_REMOTE_H_ 34 #define LIBNET_NETIF_REMOTE_H_ 35 35 36 36 #include <async.h> 37 #include < fibril_synch.h>38 #include < ipc/ipc.h>37 #include <ipc/services.h> 38 #include <adt/measured_strings.h> 39 39 40 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_ref *, 40 #include <net/device.h> 41 #include <net/packet.h> 42 43 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_t **, 41 44 char **); 42 45 extern int netif_probe_req_remote(int, device_id_t, int, int); 43 extern int netif_send_msg_remote(int, device_id_t, packet_t , services_t);46 extern int netif_send_msg_remote(int, device_id_t, packet_t *, services_t); 44 47 extern int netif_start_req_remote(int, device_id_t); 45 48 extern int netif_stop_req_remote(int, device_id_t); 46 extern int netif_stats_req_remote(int, device_id_t, device_stats_ ref);49 extern int netif_stats_req_remote(int, device_id_t, device_stats_t *); 47 50 extern int netif_bind_service_remote(services_t, device_id_t, services_t, 48 51 async_client_conn_t); -
uspace/lib/net/include/nil_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_NIL_INTERFACE_H__34 #define __NET_NIL_INTERFACE_H__33 #ifndef LIBNET_NIL_INTERFACE_H_ 34 #define LIBNET_NIL_INTERFACE_H_ 35 35 36 36 #include <async.h> … … 38 38 39 39 #include <ipc/ipc.h> 40 #include <ipc/nil.h> 40 41 41 #include <net_messages.h> 42 #include <adt/measured_strings.h> 43 #include <packet/packet.h> 44 #include <nil_messages.h> 45 #include <net_device.h> 42 #include <generic.h> 43 #include <nil_remote.h> 46 44 47 45 #define nil_bind_service(service, device_id, me, receiver) \ … … 49 47 50 48 #define nil_packet_size_req(nil_phone, device_id, packet_dimension) \ 51 generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, device_id,\52 packet_dimension)49 generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \ 50 device_id, packet_dimension) 53 51 54 52 #define nil_get_addr_req(nil_phone, device_id, address, data) \ … … 67 65 netif_service) 68 66 69 70 #ifdef CONFIG_NETIF_NIL_BUNDLE71 72 #include <nil_local.h>73 #include <packet/packet_server.h>74 75 #define nil_device_state_msg nil_device_state_msg_local76 #define nil_received_msg nil_received_msg_local77 78 #else /* CONFIG_NETIF_NIL_BUNDLE */79 80 #include <nil_remote.h>81 #include <packet/packet_server.h>82 83 67 #define nil_device_state_msg nil_device_state_msg_remote 84 68 #define nil_received_msg nil_received_msg_remote 85 86 #endif /* CONFIG_NETIF_NIL_BUNDLE */87 69 88 70 #endif -
uspace/lib/net/include/nil_local.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 … … 36 36 */ 37 37 38 #ifndef __NET_NIL_LOCAL_H__39 #define __NET_NIL_LOCAL_H__38 #ifndef LIBNET_NIL_LOCAL_H_ 39 #define LIBNET_NIL_LOCAL_H_ 40 40 41 41 #include <ipc/ipc.h> … … 45 45 * Is called by the module_start() function. 46 46 * 47 * @param[in] net_phone The networking moduel phone. 48 * 49 * @return EOK on success. 50 * @return Other error codes as defined for each specific module initialize function. 51 * 47 * @param[in] net_phone The networking moduel phone. 48 * @return EOK on success. 49 * @return Other error codes as defined for each specific module 50 * initialize function. 52 51 */ 53 52 extern int nil_initialize(int); 54 53 54 /** Notify the network interface layer about the device state change. 55 * 56 * @param[in] nil_phone The network interface layer phone. 57 * @param[in] device_id The device identifier. 58 * @param[in] state The new device state. 59 * @return EOK on success. 60 * @return Other error codes as defined for each specific module 61 * device state function. 62 */ 55 63 extern int nil_device_state_msg_local(int, device_id_t, int); 56 extern int nil_received_msg_local(int, device_id_t, packet_t, services_t); 64 65 66 /** Pass the packet queue to the network interface layer. 67 * 68 * Process and redistribute the received packet queue to the registered 69 * upper layers. 70 * 71 * @param[in] nil_phone The network interface layer phone. 72 * @param[in] device_id The source device identifier. 73 * @param[in] packet The received packet or the received packet queue. 74 * @param target The target service. Ignored parameter. 75 * @return EOK on success. 76 * @return Other error codes as defined for each specific module 77 * received function. 78 */ 79 extern int nil_received_msg_local(int, device_id_t, packet_t *, services_t); 57 80 58 81 /** Message processing function. 59 82 * 60 * @param[in] name Module name. 61 * @param[in] callid The message identifier. 62 * @param[in] call The message parameters. 63 * @param[out] answer The message answer parameters. 64 * @param[out] answer_count The last parameter for the actual answer 65 * in the answer parameter. 66 * 67 * @return EOK on success. 68 * @return ENOTSUP if the message is not known. 69 * @return Other error codes as defined for each specific 70 * module message function. 83 * @param[in] name Module name. 84 * @param[in] callid The message identifier. 85 * @param[in] call The message parameters. 86 * @param[out] answer The message answer parameters. 87 * @param[out] answer_count The last parameter for the actual answer in the 88 * answer parameter. 89 * @return EOK on success. 90 * @return ENOTSUP if the message is not known. 91 * @return Other error codes as defined for each specific module 92 * message function. 71 93 * 72 94 * @see nil_interface.h 73 95 * @see IS_NET_NIL_MESSAGE() 96 */ 97 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, 98 ipc_call_t *, int *); 99 100 /** Pass the parameters to the module specific nil_message() function. 74 101 * 102 * @param[in] name Module name. 103 * @param[in] callid The message identifier. 104 * @param[in] call The message parameters. 105 * @param[out] answer The message answer parameters. 106 * @param[out] answer_count The last parameter for the actual answer in the 107 * answer parameter. 108 * @return EOK on success. 109 * @return ENOTSUP if the message is not known. 110 * @return Other error codes as defined for each specific module 111 * message function. 75 112 */ 76 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,77 int *);78 79 113 extern int nil_module_message_standalone(const char *, ipc_callid_t, 80 114 ipc_call_t *, ipc_call_t *, int *); 115 116 /** Start the standalone nil layer module. 117 * 118 * Initialize the client connection serving function, initialize 119 * the module, register the module service and start the async 120 * manager, processing IPC messages in an infinite loop. 121 * 122 * @param[in] client_connection The client connection processing function. 123 * The module skeleton propagates its own one. 124 * @return EOK on success. 125 * @return Other error codes as defined for the pm_init() function. 126 * @return Other error codes as defined for the nil_initialize() 127 * function. 128 * @return Other error codes as defined for the REGISTER_ME() macro 129 * function. 130 */ 81 131 extern int nil_module_start_standalone(async_client_conn_t); 82 132 -
uspace/lib/net/include/nil_remote.h
r9a1d8ab r0b749a3 34 34 #define __NET_NIL_REMOTE_H__ 35 35 36 #include < async.h>37 #include < fibril_synch.h>38 #include < ipc/ipc.h>36 #include <ipc/services.h> 37 #include <net/device.h> 38 #include <net/packet.h> 39 39 40 40 extern int nil_device_state_msg_remote(int, device_id_t, int); 41 extern int nil_received_msg_remote(int, device_id_t, packet_t , services_t);41 extern int nil_received_msg_remote(int, device_id_t, packet_t *, services_t); 42 42 43 43 #endif -
uspace/lib/net/include/packet_remote.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 #ifndef __NET_PACKET_REMOTE_H__34 #define __NET_PACKET_REMOTE_H__33 #ifndef LIBNET_PACKET_REMOTE_H_ 34 #define LIBNET_PACKET_REMOTE_H_ 35 35 36 #include <packet/packet.h> 36 #include <net/packet.h> 37 #include <sys/types.h> 37 38 38 extern int packet_translate_remote(int, packet_ ref, packet_id_t);39 extern packet_t packet_get_4_remote(int, size_t, size_t, size_t, size_t);40 extern packet_t packet_get_1_remote(int, size_t);39 extern int packet_translate_remote(int, packet_t **, packet_id_t); 40 extern packet_t *packet_get_4_remote(int, size_t, size_t, size_t, size_t); 41 extern packet_t *packet_get_1_remote(int, size_t); 41 42 extern void pq_release_remote(int, packet_id_t); 42 43 -
uspace/lib/net/include/protocol_map.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Internetwork layer services - network interface layer service type translation. 34 * Internetwork layer services - network interface layer service type 35 * translation. 35 36 */ 36 37 37 #ifndef __NET_PROTOCOL_MAP_H__ 38 #define __NET_PROTOCOL_MAP_H__ 39 40 #include <ipc/services.h> 38 #ifndef LIBNET_PROTOCOL_MAP_H_ 39 #define LIBNET_PROTOCOL_MAP_H_ 41 40 42 41 #include <ethernet_lsap.h> … … 44 43 #include <net_hardware.h> 45 44 46 /** Maps the internetwork layer service to the network interface layer type. 47 * @param[in] nil Network interface layer service. 48 * @param[in] il Internetwork layer service. 49 * @returns Network interface layer type of the internetworking layer service. 50 * @returns 0 if mapping is not found. 51 */ 52 static inline eth_type_t protocol_map(services_t nil, services_t il){ 53 switch(nil){ 54 case SERVICE_ETHERNET: 55 case SERVICE_DP8390: 56 switch(il){ 57 case SERVICE_IP: 58 return ETH_P_IP; 59 case SERVICE_ARP: 60 return ETH_P_ARP; 61 default: 62 return 0; 63 } 64 default: 65 return 0; 66 } 67 } 45 #include <ipc/services.h> 68 46 69 /** Maps the network interface layer type to the internetwork layer service. 70 * @param[in] nil Network interface layer service. 71 * @param[in] protocol Network interface layer type. 72 * @returns Internetwork layer service of the network interface layer type. 73 * @returns 0 if mapping is not found. 74 */ 75 static inline services_t protocol_unmap(services_t nil, int protocol){ 76 switch(nil){ 77 case SERVICE_ETHERNET: 78 case SERVICE_DP8390: 79 switch(protocol){ 80 case ETH_P_IP: 81 return SERVICE_IP; 82 case ETH_P_ARP: 83 return SERVICE_ARP; 84 default: 85 return 0; 86 } 87 default: 88 return 0; 89 } 90 } 91 92 /** Maps the link service access point identifier to the Ethernet protocol identifier. 93 * @param[in] lsap Link service access point identifier. 94 * @returns Ethernet protocol identifier of the link service access point identifier. 95 * @returns ETH_LSAP_NULL if mapping is not found. 96 */ 97 static inline eth_type_t lsap_map(eth_lsap_t lsap){ 98 switch(lsap){ 99 case ETH_LSAP_IP: 100 return ETH_P_IP; 101 case ETH_LSAP_ARP: 102 return ETH_P_ARP; 103 default: 104 return ETH_LSAP_NULL; 105 } 106 } 107 108 /** Maps the Ethernet protocol identifier to the link service access point identifier. 109 * @param[in] ethertype Ethernet protocol identifier. 110 * @returns Link service access point identifier. 111 * @returns 0 if mapping is not found. 112 */ 113 static inline eth_lsap_t lsap_unmap(eth_type_t ethertype){ 114 switch(ethertype){ 115 case ETH_P_IP: 116 return ETH_LSAP_IP; 117 case ETH_P_ARP: 118 return ETH_LSAP_ARP; 119 default: 120 return 0; 121 } 122 } 123 124 /** Maps the network interface layer services to the hardware types. 125 * @param[in] nil The network interface service. 126 * @returns The hardware type of the network interface service. 127 * @returns 0 if mapping is not found. 128 */ 129 static inline hw_type_t hardware_map(services_t nil){ 130 switch(nil){ 131 case SERVICE_ETHERNET: 132 case SERVICE_DP8390: 133 return HW_ETHER; 134 default: 135 return 0; 136 } 137 } 47 extern eth_type_t protocol_map(services_t, services_t); 48 extern services_t protocol_unmap(services_t, int); 49 extern eth_type_t lsap_map(eth_lsap_t); 50 extern eth_lsap_t lsap_unmap(eth_type_t); 51 extern hw_type_t hardware_map(services_t); 138 52 139 53 #endif -
uspace/lib/net/include/tl_common.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_tl30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Transport layer common functions.34 * Transport layer common functions. 35 35 */ 36 36 37 #ifndef __NET_TL_COMMON_H__38 #define __NET_TL_COMMON_H__37 #ifndef LIBNET_TL_COMMON_H_ 38 #define LIBNET_TL_COMMON_H_ 39 39 40 #include <packet/packet.h> 41 #include <net_device.h> 42 #include <inet.h> 43 #include <socket_codes.h> 40 #include <ipc/services.h> 41 42 #include <net/socket_codes.h> 43 #include <net/packet.h> 44 #include <net/device.h> 45 #include <net/inet.h> 44 46 45 47 /** Device packet dimensions. 46 * Maps devices to the packet dimensions.47 * @see device.h48 * Maps devices to the packet dimensions. 49 * @see device.h 48 50 */ 49 51 DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t); 50 52 51 extern int tl_get_ip_packet_dimension(int, packet_dimensions_ref, 52 device_id_t, packet_dimension_ref *); 53 54 /** Gets the address port. 55 * Supports AF_INET and AF_INET6 address families. 56 * @param[in,out] addr The address to be updated. 57 * @param[in] addrlen The address length. 58 * @param[out] port The set port. 59 * @returns EOK on success. 60 * @returns EINVAL if the address length does not match the address family. 61 * @returns EAFNOSUPPORT if the address family is not supported. 62 */ 63 extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port); 64 65 /** Updates IP device packet dimensions cache. 66 * @param[in,out] packet_dimensions The packet dimensions cache. 67 * @param[in] device_id The device identifier. 68 * @param[in] content The new maximum content size. 69 * @returns EOK on success. 70 * @returns ENOENT if the packet dimension is not cached. 71 */ 72 extern int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content); 73 74 /** Sets the address port. 75 * Supports AF_INET and AF_INET6 address families. 76 * @param[in,out] addr The address to be updated. 77 * @param[in] addrlen The address length. 78 * @param[in] port The port to be set. 79 * @returns EOK on success. 80 * @returns EINVAL if the address length does not match the address family. 81 * @returns EAFNOSUPPORT if the address family is not supported. 82 */ 83 extern int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port); 84 85 /** Prepares the packet for ICMP error notification. 86 * Keeps the first packet and releases all the others. 87 * Releases all the packets on error. 88 * @param[in] packet_phone The packet server module phone. 89 * @param[in] icmp_phone The ICMP module phone. 90 * @param[in] packet The packet to be send. 91 * @param[in] error The packet error reporting service. Prefixes the received packet. 92 * @returns EOK on success. 93 * @returns ENOENT if no packet may be sent. 94 */ 95 extern int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error); 96 97 /** Receives data from the socket into a packet. 98 * @param[in] packet_phone The packet server module phone. 99 * @param[out] packet The new created packet. 100 * @param[in] prefix Reserved packet data prefix length. 101 * @param[in] dimension The packet dimension. 102 * @param[in] addr The destination address. 103 * @param[in] addrlen The address length. 104 * @returns Number of bytes received. 105 * @returns EINVAL if the client does not send data. 106 * @returns ENOMEM if there is not enough memory left. 107 * @returns Other error codes as defined for the async_data_read_finalize() function. 108 */ 109 extern int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen); 53 extern int tl_get_ip_packet_dimension(int, packet_dimensions_t *, 54 device_id_t, packet_dimension_t **); 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, 57 size_t); 58 extern int tl_set_address_port(struct sockaddr *, int, uint16_t); 59 extern int tl_prepare_icmp_packet(int, int, packet_t *, services_t); 60 extern int tl_socket_read_packet_data(int, packet_t **, size_t, 61 const packet_dimension_t *, const struct sockaddr *, socklen_t); 110 62 111 63 #endif -
uspace/lib/net/include/tl_interface.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_tl30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 … … 35 35 */ 36 36 37 #ifndef __NET_TL_INTERFACE_H__38 #define __NET_TL_INTERFACE_H__37 #ifndef LIBNET_TL_INTERFACE_H_ 38 #define LIBNET_TL_INTERFACE_H_ 39 39 40 40 #include <async.h> 41 41 #include <ipc/services.h> 42 #include <ipc/tl.h> 42 43 43 #include <net_messages.h> 44 #include <net_device.h> 45 #include <packet/packet.h> 46 #include <packet/packet_client.h> 47 #include <tl_messages.h> 44 #include <generic.h> 45 #include <net/device.h> 46 #include <net/packet.h> 47 #include <packet_client.h> 48 48 49 49 /** @name Transport layer module interface … … 52 52 /*@{*/ 53 53 54 /** Notify the remote transport layer modules about the received packet/s. 55 * 56 * @param[in] tl_phone The transport layer module phone used for remote calls. 57 * @param[in] device_id The device identifier. 58 * @param[in] packet The received packet or the received packet queue. 59 * The packet queue is used to carry a fragmented 60 * datagram. The first packet contains the headers, 61 * the others contain only data. 62 * @param[in] target The target transport layer module service to be 63 * delivered to. 64 * @param[in] error The packet error reporting service. Prefixes the 65 * received packet. 66 * 67 * @return EOK on success. 68 * 69 */ 70 inline static int tl_received_msg(int tl_phone, device_id_t device_id, 71 packet_t packet, services_t target, services_t error) 72 { 73 return generic_received_msg_remote(tl_phone, NET_TL_RECEIVED, device_id, 74 packet_get_id(packet), target, error); 75 } 54 extern int tl_received_msg(int, device_id_t, packet_t *, services_t, services_t); 76 55 77 56 /*@}*/ -
uspace/lib/net/include/tl_local.h
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup tl_local30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 #ifndef __TL_LOCAL_H__34 #define __TL_LOCAL_H__33 #ifndef LIBNET_TL_LOCAL_H_ 34 #define LIBNET_TL_LOCAL_H_ 35 35 36 36 #include <ipc/ipc.h> 37 37 #include <async.h> 38 38 39 /** Starts the TL module. 40 * 41 * Initializes the client connection serving function, initializes the module, 42 * registers the module service and starts the async manager, processing IPC 43 * messages in an infinite loop. 44 * 45 * @param[in] client_connection The client connection processing function. The 46 * module skeleton propagates its own one. 47 * @return EOK on successful module termination. 48 * @return Other error codes as defined for the module initialize 49 * function. 50 * @return Other error codes as defined for the REGISTER_ME() macro 51 * function. 52 */ 39 53 extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *, 40 54 ipc_call_t *, int *); 55 56 57 /** Processes the TL module message. 58 * 59 * @param[in] callid The message identifier. 60 * @param[in] call The message parameters. 61 * @param[out] answer The message answer parameters. 62 * @param[out] answer_count The last parameter for the actual answer in the 63 * answer parameter. 64 * @return EOK on success. 65 * @return Other error codes as defined for the module's message 66 * standalone function. 67 */ 41 68 extern int tl_module_start_standalone(async_client_conn_t); 42 69 -
uspace/lib/net/netif/netif_local.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 42 42 #include <ipc/ipc.h> 43 43 #include <ipc/services.h> 44 45 #include < net_err.h>46 #include <net_messages.h> 47 #include < net_modules.h>48 #include < packet/packet.h>49 #include < packet/packet_client.h>50 #include <packet /packet_server.h>44 #include <ipc/netif.h> 45 #include <errno.h> 46 47 #include <generic.h> 48 #include <net/modules.h> 49 #include <net/packet.h> 50 #include <packet_client.h> 51 51 #include <packet_remote.h> 52 52 #include <adt/measured_strings.h> 53 #include <net _device.h>53 #include <net/device.h> 54 54 #include <nil_interface.h> 55 55 #include <netif_local.h> 56 #include <netif_messages.h>57 56 #include <netif_interface.h> 58 57 59 58 DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t); 60 59 61 /** Network interface global data. 62 */ 60 /** Network interface global data. */ 63 61 netif_globals_t netif_globals; 64 62 … … 66 64 * 67 65 * @param[in] netif_phone The network interface phone. 68 * @param[in] device_id The device identifier.69 * @param[in] irq The device interrupt number.70 * @param[in] io The device input/output address.71 * 72 * @return EOK on success.73 * @return Other errro codes as defined for thenetif_probe_message().74 * 75 */ 76 intnetif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)66 * @param[in] device_id The device identifier. 67 * @param[in] irq The device interrupt number. 68 * @param[in] io The device input/output address. 69 * @return EOK on success. 70 * @return Other error codes as defined for the 71 * netif_probe_message(). 72 */ 73 int 74 netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io) 77 75 { 78 76 fibril_rwlock_write_lock(&netif_globals.lock); … … 86 84 * 87 85 * @param[in] netif_phone The network interface phone. 88 * @param[in] device_id The device identifier. 89 * @param[in] packet The packet queue. 90 * @param[in] sender The sending module service. 91 * 92 * @return EOK on success. 93 * @return Other error codes as defined for the generic_send_msg() function. 94 * 86 * @param[in] device_id The device identifier. 87 * @param[in] packet The packet queue. 88 * @param[in] sender The sending module service. 89 * @return EOK on success. 90 * @return Other error codes as defined for the generic_send_msg() 91 * function. 95 92 */ 96 93 int netif_send_msg_local(int netif_phone, device_id_t device_id, 97 packet_t packet, services_t sender)94 packet_t *packet, services_t sender) 98 95 { 99 96 fibril_rwlock_write_lock(&netif_globals.lock); … … 107 104 * 108 105 * @param[in] netif_phone The network interface phone. 109 * @param[in] device_id The device identifier.110 * 111 * @return EOK on success.112 * @return Other error codes as defined for the find_device()function.113 * @return Other error codes as defined for the netif_start_message() function.114 * 106 * @param[in] device_id The device identifier. 107 * @return EOK on success. 108 * @return Other error codes as defined for the find_device() 109 * function. 110 * @return Other error codes as defined for the 111 * netif_start_message() function. 115 112 */ 116 113 int netif_start_req_local(int netif_phone, device_id_t device_id) 117 114 { 118 ERROR_DECLARE;115 int rc; 119 116 120 117 fibril_rwlock_write_lock(&netif_globals.lock); 121 118 122 119 netif_device_t *device; 123 if (ERROR_OCCURRED(find_device(device_id, &device))) { 120 rc = find_device(device_id, &device); 121 if (rc != EOK) { 124 122 fibril_rwlock_write_unlock(&netif_globals.lock); 125 return ERROR_CODE;123 return rc; 126 124 } 127 125 … … 142 140 * 143 141 * @param[in] netif_phone The network interface phone. 144 * @param[in] device_id The device identifier.145 * 146 * @return EOK on success.147 * @return Other error codes as defined for the find_device()function.148 * @return Other error codes as defined for the netif_stop_message() function.149 * 142 * @param[in] device_id The device identifier. 143 * @return EOK on success. 144 * @return Other error codes as defined for the find_device() 145 * function. 146 * @return Other error codes as defined for the 147 * netif_stop_message() function. 150 148 */ 151 149 int netif_stop_req_local(int netif_phone, device_id_t device_id) 152 150 { 153 ERROR_DECLARE;151 int rc; 154 152 155 153 fibril_rwlock_write_lock(&netif_globals.lock); 156 154 157 155 netif_device_t *device; 158 if (ERROR_OCCURRED(find_device(device_id, &device))) { 156 rc = find_device(device_id, &device); 157 if (rc != EOK) { 159 158 fibril_rwlock_write_unlock(&netif_globals.lock); 160 return ERROR_CODE;159 return rc; 161 160 } 162 161 … … 176 175 /** Return the device usage statistics. 177 176 * 178 * @param[in] netif_phone The network interface phone. 179 * @param[in] device_id The device identifier. 180 * @param[out] stats The device usage statistics. 181 * 177 * @param[in] netif_phone The network interface phone. 178 * @param[in] device_id The device identifier. 179 * @param[out] stats The device usage statistics. 182 180 * @return EOK on success. 183 *184 181 */ 185 182 int netif_stats_req_local(int netif_phone, device_id_t device_id, 186 device_stats_ refstats)183 device_stats_t *stats) 187 184 { 188 185 fibril_rwlock_read_lock(&netif_globals.lock); … … 195 192 /** Return the device local hardware address. 196 193 * 197 * @param[in] netif_phone The network interface phone. 198 * @param[in] device_id The device identifier. 199 * @param[out] address The device local hardware address. 200 * @param[out] data The address data. 201 * 202 * @return EOK on success. 203 * @return EBADMEM if the address parameter is NULL. 204 * @return ENOENT if there no such device. 205 * @return Other error codes as defined for the netif_get_addr_message() 206 * function. 207 * 194 * @param[in] netif_phone The network interface phone. 195 * @param[in] device_id The device identifier. 196 * @param[out] address The device local hardware address. 197 * @param[out] data The address data. 198 * @return EOK on success. 199 * @return EBADMEM if the address parameter is NULL. 200 * @return ENOENT if there no such device. 201 * @return Other error codes as defined for the 202 * netif_get_addr_message() function. 208 203 */ 209 204 int netif_get_addr_req_local(int netif_phone, device_id_t device_id, 210 measured_string_ ref*address, char **data)211 { 212 ERROR_DECLARE;213 214 if ( (!address) || (!data))205 measured_string_t **address, char **data) 206 { 207 int rc; 208 209 if (!address || !data) 215 210 return EBADMEM; 216 211 … … 218 213 219 214 measured_string_t translation; 220 if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) { 215 rc = netif_get_addr_message(device_id, &translation); 216 if (rc == EOK) { 221 217 *address = measured_string_copy(&translation); 222 ERROR_CODE= (*address) ? EOK : ENOMEM;218 rc = (*address) ? EOK : ENOMEM; 223 219 } 224 220 … … 227 223 *data = (**address).value; 228 224 229 return ERROR_CODE; 230 } 231 232 /** Create bidirectional connection with the network interface module and registers the message receiver. 233 * 234 * @param[in] service The network interface module service. 235 * @param[in] device_id The device identifier. 236 * @param[in] me The requesting module service. 237 * @param[in] receiver The message receiver. 238 * 239 * @return The phone of the needed service. 240 * @return EOK on success. 241 * @return Other error codes as defined for the bind_service() function. 242 * 243 */ 244 int netif_bind_service_local(services_t service, device_id_t device_id, 245 services_t me, async_client_conn_t receiver) 246 { 247 return EOK; 225 return rc; 248 226 } 249 227 250 228 /** Find the device specific data. 251 229 * 252 * @param[in] device_id The device identifier. 253 * @param[out] device The device specific data. 254 * 255 * @return EOK on success. 256 * @return ENOENT if device is not found. 257 * @return EPERM if the device is not initialized. 258 * 230 * @param[in] device_id The device identifier. 231 * @param[out] device The device specific data. 232 * @return EOK on success. 233 * @return ENOENT if device is not found. 234 * @return EPERM if the device is not initialized. 259 235 */ 260 236 int find_device(device_id_t device_id, netif_device_t **device) … … 275 251 /** Clear the usage statistics. 276 252 * 277 * @param[in] stats The usage statistics. 278 * 279 */ 280 void null_device_stats(device_stats_ref stats) 253 * @param[in] stats The usage statistics. 254 */ 255 void null_device_stats(device_stats_t *stats) 281 256 { 282 257 bzero(stats, sizeof(device_stats_t)); … … 285 260 /** Initialize the netif module. 286 261 * 287 * @param[in] client_connection The client connection functio to be 288 * registered. 289 * 290 * @return EOK on success. 291 * @return Other error codes as defined for each specific module 292 * message function. 293 * 262 * @param[in] client_connection The client connection functio to be registered. 263 * @return EOK on success. 264 * @return Other error codes as defined for each specific module 265 * message function. 294 266 */ 295 267 int netif_init_module(async_client_conn_t client_connection) 296 268 { 297 ERROR_DECLARE;269 int rc; 298 270 299 271 async_set_client_connection(client_connection); … … 302 274 netif_device_map_initialize(&netif_globals.device_map); 303 275 304 ERROR_PROPAGATE(pm_init()); 276 rc = pm_init(); 277 if (rc != EOK) 278 return rc; 305 279 306 280 fibril_rwlock_initialize(&netif_globals.lock); 307 if (ERROR_OCCURRED(netif_initialize())) { 281 282 rc = netif_initialize(); 283 if (rc != EOK) { 308 284 pm_destroy(); 309 return ERROR_CODE;285 return rc; 310 286 } 311 287 … … 317 293 * Prepared for future optimization. 318 294 * 319 * @param[in] packet_id The packet identifier. 320 * 295 * @param[in] packet_id The packet identifier. 321 296 */ 322 297 void netif_pq_release(packet_id_t packet_id) … … 327 302 /** Allocate new packet to handle the given content size. 328 303 * 329 * @param[in] content The minimum content size. 330 * 331 * @return The allocated packet. 332 * @return NULL if there is an error. 333 * 334 */ 335 packet_t netif_packet_get_1(size_t content) 304 * @param[in] content The minimum content size. 305 * @return The allocated packet. 306 * @return NULL if there is an error. 307 * 308 */ 309 packet_t *netif_packet_get_1(size_t content) 336 310 { 337 311 return packet_get_1_remote(netif_globals.net_phone, content); 338 312 } 339 313 340 /** Register the device notification receiver, the network interface layer module. 341 * 342 * @param[in] name Module name. 343 * @param[in] device_id The device identifier. 344 * @param[in] phone The network interface layer module phone. 345 * 346 * @return EOK on success. 347 * @return ENOENT if there is no such device. 348 * @return ELIMIT if there is another module registered. 349 * 314 /** Register the device notification receiver, the network interface layer 315 * module. 316 * 317 * @param[in] name Module name. 318 * @param[in] device_id The device identifier. 319 * @param[in] phone The network interface layer module phone. 320 * @return EOK on success. 321 * @return ENOENT if there is no such device. 322 * @return ELIMIT if there is another module registered. 350 323 */ 351 324 static int register_message(const char *name, device_id_t device_id, int phone) 352 325 { 353 ERROR_DECLARE;354 355 326 netif_device_t *device; 356 ERROR_PROPAGATE(find_device(device_id, &device)); 357 if(device->nil_phone > 0) 327 int rc; 328 329 rc = find_device(device_id, &device); 330 if (rc != EOK) 331 return rc; 332 333 if (device->nil_phone > 0) 358 334 return ELIMIT; 359 335 … … 366 342 /** Process the netif module messages. 367 343 * 368 * @param[in] nameModule name.369 * @param[in] callidThe message identifier.370 * @param[in] callThe message parameters.371 * @param[out] answer The message answer parameters.372 * @param[out] answer_count The last parameter for the actual answer 373 * in theanswer parameter.374 * 375 * @return EOK on success.376 * @return ENOTSUP if the message is not known.377 * @return Other error codes as defined for each specific modulemessage function.344 * @param[in] name Module name. 345 * @param[in] callid The message identifier. 346 * @param[in] call The message parameters. 347 * @param[out] answer The message answer parameters. 348 * @param[out] answer_count The last parameter for the actual answer in the 349 * answer parameter. 350 * @return EOK on success. 351 * @return ENOTSUP if the message is not known. 352 * @return Other error codes as defined for each specific module 353 * message function. 378 354 * 379 355 * @see IS_NET_NETIF_MESSAGE() … … 383 359 ipc_call_t *call, ipc_call_t *answer, int *answer_count) 384 360 { 385 ERROR_DECLARE;386 387 361 size_t length; 388 362 device_stats_t stats; 389 packet_t packet;363 packet_t *packet; 390 364 measured_string_t address; 365 int rc; 391 366 392 367 *answer_count = 0; 393 368 switch (IPC_GET_METHOD(*call)) { 394 case IPC_M_PHONE_HUNGUP:395 return EOK;396 case NET_NETIF_PROBE:397 return netif_probe_req_local(0, IPC_GET_DEVICE(call),398 NETIF_GET_IRQ(call), NETIF_GET_IO(call));399 case IPC_M_CONNECT_TO_ME:400 fibril_rwlock_write_lock(&netif_globals.lock);401 ERROR_CODE = register_message(name, IPC_GET_DEVICE(call),402 IPC_GET_PHONE(call));403 fibril_rwlock_write_unlock(&netif_globals.lock);404 return ERROR_CODE;405 case NET_NETIF_SEND:406 ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone,407 &packet, IPC_GET_PACKET(call)));408 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,409 IPC_GET_SENDER(call));410 case NET_NETIF_START:411 return netif_start_req_local(0, IPC_GET_DEVICE(call));412 case NET_NETIF_STATS:413 fibril_rwlock_read_lock(&netif_globals.lock);414 if (!ERROR_OCCURRED(async_data_read_receive(&callid, &length))) {415 if (length < sizeof(device_stats_t))416 ERROR_CODE = EOVERFLOW;417 else {418 if (!ERROR_OCCURRED(netif_get_device_stats(419 IPC_GET_DEVICE(call), &stats)))420 ERROR_CODE = async_data_read_finalize(callid, &stats,421 sizeof(device_stats_t)); 422 }423 }369 case IPC_M_PHONE_HUNGUP: 370 return EOK; 371 372 case NET_NETIF_PROBE: 373 return netif_probe_req_local(0, IPC_GET_DEVICE(call), 374 NETIF_GET_IRQ(call), NETIF_GET_IO(call)); 375 376 case IPC_M_CONNECT_TO_ME: 377 fibril_rwlock_write_lock(&netif_globals.lock); 378 rc = register_message(name, IPC_GET_DEVICE(call), 379 IPC_GET_PHONE(call)); 380 fibril_rwlock_write_unlock(&netif_globals.lock); 381 return rc; 382 383 case NET_NETIF_SEND: 384 rc = packet_translate_remote(netif_globals.net_phone, &packet, 385 IPC_GET_PACKET(call)); 386 if (rc != EOK) 387 return rc; 388 return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet, 389 IPC_GET_SENDER(call)); 390 391 case NET_NETIF_START: 392 return netif_start_req_local(0, IPC_GET_DEVICE(call)); 393 394 case NET_NETIF_STATS: 395 fibril_rwlock_read_lock(&netif_globals.lock); 396 397 rc = async_data_read_receive(&callid, &length); 398 if (rc != EOK) { 424 399 fibril_rwlock_read_unlock(&netif_globals.lock); 425 return ERROR_CODE; 426 case NET_NETIF_STOP: 427 return netif_stop_req_local(0, IPC_GET_DEVICE(call)); 428 case NET_NETIF_GET_ADDR: 429 fibril_rwlock_read_lock(&netif_globals.lock); 430 if (!ERROR_OCCURRED(netif_get_addr_message(IPC_GET_DEVICE(call), 431 &address))) 432 ERROR_CODE = measured_strings_reply(&address, 1); 400 return rc; 401 } 402 if (length < sizeof(device_stats_t)) { 433 403 fibril_rwlock_read_unlock(&netif_globals.lock); 434 return ERROR_CODE; 404 return EOVERFLOW; 405 } 406 407 rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats); 408 if (rc == EOK) { 409 rc = async_data_read_finalize(callid, &stats, 410 sizeof(device_stats_t)); 411 } 412 413 fibril_rwlock_read_unlock(&netif_globals.lock); 414 return rc; 415 416 case NET_NETIF_STOP: 417 return netif_stop_req_local(0, IPC_GET_DEVICE(call)); 418 419 case NET_NETIF_GET_ADDR: 420 fibril_rwlock_read_lock(&netif_globals.lock); 421 rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address); 422 if (rc == EOK) 423 rc = measured_strings_reply(&address, 1); 424 fibril_rwlock_read_unlock(&netif_globals.lock); 425 return rc; 435 426 } 436 427 … … 440 431 /** Start the network interface module. 441 432 * 442 * Initialize the client connection serving function, initialize 443 * the module, registers the module service and start the async 444 * manager, processing IPC messages in an infinite loop. 445 * 446 * @param[in] client_connection The client connection processing 447 * function. The module skeleton propagates 448 * its own one. 449 * 450 * @return EOK on success. 451 * @return Other error codes as defined for each specific module message 452 * function. 453 * 433 * Initialize the client connection serving function, initialize the module, 434 * registers the module service and start the async manager, processing IPC 435 * messages in an infinite loop. 436 * 437 * @param[in] client_connection The client connection processing function. 438 * The module skeleton propagates its own one. 439 * @return EOK on success. 440 * @return Other error codes as defined for each specific module 441 * message function. 454 442 */ 455 443 int netif_module_start_standalone(async_client_conn_t client_connection) 456 444 { 457 ERROR_DECLARE; 458 459 ERROR_PROPAGATE(netif_init_module(client_connection)); 445 int rc; 446 447 rc = netif_init_module(client_connection); 448 if (rc != EOK) 449 return rc; 460 450 461 451 async_manager(); -
uspace/lib/net/netif/netif_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup netif29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #include <netif_remote.h> 38 #include <packet_client.h> 39 #include <generic.h> 40 37 41 #include <ipc/services.h> 42 #include <ipc/netif.h> 38 43 39 #include <net _modules.h>44 #include <net/modules.h> 40 45 #include <adt/measured_strings.h> 41 #include <packet/packet.h> 42 #include <packet/packet_client.h> 43 #include <net_device.h> 44 #include <netif_remote.h> 45 #include <netif_messages.h> 46 #include <net/packet.h> 47 #include <net/device.h> 46 48 49 /** Return the device local hardware address. 50 * 51 * @param[in] netif_phone The network interface phone. 52 * @param[in] device_id The device identifier. 53 * @param[out] address The device local hardware address. 54 * @param[out] data The address data. 55 * @return EOK on success. 56 * @return EBADMEM if the address parameter is NULL. 57 * @return ENOENT if there no such device. 58 * @return Other error codes as defined for the 59 * netif_get_addr_message() function. 60 */ 47 61 int netif_get_addr_req_remote(int netif_phone, device_id_t device_id, 48 measured_string_ ref*address, char **data)62 measured_string_t **address, char **data) 49 63 { 50 64 return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, … … 52 66 } 53 67 54 int netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io) 68 /** Probe the existence of the device. 69 * 70 * @param[in] netif_phone The network interface phone. 71 * @param[in] device_id The device identifier. 72 * @param[in] irq The device interrupt number. 73 * @param[in] io The device input/output address. 74 * @return EOK on success. 75 * @return Other error codes as defined for the 76 * netif_probe_message(). 77 */ 78 int 79 netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io) 55 80 { 56 81 return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io); 57 82 } 58 83 59 int netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet, 84 /** Send the packet queue. 85 * 86 * @param[in] netif_phone The network interface phone. 87 * @param[in] device_id The device identifier. 88 * @param[in] packet The packet queue. 89 * @param[in] sender The sending module service. 90 * @return EOK on success. 91 * @return Other error codes as defined for the generic_send_msg() 92 * function. 93 */ 94 int 95 netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet, 60 96 services_t sender) 61 97 { … … 64 100 } 65 101 102 /** Start the device. 103 * 104 * @param[in] netif_phone The network interface phone. 105 * @param[in] device_id The device identifier. 106 * @return EOK on success. 107 * @return Other error codes as defined for the find_device() 108 * function. 109 * @return Other error codes as defined for the 110 * netif_start_message() function. 111 */ 66 112 int netif_start_req_remote(int netif_phone, device_id_t device_id) 67 113 { … … 69 115 } 70 116 117 /** Stop the device. 118 * 119 * @param[in] netif_phone The network interface phone. 120 * @param[in] device_id The device identifier. 121 * @return EOK on success. 122 * @return Other error codes as defined for the find_device() 123 * function. 124 * @return Other error codes as defined for the 125 * netif_stop_message() function. 126 */ 71 127 int netif_stop_req_remote(int netif_phone, device_id_t device_id) 72 128 { … … 74 130 } 75 131 132 /** Return the device usage statistics. 133 * 134 * @param[in] netif_phone The network interface phone. 135 * @param[in] device_id The device identifier. 136 * @param[out] stats The device usage statistics. 137 * @return EOK on success. 138 */ 76 139 int netif_stats_req_remote(int netif_phone, device_id_t device_id, 77 device_stats_ refstats)140 device_stats_t *stats) 78 141 { 79 142 if (!stats) … … 90 153 } 91 154 92 int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me, 93 async_client_conn_t receiver) 155 /** Create bidirectional connection with the network interface module and 156 * registers the message receiver. 157 * 158 * @param[in] service The network interface module service. 159 * @param[in] device_id The device identifier. 160 * @param[in] me The requesting module service. 161 * @param[in] receiver The message receiver. 162 * 163 * @return The phone of the needed service. 164 * @return EOK on success. 165 * @return Other error codes as defined for the bind_service() 166 * function. 167 */ 168 int 169 netif_bind_service_remote(services_t service, device_id_t device_id, 170 services_t me, async_client_conn_t receiver) 94 171 { 95 172 return bind_service(service, device_id, me, 0, receiver); -
uspace/lib/net/nil/nil_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_nil29 /** @addtogroup libnet 30 30 * @{ 31 31 */ … … 36 36 */ 37 37 38 #include <net_messages.h> 39 #include <net_device.h> 38 #include <nil_remote.h> 40 39 #include <nil_interface.h> 41 #include <packet/packet.h> 42 #include <packet/packet_client.h> 43 #include <nil_messages.h> 44 #include <nil_remote.h> 40 #include <generic.h> 41 #include <net/device.h> 42 #include <net/packet.h> 43 #include <packet_client.h> 44 45 #include <ipc/nil.h> 45 46 46 47 /** Notify the network interface layer about the device state change. 47 48 * 48 * @param[in] nil_phone The network interface layer phone. 49 * @param[in] device_id The device identifier. 50 * @param[in] state The new device state. 51 * 52 * @return EOK on success. 53 * @return Other error codes as defined for each specific module device 54 * state function. 55 * 49 * @param[in] nil_phone The network interface layer phone. 50 * @param[in] device_id The device identifier. 51 * @param[in] state The new device state. 52 * @return EOK on success. 53 * @return Other error codes as defined for each specific module 54 * device state function. 56 55 */ 57 56 int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state) … … 66 65 * upper layers. 67 66 * 68 * @param[in] nil_phone The network interface layer phone. 69 * @param[in] device_id The source device identifier. 70 * @param[in] packet The received packet or the received packet queue. 71 * @param target The target service. Ignored parameter. 72 * 73 * @return EOK on success. 74 * @return Other error codes as defined for each specific module 75 * received function. 76 * 67 * @param[in] nil_phone The network interface layer phone. 68 * @param[in] device_id The source device identifier. 69 * @param[in] packet The received packet or the received packet queue. 70 * @param target The target service. Ignored parameter. 71 * @return EOK on success. 72 * @return Other error codes as defined for each specific module 73 * received function. 77 74 */ 78 75 int nil_received_msg_remote(int nil_phone, device_id_t device_id, 79 packet_t packet, services_t target)76 packet_t *packet, services_t target) 80 77 { 81 return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, device_id,82 packet_get_id(packet), target, 0);78 return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, 79 device_id, packet_get_id(packet), target, 0); 83 80 } 84 81 -
uspace/lib/net/tl/icmp_client.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP client interface implementation.35 * @see icmp_client.h34 * ICMP client interface implementation. 35 * @see icmp_client.h 36 36 */ 37 37 38 #include <icmp_client.h> 39 #include <icmp_header.h> 40 #include <packet_client.h> 41 38 42 #ifdef CONFIG_DEBUG 39 #include <stdio.h>43 #include <stdio.h> 40 44 #endif 41 45 … … 43 47 #include <sys/types.h> 44 48 45 #include <icmp_codes.h> 46 #include <icmp_client.h> 47 #include <packet/packet.h> 48 #include <packet/packet_client.h> 49 #include <icmp_header.h> 49 #include <net/icmp_codes.h> 50 #include <net/packet.h> 50 51 51 int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){ 52 icmp_header_ref header; 52 /** Processes the received packet prefixed with an ICMP header. 53 * 54 * @param[in] packet The received packet. 55 * @param[out] type The ICMP header type. 56 * @param[out] code The ICMP header code. 57 * @param[out] pointer The ICMP header pointer. 58 * @param[out] mtu The ICMP header MTU. 59 * @return The ICMP header length. 60 * @return Zero if the packet contains no data. 61 */ 62 int 63 icmp_client_process_packet(packet_t *packet, icmp_type_t *type, 64 icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu) 65 { 66 icmp_header_t *header; 53 67 54 header = (icmp_header_ ref) packet_get_data(packet);55 if ((! header)56 || (packet_get_data_length(packet) < sizeof(icmp_header_t))){68 header = (icmp_header_t *) packet_get_data(packet); 69 if (!header || 70 (packet_get_data_length(packet) < sizeof(icmp_header_t))) { 57 71 return 0; 58 72 } 59 if(type){ 73 74 if (type) 60 75 *type = header->type; 61 } 62 if(code){ 76 if (code) 63 77 *code = header->code; 64 } 65 if(pointer){ 78 if (pointer) 66 79 *pointer = header->un.param.pointer; 67 } 68 if(mtu){ 80 if (mtu) 69 81 *mtu = header->un.frag.mtu; 70 } 82 71 83 // remove debug dump 72 84 #ifdef CONFIG_DEBUG 73 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet)); 85 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, 86 packet_get_id(packet)); 74 87 #endif 75 88 return sizeof(icmp_header_t); 76 89 } 77 90 78 size_t icmp_client_header_length(packet_t packet){ 79 if(packet_get_data_length(packet) < sizeof(icmp_header_t)){ 91 /** Returns the ICMP header length. 92 * 93 * @param[in] packet The packet. 94 * @return The ICMP header length in bytes. 95 */ 96 size_t icmp_client_header_length(packet_t *packet) 97 { 98 if (packet_get_data_length(packet) < sizeof(icmp_header_t)) 80 99 return 0; 81 } 100 82 101 return sizeof(icmp_header_t); 83 102 } -
uspace/lib/net/tl/icmp_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup icmp29 /** @addtogroup libnet 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * ICMP interface implementation for remote modules.35 * @see icmp_interface.h34 * ICMP interface implementation for remote modules. 35 * @see icmp_interface.h 36 36 */ 37 38 #include <icmp_interface.h> 39 #include <net/modules.h> 40 #include <packet_client.h> 37 41 38 42 #include <async.h> … … 40 44 #include <ipc/ipc.h> 41 45 #include <ipc/services.h> 46 #include <ipc/icmp.h> 42 47 #include <sys/types.h> 43 48 44 #include <net_messages.h> 45 #include <net_modules.h> 46 #include <icmp_interface.h> 47 #include <packet/packet_client.h> 48 #include <icmp_messages.h> 49 50 int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){ 51 async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu); 49 /** Sends the Destination Unreachable error notification packet. 50 * 51 * Beginning of the packet is sent as the notification packet data. 52 * The source and the destination addresses should be set in the original 53 * packet. 54 * 55 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 56 * @param[in] code The error specific code. 57 * @param[in] mtu The error MTU value. 58 * @param[in] packet The original packet. 59 * @return EOK on success. 60 * @return EPERM if the ICMP error notifications are disabled. 61 * @return ENOMEM if there is not enough memory left. 62 */ 63 int 64 icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, 65 icmp_param_t mtu, packet_t *packet) 66 { 67 async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code, 68 (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu); 52 69 return EOK; 53 70 } 54 71 55 int icmp_source_quench_msg(int icmp_phone, packet_t packet){ 56 async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, (ipcarg_t) packet_get_id(packet)); 72 /** Sends the Source Quench error notification packet. 73 * 74 * Beginning of the packet is sent as the notification packet data. 75 * The source and the destination addresses should be set in the original 76 * packet. 77 * 78 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 79 * @param[in] packet The original packet. 80 * @return EOK on success. 81 * @return EPERM if the ICMP error notifications are disabled. 82 * @return ENOMEM if there is not enough memory left. 83 */ 84 int icmp_source_quench_msg(int icmp_phone, packet_t *packet) 85 { 86 async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, 87 (ipcarg_t) packet_get_id(packet)); 57 88 return EOK; 58 89 } 59 90 60 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet){ 61 async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet)); 91 /** Sends the Time Exceeded error notification packet. 92 * 93 * Beginning of the packet is sent as the notification packet data. 94 * The source and the destination addresses should be set in the original 95 * packet. 96 * 97 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 98 * @param[in] code The error specific code. 99 * @param[in] packet The original packet. 100 * @return EOK on success. 101 * @return EPERM if the ICMP error notifications are disabled. 102 * @return ENOMEM if there is not enough memory left. 103 */ 104 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet) 105 { 106 async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code, 107 (ipcarg_t) packet_get_id(packet)); 62 108 return EOK; 63 109 } 64 110 65 int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet){ 66 async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer); 111 /** Sends the Parameter Problem error notification packet. 112 * 113 * Beginning of the packet is sent as the notification packet data. 114 * The source and the destination addresses should be set in the original 115 * packet. 116 * 117 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls. 118 * @param[in] code The error specific code. 119 * @param[in] pointer The problematic parameter offset. 120 * @param[in] packet The original packet. 121 * @return EOK on success. 122 * @return EPERM if the ICMP error notifications are disabled. 123 * @return ENOMEM if there is not enough memory left. 124 */ 125 int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, 126 icmp_param_t pointer, packet_t *packet) 127 { 128 async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code, 129 (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer); 67 130 return EOK; 68 131 } … … 70 133 /** @} 71 134 */ 135 -
uspace/lib/net/tl/tl_common.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup net_tl30 * @{29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 34 * Transport layer common functions implementation. 35 * @see tl_common.h 36 */ 37 38 #include <tl_common.h> 39 #include <packet_client.h> 40 #include <packet_remote.h> 41 #include <icmp_interface.h> 42 #include <ip_remote.h> 43 #include <ip_interface.h> 44 #include <tl_interface.h> 45 46 #include <net/socket_codes.h> 47 #include <net/in.h> 48 #include <net/in6.h> 49 #include <net/inet.h> 50 #include <net/device.h> 51 #include <net/packet.h> 37 52 38 53 #include <async.h> 39 54 #include <ipc/services.h> 40 41 #include <net_err.h> 42 #include <packet/packet.h> 43 #include <packet/packet_client.h> 44 #include <packet_remote.h> 45 #include <net_device.h> 46 #include <icmp_interface.h> 47 #include <in.h> 48 #include <in6.h> 49 #include <inet.h> 50 #include <ip_local.h> 51 #include <ip_remote.h> 52 #include <socket_codes.h> 53 #include <socket_errno.h> 54 #include <ip_interface.h> 55 #include <tl_interface.h> 56 #include <tl_common.h> 55 #include <errno.h> 57 56 58 57 DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t); 59 58 60 int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port){ 61 const struct sockaddr_in * address_in; 62 const struct sockaddr_in6 * address_in6; 63 64 if((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr))){ 65 return EINVAL; 66 } 67 switch(addr->sa_family){ 68 case AF_INET: 69 if(addrlen != sizeof(struct sockaddr_in)){ 70 return EINVAL; 71 } 72 address_in = (struct sockaddr_in *) addr; 73 *port = ntohs(address_in->sin_port); 74 break; 75 case AF_INET6: 76 if(addrlen != sizeof(struct sockaddr_in6)){ 77 return EINVAL; 78 } 79 address_in6 = (struct sockaddr_in6 *) addr; 80 *port = ntohs(address_in6->sin6_port); 81 break; 82 default: 83 return EAFNOSUPPORT; 84 } 59 /** Gets the address port. 60 * 61 * Supports AF_INET and AF_INET6 address families. 62 * 63 * @param[in,out] addr The address to be updated. 64 * @param[in] addrlen The address length. 65 * @param[out] port The set port. 66 * @return EOK on success. 67 * @return EINVAL if the address length does not match the address 68 * family. 69 * @return EAFNOSUPPORT if the address family is not supported. 70 */ 71 int 72 tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port) 73 { 74 const struct sockaddr_in *address_in; 75 const struct sockaddr_in6 *address_in6; 76 77 if ((addrlen <= 0) || ((size_t) addrlen < sizeof(struct sockaddr))) 78 return EINVAL; 79 80 switch (addr->sa_family) { 81 case AF_INET: 82 if (addrlen != sizeof(struct sockaddr_in)) 83 return EINVAL; 84 85 address_in = (struct sockaddr_in *) addr; 86 *port = ntohs(address_in->sin_port); 87 break; 88 89 case AF_INET6: 90 if (addrlen != sizeof(struct sockaddr_in6)) 91 return EINVAL; 92 93 address_in6 = (struct sockaddr_in6 *) addr; 94 *port = ntohs(address_in6->sin6_port); 95 break; 96 97 default: 98 return EAFNOSUPPORT; 99 } 100 85 101 return EOK; 86 102 } … … 91 107 * The reply is cached then. 92 108 * 93 * @param[in] ip_phoneThe IP moduel phone for (semi)remote calls.94 * @param[in] packet_dimensions The packet dimensions cache.95 * @param[in] device_idThe device identifier.96 * @param[out] packet_dimension The IP packet dimensions.97 * 98 * @return EOK on success.99 * @return EBADMEM if the packet_dimension parameter is NULL.100 * @return ENOMEM if there is not enough memory left.101 * @return EINVAL if the packet_dimensions cache is not valid.102 * @return Other codes as defined for the ip_packet_size_req()function.103 * 104 */ 105 inttl_get_ip_packet_dimension(int ip_phone,106 packet_dimensions_ refpacket_dimensions, device_id_t device_id,107 packet_dimension_ ref*packet_dimension)108 { 109 ERROR_DECLARE;109 * @param[in] ip_phone The IP moduel phone for (semi)remote calls. 110 * @param[in] packet_dimensions The packet dimensions cache. 111 * @param[in] device_id The device identifier. 112 * @param[out] packet_dimension The IP packet dimensions. 113 * @return EOK on success. 114 * @return EBADMEM if the packet_dimension parameter is NULL. 115 * @return ENOMEM if there is not enough memory left. 116 * @return EINVAL if the packet_dimensions cache is not valid. 117 * @return Other codes as defined for the ip_packet_size_req() 118 * function. 119 */ 120 int 121 tl_get_ip_packet_dimension(int ip_phone, 122 packet_dimensions_t *packet_dimensions, device_id_t device_id, 123 packet_dimension_t **packet_dimension) 124 { 125 int rc; 110 126 111 127 if (!packet_dimension) 112 128 return EBADMEM; 113 129 114 *packet_dimension = packet_dimensions_find(packet_dimensions, device_id); 130 *packet_dimension = packet_dimensions_find(packet_dimensions, 131 device_id); 115 132 if (!*packet_dimension) { 116 133 /* Ask for and remember them if not found */ … … 119 136 return ENOMEM; 120 137 121 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,122 *packet_dimension))) {138 rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension); 139 if (rc != EOK) { 123 140 free(*packet_dimension); 124 return ERROR_CODE;141 return rc; 125 142 } 126 143 127 ERROR_CODE= packet_dimensions_add(packet_dimensions, device_id,144 rc = packet_dimensions_add(packet_dimensions, device_id, 128 145 *packet_dimension); 129 if ( ERROR_CODE< 0) {146 if (rc < 0) { 130 147 free(*packet_dimension); 131 return ERROR_CODE;148 return rc; 132 149 } 133 150 } … … 136 153 } 137 154 138 int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content){ 139 packet_dimension_ref packet_dimension; 155 /** Updates IP device packet dimensions cache. 156 * 157 * @param[in,out] packet_dimensions The packet dimensions cache. 158 * @param[in] device_id The device identifier. 159 * @param[in] content The new maximum content size. 160 * @return EOK on success. 161 * @return ENOENT if the packet dimension is not cached. 162 */ 163 int 164 tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions, 165 device_id_t device_id, size_t content) 166 { 167 packet_dimension_t *packet_dimension; 140 168 141 169 packet_dimension = packet_dimensions_find(packet_dimensions, device_id); 142 if (! packet_dimension){170 if (!packet_dimension) 143 171 return ENOENT; 144 } 172 145 173 packet_dimension->content = content; 146 if(device_id != DEVICE_INVALID_ID){ 147 packet_dimension = packet_dimensions_find(packet_dimensions, DEVICE_INVALID_ID); 148 if(packet_dimension){ 149 if(packet_dimension->content >= content){ 174 175 if (device_id != DEVICE_INVALID_ID) { 176 packet_dimension = packet_dimensions_find(packet_dimensions, 177 DEVICE_INVALID_ID); 178 179 if (packet_dimension) { 180 if (packet_dimension->content >= content) 150 181 packet_dimension->content = content; 151 }else{152 packet_dimensions_exclude(packet_dimensions, DEVICE_INVALID_ID);153 }182 else 183 packet_dimensions_exclude(packet_dimensions, 184 DEVICE_INVALID_ID); 154 185 } 155 186 } 187 156 188 return EOK; 157 189 } 158 190 159 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port){ 160 struct sockaddr_in * address_in; 161 struct sockaddr_in6 * address_in6; 191 /** Sets the address port. 192 * 193 * Supports AF_INET and AF_INET6 address families. 194 * 195 * @param[in,out] addr The address to be updated. 196 * @param[in] addrlen The address length. 197 * @param[in] port The port to be set. 198 * @return EOK on success. 199 * @return EINVAL if the address length does not match the address 200 * family. 201 * @return EAFNOSUPPORT if the address family is not supported. 202 */ 203 int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port) 204 { 205 struct sockaddr_in *address_in; 206 struct sockaddr_in6 *address_in6; 162 207 size_t length; 163 208 164 if (addrlen < 0){165 return EINVAL; 166 }209 if (addrlen < 0) 210 return EINVAL; 211 167 212 length = (size_t) addrlen; 168 if(length < sizeof(struct sockaddr)){ 169 return EINVAL; 170 } 171 switch(addr->sa_family){ 172 case AF_INET: 173 if(length != sizeof(struct sockaddr_in)){ 213 if (length < sizeof(struct sockaddr)) 214 return EINVAL; 215 216 switch (addr->sa_family) { 217 case AF_INET: 218 if (length != sizeof(struct sockaddr_in)) 219 return EINVAL; 220 address_in = (struct sockaddr_in *) addr; 221 address_in->sin_port = htons(port); 222 return EOK; 223 224 case AF_INET6: 225 if (length != sizeof(struct sockaddr_in6)) 174 226 return EINVAL; 175 } 176 address_in = (struct sockaddr_in *) addr; 177 address_in->sin_port = htons(port); 178 return EOK; 179 case AF_INET6: 180 if(length != sizeof(struct sockaddr_in6)){ 181 return EINVAL; 182 } 183 address_in6 = (struct sockaddr_in6 *) addr; 184 address_in6->sin6_port = htons(port); 185 return EOK; 186 default: 187 return EAFNOSUPPORT; 188 } 189 } 190 191 int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error){ 192 packet_t next; 193 uint8_t * src; 227 address_in6 = (struct sockaddr_in6 *) addr; 228 address_in6->sin6_port = htons(port); 229 return EOK; 230 231 default: 232 return EAFNOSUPPORT; 233 } 234 } 235 236 /** Prepares the packet for ICMP error notification. 237 * 238 * Keeps the first packet and releases all the others. 239 * Releases all the packets on error. 240 * 241 * @param[in] packet_phone The packet server module phone. 242 * @param[in] icmp_phone The ICMP module phone. 243 * @param[in] packet The packet to be send. 244 * @param[in] error The packet error reporting service. Prefixes the 245 * received packet. 246 * @return EOK on success. 247 * @return ENOENT if no packet may be sent. 248 */ 249 int 250 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet, 251 services_t error) 252 { 253 packet_t *next; 254 uint8_t *src; 194 255 int length; 195 256 … … 200 261 201 262 length = packet_get_addr(packet, &src, NULL); 202 if((length > 0) 203 && (! error) 204 && (icmp_phone >= 0) 205 // set both addresses to the source one (avoids the source address deletion before setting the destination one) 206 && (packet_set_addr(packet, src, src, (size_t) length) == EOK)){ 263 if ((length > 0) && (!error) && (icmp_phone >= 0) && 264 // set both addresses to the source one (avoids the source address 265 // deletion before setting the destination one) 266 (packet_set_addr(packet, src, src, (size_t) length) == EOK)) { 207 267 return EOK; 208 } else{268 } else 209 269 pq_release_remote(packet_phone, packet_get_id(packet)); 210 } 270 211 271 return ENOENT; 212 272 } 213 273 214 int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen){ 215 ERROR_DECLARE; 216 274 /** Receives data from the socket into a packet. 275 * 276 * @param[in] packet_phone The packet server module phone. 277 * @param[out] packet The new created packet. 278 * @param[in] prefix Reserved packet data prefix length. 279 * @param[in] dimension The packet dimension. 280 * @param[in] addr The destination address. 281 * @param[in] addrlen The address length. 282 * @return Number of bytes received. 283 * @return EINVAL if the client does not send data. 284 * @return ENOMEM if there is not enough memory left. 285 * @return Other error codes as defined for the 286 * async_data_read_finalize() function. 287 */ 288 int 289 tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix, 290 const packet_dimension_t *dimension, const struct sockaddr *addr, 291 socklen_t addrlen) 292 { 217 293 ipc_callid_t callid; 218 294 size_t length; 219 void * data; 220 221 if(! dimension){ 222 return EINVAL; 223 } 295 void *data; 296 int rc; 297 298 if (!dimension) 299 return EINVAL; 300 224 301 // get the data length 225 if (! async_data_write_receive(&callid, &length)){226 return EINVAL; 227 } 302 if (!async_data_write_receive(&callid, &length)) 303 return EINVAL; 304 228 305 // get a new packet 229 *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix); 230 if(! packet){ 306 *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, 307 prefix + dimension->prefix, dimension->suffix); 308 if (!packet) 231 309 return ENOMEM; 232 } 310 233 311 // allocate space in the packet 234 312 data = packet_suffix(*packet, length); 235 if (! data){313 if (!data) { 236 314 pq_release_remote(packet_phone, packet_get_id(*packet)); 237 315 return ENOMEM; 238 316 } 317 239 318 // read the data into the packet 240 if(ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) 319 rc = async_data_write_finalize(callid, data, length); 320 if (rc != EOK) { 321 pq_release_remote(packet_phone, packet_get_id(*packet)); 322 return rc; 323 } 324 241 325 // set the packet destination address 242 || ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){ 326 rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen); 327 if (rc != EOK) { 243 328 pq_release_remote(packet_phone, packet_get_id(*packet)); 244 return ERROR_CODE; 245 } 329 return rc; 330 } 331 246 332 return (int) length; 247 333 } -
uspace/lib/packet/Makefile
r9a1d8ab r0b749a3 28 28 # 29 29 30 USPACE_PREFIX = ../../../.. 31 LIBS = $(LIBPCI_PREFIX)/libpci.a 32 EXTRA_CFLAGS = -I$(LIBPCI_PREFIX) 33 BINARY = pci 30 USPACE_PREFIX = ../.. 31 EXTRA_CFLAGS = -Iinclude 32 LIBRARY = libpacket 34 33 35 34 SOURCES = \ 36 pci.c35 generic/packet_server.c 37 36 38 37 include $(USPACE_PREFIX)/Makefile.common
Note:
See TracChangeset
for help on using the changeset viewer.
