Subversion Repositories HelenOS

Compare Revisions

No changes between revisions

Ignore whitespace Rev 3901 → Rev 3912

/branches/network/uspace/doc/doxygroups.h
27,20 → 27,60
*/
 
/**
* @defgroup net Networking Service
* @defgroup net Networking Subsystem
* @ingroup srvcs
*/
 
/**
* @defgroup arp Address Resolution Protocol (ARP) Service
* @defgroup netif Network interface drivers
* @ingroup net
*/
 
/**
* @defgroup lo Loopback Service
* @ingroup netif
*/
 
/**
* @defgroup eth Ethernet network interface layer Service
* @defgroup net_nil Network interface layer
* @ingroup net
*/
 
/**
* @defgroup eth Ethernet (IEEE 802.3) network interface layer Service
* @ingroup net_nil
*/
 
/**
* @defgroup net_il Inter-networking layer
* @ingroup net
*/
 
/**
* @defgroup arp Address Resolution Protocol (ARP) Service
* @ingroup net_il
*/
 
/**
* @defgroup ip Internet Protocol (IP) Service
* @ingroup net_il
*/
 
/**
* @defgroup net_tl Transport layer
* @ingroup net
*/
 
/**
* @defgroup tcp Transmission Control Protocol (TCP) Service
* @ingroup net_tl
*/
 
/**
* @defgroup packet Packet management system
* @ingroup net
*/
 
/**
* @cond amd64
* @defgroup pci PCI Service
/branches/network/uspace/srv/net/tl/tcp/tcp_module.h
26,12 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup tcp
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __NET_TCP_MODULE_H__
/branches/network/uspace/srv/net/tl/tcp/tcp.c
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup tcp
* @{
*/
 
/** @file
/branches/network/uspace/srv/net/tl/tcp/tcp.h
26,12 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup tcp
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __NET_TCP_H__
/branches/network/uspace/srv/net/tl/tcp/tcp_module.c
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup tcp
* @{
*/
 
/** @file
74,6 → 74,7
 
async_manager();
 
pm_destroy();
return EOK;
}
 
/branches/network/uspace/srv/net/include/sockaddr.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
/branches/network/uspace/srv/net/include/hardware.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup net_nil
* @{
*/
 
/** @file
* Hardware types according to the online IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
* 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.
* Names similar to the linux src/include/linux/if_arp.h header file.
*/
 
/branches/network/uspace/srv/net/include/protocol_map.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup net_nil
* @{
*/
 
/** @file
*
* Internetwork layer services - network interface layer service type translation.
*/
 
#ifndef __NET_PROTOCOL_MAP_H__
41,6 → 41,12
 
#include "ethernet_protocols.h"
 
/** Maps the internetwork layer service to the network interface layer type.
* @param nil Network interface layer service. Input parameter.
* @param il Internetwork layer service. Input parameter.
* @returns Network interface layer type of the internetworking layer service.
* @returns 0 if mapping is not found.
*/
static inline int protocol_map( services_t nil, services_t il ){
switch( nil ){
case SERVICE_ETHERNET:
57,6 → 63,12
}
}
 
/** Maps the network interface layer type to the internetwork layer service.
* @param nil Network interface layer service. Input parameter.
* @param protocol Network interface layer type. Input parameter.
* @returns Internetwork layer service of the network interface layer type.
* @returns 0 if mapping is not found.
*/
static inline services_t protocol_unmap( services_t nil, int protocol ){
switch( nil ){
case SERVICE_ETHERNET:
Property changes:
Deleted: svn:eol-style
-native
\ No newline at end of property
Added: svn:mergeinfo
/branches/network/uspace/srv/net/include/byteorder.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/branches/network/uspace/srv/net/include/ethernet_protocols.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup eth
* @{
*/
 
/** @file
* Ethernet protocol numbers according to the online IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009.
* Ethernet protocol numbers according to the on-line IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009.
* Names according to the linux src/include/linux/if_ether.h header file.
*/
 
Property changes:
Deleted: svn:mergeinfo
/branches/network/uspace/srv/net/include/protocols.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,7 → 31,7
*/
 
/** @file
* Internet protocol numbers according to the online IANA - Assigned Protocol numbers - <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml>, cited January 14 2009.
* Internet protocol numbers according to the on-line IANA - Assigned Protocol numbers - <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml>, cited January 14 2009.
* Names according to the linux src/include/linux/in.h header file.
*/
 
38,573 → 38,573
#ifndef __NET_IPPROTOCOLS_H__
#define __NET_IPPROTOCOLS_H__
 
/** IPv6 Hop-by-Hop Option interenet protocol number.
/** IPv6 Hop-by-Hop Option internet protocol number.
*/
#define IPPROTO_HOPOPT 0
 
/** Internet Control Message interenet protocol number.
/** Internet Control Message internet protocol number.
*/
#define IPPROTO_ICMP 1
 
/** Internet Group Management interenet protocol number.
/** Internet Group Management internet protocol number.
*/
#define IPPROTO_IGMP 2
 
/** Gateway-to-Gateway interenet protocol number.
/** Gateway-to-Gateway internet protocol number.
*/
#define IPPROTO_GGP 3
 
/** IP in IP (encapsulation) interenet protocol number.
/** IP in IP (encapsulation) internet protocol number.
*/
#define IPPROTO_IP 4
 
/** Stream interenet protocol number.
/** Stream internet protocol number.
*/
#define IPPROTO_ST 5
 
/** Transmission Control interenet protocol number.
/** Transmission Control internet protocol number.
*/
#define IPPROTO_TCP 6
 
/** CBT interenet protocol number.
/** CBT internet protocol number.
*/
#define IPPROTO_CBT 7
 
/** Exterior Gateway Protocol interenet protocol number.
/** Exterior Gateway Protocol internet protocol number.
*/
#define IPPROTO_EGP 8
 
/** any private interior gateway
(used by Cisco for their IGRP) interenet protocol number.
(used by Cisco for their IGRP) internet protocol number.
*/
#define IPPROTO_IGP 9
 
/** BBN RCC Monitoring interenet protocol number.
/** BBN RCC Monitoring internet protocol number.
*/
#define IPPROTO_BBN_RCC_MON 10
 
/** Network Voice Protocol interenet protocol number.
/** Network Voice Protocol internet protocol number.
*/
#define IPPROTO_NVP_II 11
 
/** PUP interenet protocol number.
/** PUP internet protocol number.
*/
#define IPPROTO_PUP 12
 
/** ARGUS interenet protocol number.
/** ARGUS internet protocol number.
*/
#define IPPROTO_ARGUS 13
 
/** EMCON interenet protocol number.
/** EMCON internet protocol number.
*/
#define IPPROTO_EMCON 14
 
/** Cross Net Debugger interenet protocol number.
/** Cross Net Debugger internet protocol number.
*/
#define IPPROTO_XNET 15
 
/** Chaos interenet protocol number.
/** Chaos internet protocol number.
*/
#define IPPROTO_CHAOS 16
 
/** User Datagram interenet protocol number.
/** User Datagram internet protocol number.
*/
#define IPPROTO_UDP 17
 
/** Multiplexing interenet protocol number.
/** Multiplexing internet protocol number.
*/
#define IPPROTO_MUX 18
 
/** DCN Measurement Subsystems interenet protocol number.
/** DCN Measurement Subsystems internet protocol number.
*/
#define IPPROTO_DCN_MEAS 19
 
/** Host Monitoring interenet protocol number.
/** Host Monitoring internet protocol number.
*/
#define IPPROTO_HMP 20
 
/** Packet Radio Measurement interenet protocol number.
/** Packet Radio Measurement internet protocol number.
*/
#define IPPROTO_PRM 21
 
/** XEROX NS IDP interenet protocol number.
/** XEROX NS IDP internet protocol number.
*/
#define IPPROTO_XNS_IDP 22
 
/** Trunk-1 interenet protocol number.
/** Trunk-1 internet protocol number.
*/
#define IPPROTO_TRUNK_1 23
 
/** Trunk-2 interenet protocol number.
/** Trunk-2 internet protocol number.
*/
#define IPPROTO_TRUNK_2 24
 
/** Leaf-1 interenet protocol number.
/** Leaf-1 internet protocol number.
*/
#define IPPROTO_LEAF_1 25
 
/** Leaf-2 interenet protocol number.
/** Leaf-2 internet protocol number.
*/
#define IPPROTO_LEAF_2 26
 
/** Reliable Data Protocol interenet protocol number.
/** Reliable Data Protocol internet protocol number.
*/
#define IPPROTO_RDP 27
 
/** Internet Reliable Transaction interenet protocol number.
/** Internet Reliable Transaction internet protocol number.
*/
#define IPPROTO_IRTP 28
 
/** ISO Transport Protocol Class 4 interenet protocol number.
/** ISO Transport Protocol Class 4 internet protocol number.
*/
#define IPPROTO_ISO_TP4 29
 
/** Bulk Data Transfer Protocol interenet protocol number.
/** Bulk Data Transfer Protocol internet protocol number.
*/
#define IPPROTO_NETBLT 30
 
/** MFE Network Services Protocol interenet protocol number.
/** MFE Network Services Protocol internet protocol number.
*/
#define IPPROTO_MFE_NSP 31
 
/** MERIT Internodal Protocol interenet protocol number.
/** MERIT Internodal Protocol internet protocol number.
*/
#define IPPROTO_MERIT_INP 32
 
/** Datagram Congestion Control Protocol interenet protocol number.
/** Datagram Congestion Control Protocol internet protocol number.
*/
#define IPPROTO_DCCP 33
 
/** Third Party Connect Protocol interenet protocol number.
/** Third Party Connect Protocol internet protocol number.
*/
#define IPPROTO_3PC 34
 
/** Inter-Domain Policy Routing Protocol interenet protocol number.
/** Inter-Domain Policy Routing Protocol internet protocol number.
*/
#define IPPROTO_IDPR 35
 
/** XTP interenet protocol number.
/** XTP internet protocol number.
*/
#define IPPROTO_XTP 36
 
/** Datagram Delivery Protocol interenet protocol number.
/** Datagram Delivery Protocol internet protocol number.
*/
#define IPPROTO_DDP 37
 
/** IDPR Control Message Transport Proto interenet protocol number.
/** IDPR Control Message Transport Proto internet protocol number.
*/
#define IPPROTO_IDPR_CMTP 38
 
/** TP++ Transport Protocol interenet protocol number.
/** TP++ Transport Protocol internet protocol number.
*/
#define IPPROTO_TP 39
 
/** IL Transport Protocol interenet protocol number.
/** IL Transport Protocol internet protocol number.
*/
#define IPPROTO_IL 40
 
/** Ipv6 interenet protocol number.
/** Ipv6 internet protocol number.
*/
#define IPPROTO_IPV6 41
 
/** Source Demand Routing Protocol interenet protocol number.
/** Source Demand Routing Protocol internet protocol number.
*/
#define IPPROTO_SDRP 42
 
/** Routing Header for IPv6 interenet protocol number.
/** Routing Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Route 43
 
/** Fragment Header for IPv6 interenet protocol number.
/** Fragment Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Frag 44
 
/** Inter-Domain Routing Protocol interenet protocol number.
/** Inter-Domain Routing Protocol internet protocol number.
*/
#define IPPROTO_IDRP 45
 
/** Reservation Protocol interenet protocol number.
/** Reservation Protocol internet protocol number.
*/
#define IPPROTO_RSVP 46
 
/** General Routing Encapsulation interenet protocol number.
/** General Routing Encapsulation internet protocol number.
*/
#define IPPROTO_GRE 47
 
/** Dynamic Source Routing Protocol interenet protocol number.
/** Dynamic Source Routing Protocol internet protocol number.
*/
#define IPPROTO_DSR 48
 
/** BNA interenet protocol number.
/** BNA internet protocol number.
*/
#define IPPROTO_BNA 49
 
/** Encap Security Payload interenet protocol number.
/** Encap Security Payload internet protocol number.
*/
#define IPPROTO_ESP 50
 
/** Authentication Header interenet protocol number.
/** Authentication Header internet protocol number.
*/
#define IPPROTO_AH 51
 
/** Integrated Net Layer Security TUBA interenet protocol number.
/** Integrated Net Layer Security TUBA internet protocol number.
*/
#define IPPROTO_I_NLSP 52
 
/** IP with Encryption interenet protocol number.
/** IP with Encryption internet protocol number.
*/
#define IPPROTO_SWIPE 53
 
/** NBMA Address Resolution Protocol interenet protocol number.
/** NBMA Address Resolution Protocol internet protocol number.
*/
#define IPPROTO_NARP 54
 
/** IP Mobility interenet protocol number.
/** IP Mobility internet protocol number.
*/
#define IPPROTO_MOBILE 55
 
/** Transport Layer Security Protocol
using Kryptonet key management interenet protocol number.
using Kryptonet key management internet protocol number.
*/
#define IPPROTO_TLSP 56
 
/** SKIP interenet protocol number.
/** SKIP internet protocol number.
*/
#define IPPROTO_SKIP 57
 
/** ICMP for IPv6 interenet protocol number.
/** ICMP for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_ICMP 58
 
/** No Next Header for IPv6 interenet protocol number.
/** No Next Header for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_NoNxt 59
 
/** Destination Options for IPv6 interenet protocol number.
/** Destination Options for IPv6 internet protocol number.
*/
#define IPPROTO_IPv6_Opts 60
 
/** Any host internal protocol interenet protocol number.
/** Any host internal protocol internet protocol number.
*/
#define IPPROTO_AHIP 61
 
/** CFTP interenet protocol number.
/** CFTP internet protocol number.
*/
#define IPPROTO_CFTP 62
 
/** Any local network interenet protocol number.
/** Any local network internet protocol number.
*/
#define IPPROTO_ALN 63
 
/** SATNET and Backroom EXPAK interenet protocol number.
/** SATNET and Backroom EXPAK internet protocol number.
*/
#define IPPROTO_SAT_EXPAK 64
 
/** Kryptolan interenet protocol number.
/** Kryptolan internet protocol number.
*/
#define IPPROTO_KRYPTOLAN 65
 
/** MIT Remote Virtual Disk Protocol interenet protocol number.
/** MIT Remote Virtual Disk Protocol internet protocol number.
*/
#define IPPROTO_RVD 66
 
/** Internet Pluribus Packet Core interenet protocol number.
/** Internet Pluribus Packet Core internet protocol number.
*/
#define IPPROTO_IPPC 67
 
/** Any distributed file system interenet protocol number.
/** Any distributed file system internet protocol number.
*/
#define IPPROTO_ADFS 68
 
/** SATNET Monitoring interenet protocol number.
/** SATNET Monitoring internet protocol number.
*/
#define IPPROTO_SAT_MON 69
 
/** VISA Protocol interenet protocol number.
/** VISA Protocol internet protocol number.
*/
#define IPPROTO_VISA 70
 
/** Internet Packet Core Utility interenet protocol number.
/** Internet Packet Core Utility internet protocol number.
*/
#define IPPROTO_IPCV 71
 
/** Computer Protocol Network Executive interenet protocol number.
/** Computer Protocol Network Executive internet protocol number.
*/
#define IPPROTO_CPNX 72
 
/** Computer Protocol Heart Beat interenet protocol number.
/** Computer Protocol Heart Beat internet protocol number.
*/
#define IPPROTO_CPHB 73
 
/** Wang Span Network interenet protocol number.
/** Wang Span Network internet protocol number.
*/
#define IPPROTO_WSN 74
 
/** Packet Video Protocol interenet protocol number.
/** Packet Video Protocol internet protocol number.
*/
#define IPPROTO_PVP 75
 
/** Backroom SATNET Monitoring interenet protocol number.
/** Backroom SATNET Monitoring internet protocol number.
*/
#define IPPROTO_BR_SAT_MON 76
 
/** SUN ND IPPROTOCOL_Temporary interenet protocol number.
/** SUN ND IPPROTOCOL_Temporary internet protocol number.
*/
#define IPPROTO_SUN_ND 77
 
/** WIDEBAND Monitoring interenet protocol number.
/** WIDEBAND Monitoring internet protocol number.
*/
#define IPPROTO_WB_MON 78
 
/** WIDEBAND EXPAK interenet protocol number.
/** WIDEBAND EXPAK internet protocol number.
*/
#define IPPROTO_WB_EXPAK 79
 
/** ISO Internet Protocol interenet protocol number.
/** ISO Internet Protocol internet protocol number.
*/
#define IPPROTO_ISO_IP 80
 
/** VMTP interenet protocol number.
/** VMTP internet protocol number.
*/
#define IPPROTO_VMTP 81
 
/** SECURE-VMTP interenet protocol number.
/** SECURE-VMTP internet protocol number.
*/
#define IPPROTO_SECURE_VMTP 82
 
/** VINES interenet protocol number.
/** VINES internet protocol number.
*/
#define IPPROTO_VINES 83
 
/** TTP interenet protocol number.
/** TTP internet protocol number.
*/
#define IPPROTO_TTP 84
 
/** NSFNET-IGP interenet protocol number.
/** NSFNET-IGP internet protocol number.
*/
#define IPPROTO_NSFNET_IGP 85
 
/** Dissimilar Gateway Protocol interenet protocol number.
/** Dissimilar Gateway Protocol internet protocol number.
*/
#define IPPROTO_DGP 86
 
/** TCF interenet protocol number.
/** TCF internet protocol number.
*/
#define IPPROTO_TCF 87
 
/** EIGRP interenet protocol number.
/** EIGRP internet protocol number.
*/
#define IPPROTO_EIGRP 88
 
/** OSPFIGP interenet protocol number.
/** OSPFIGP internet protocol number.
*/
#define IPPROTO_OSPFIGP 89
 
/** Sprite RPC Protocol interenet protocol number.
/** Sprite RPC Protocol internet protocol number.
*/
#define IPPROTO_Sprite_RPC 90
 
/** Locus Address Resolution Protocol interenet protocol number.
/** Locus Address Resolution Protocol internet protocol number.
*/
#define IPPROTO_LARP 91
 
/** Multicast Transport Protocol interenet protocol number.
/** Multicast Transport Protocol internet protocol number.
*/
#define IPPROTO_MTP 92
 
/** AX.25 Frames interenet protocol number.
/** AX.25 Frames internet protocol number.
*/
#define IPPROTO_AX25 93
 
/** IP-within-IP Encapsulation Protocol interenet protocol number.
/** IP-within-IP Encapsulation Protocol internet protocol number.
*/
#define IPPROTO_IPIP 94
 
/** Mobile Internetworking Control Pro. interenet protocol number.
/** Mobile Internetworking Control Pro. internet protocol number.
*/
#define IPPROTO_MICP 95
 
/** Semaphore Communications Sec. Pro. interenet protocol number.
/** Semaphore Communications Sec. Pro. internet protocol number.
*/
#define IPPROTO_SCC_SP 96
 
/** Ethernet-within-IP Encapsulation interenet protocol number.
/** Ethernet-within-IP Encapsulation internet protocol number.
*/
#define IPPROTO_ETHERIP 97
 
/** Encapsulation Header interenet protocol number.
/** Encapsulation Header internet protocol number.
*/
#define IPPROTO_ENCAP 98
 
/** Any private encryption scheme interenet protocol number.
/** Any private encryption scheme internet protocol number.
*/
#define IPPROTO_APES 99
 
/** GMTP interenet protocol number.
/** GMTP internet protocol number.
*/
#define IPPROTO_GMTP 100
 
/** Ipsilon Flow Management Protocol interenet protocol number.
/** Ipsilon Flow Management Protocol internet protocol number.
*/
#define IPPROTO_IFMP 101
 
/** PNNI over IP interenet protocol number.
/** PNNI over IP internet protocol number.
*/
#define IPPROTO_PNNI 102
 
/** Protocol Independent Multicast interenet protocol number.
/** Protocol Independent Multicast internet protocol number.
*/
#define IPPROTO_PIM 103
 
/** ARIS interenet protocol number.
/** ARIS internet protocol number.
*/
#define IPPROTO_ARIS 104
 
/** SCPS interenet protocol number.
/** SCPS internet protocol number.
*/
#define IPPROTO_SCPS 105
 
/** QNX interenet protocol number.
/** QNX internet protocol number.
*/
#define IPPROTO_QNX 106
 
/** Active Networks interenet protocol number.
/** Active Networks internet protocol number.
*/
#define IPPROTO_AN 107
 
/** IP Payload Compression Protocol interenet protocol number.
/** IP Payload Compression Protocol internet protocol number.
*/
#define IPPROTO_IPComp 108
 
/** Sitara Networks Protocol interenet protocol number.
/** Sitara Networks Protocol internet protocol number.
*/
#define IPPROTO_SNP 109
 
/** Compaq Peer Protocol interenet protocol number.
/** Compaq Peer Protocol internet protocol number.
*/
#define IPPROTO_Compaq_Peer 110
 
/** IPX in IP interenet protocol number.
/** IPX in IP internet protocol number.
*/
#define IPPROTO_IPX_in_IP 111
 
/** Virtual Router Redundancy Protocol interenet protocol number.
/** Virtual Router Redundancy Protocol internet protocol number.
*/
#define IPPROTO_VRRP 112
 
/** PGM Reliable Transport Protocol interenet protocol number.
/** PGM Reliable Transport Protocol internet protocol number.
*/
#define IPPROTO_PGM 113
 
/** Any 0-hop protocol interenet protocol number.
/** Any 0-hop protocol internet protocol number.
*/
#define IPPROTO_A0HP 114
 
/** Layer Two Tunneling Protocol interenet protocol number.
/** Layer Two Tunneling Protocol internet protocol number.
*/
#define IPPROTO_L2TP 115
 
/** D-II Data Exchange (DDX) interenet protocol number.
/** D-II Data Exchange (DDX) internet protocol number.
*/
#define IPPROTO_DDX 116
 
/** Interactive Agent Transfer Protocol interenet protocol number.
/** Interactive Agent Transfer Protocol internet protocol number.
*/
#define IPPROTO_IATP 117
 
/** Schedule Transfer Protocol interenet protocol number.
/** Schedule Transfer Protocol internet protocol number.
*/
#define IPPROTO_STP 118
 
/** SpectraLink Radio Protocol interenet protocol number.
/** SpectraLink Radio Protocol internet protocol number.
*/
#define IPPROTO_SRP 119
 
/** UTI interenet protocol number.
/** UTI internet protocol number.
*/
#define IPPROTO_UTI 120
 
/** Simple Message Protocol interenet protocol number.
/** Simple Message Protocol internet protocol number.
*/
#define IPPROTO_SMP 121
 
/** SM interenet protocol number.
/** SM internet protocol number.
*/
#define IPPROTO_SM 122
 
/** Performance Transparency Protocol interenet protocol number.
/** Performance Transparency Protocol internet protocol number.
*/
#define IPPROTO_PTP 123
 
/** ISIS over IPv4 interenet protocol number.
/** ISIS over IPv4 internet protocol number.
*/
#define IPPROTO_ISIS 124
 
/** FIRE interenet protocol number.
/** FIRE internet protocol number.
*/
#define IPPROTO_FIRE 125
 
/** Combat Radio Transport Protocol interenet protocol number.
/** Combat Radio Transport Protocol internet protocol number.
*/
#define IPPROTO_CRTP 126
 
/** Combat Radio User Datagram interenet protocol number.
/** Combat Radio User Datagram internet protocol number.
*/
#define IPPROTO_CRUDP 127
 
/** SSCOPMCE interenet protocol number.
/** SSCOPMCE internet protocol number.
*/
#define IPPROTO_SSCOPMCE 128
 
/** IPLT interenet protocol number.
/** IPLT internet protocol number.
*/
#define IPPROTO_IPLT 129
 
/** Secure Packet Shield interenet protocol number.
/** Secure Packet Shield internet protocol number.
*/
#define IPPROTO_SPS 130
 
/** Private IP Encapsulation within IP interenet protocol number.
/** Private IP Encapsulation within IP internet protocol number.
*/
#define IPPROTO_PIPE 131
 
/** Stream Control Transmission Protocol interenet protocol number.
/** Stream Control Transmission Protocol internet protocol number.
*/
#define IPPROTO_SCTP 132
 
/** Fibre Channel interenet protocol number.
/** Fibre Channel internet protocol number.
*/
#define IPPROTO_FC 133
 
/** RSVP-E2E-IGNORE interenet protocol number.
/** RSVP-E2E-IGNORE internet protocol number.
*/
#define IPPROTO_RSVP_E2E_IGNORE 134
 
/** Mobility Header interenet protocol number.
/** Mobility Header internet protocol number.
*/
#define IPPROTO_MH 135
 
/** UDPLite interenet protocol number.
/** UDPLite internet protocol number.
*/
#define IPPROTO_UDPLITE 136
 
/** MPLS-in-IP interenet protocol number.
/** MPLS-in-IP internet protocol number.
*/
#define IPPROTO_MPLS_in_IP 137
 
/** MANET Protocols interenet protocol number.
/** MANET Protocols internet protocol number.
*/
#define IPPROTO_manet 138
 
/** Host Identity Protocol interenet protocol number.
/** Host Identity Protocol internet protocol number.
*/
#define IPPROTO_HIP 139
 
/** Raw interenet protocol number.
/** Raw internet protocol number.
*/
#define IPPROTO_RAW 255
 
/** Maximum interenet protocol number.
/** Maximum internet protocol number.
*/
#define IPPROTO_MAX ( IPPROTO_RAW + 1 )
 
/branches/network/uspace/srv/net/include/socket.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
239,7 → 239,7
#define SOL_BLUETOOTH 274
*/
//
/** IPX options.
///** IPX options.
// */
//#define IPX_TYPE 1
 
/branches/network/uspace/srv/net/structures/measured_strings.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,7 → 31,7
*/
 
/** @file
* A&nbsp;character string with measured length implementation file.
* Character string with measured length implementation.
* @see measured_strings.h
*/
 
52,7 → 52,7
* @param strings The measured strings array to be processed. Input parameter.
* @param count The measured strings array size. Input parameter.
* @returns The computed sizes array.
* @returns NULL if there is no memory left.
* @returns NULL if there is not enough memory left.
*/
size_t * prepare_lengths( const measured_string_ref strings, size_t count );
 
91,7 → 91,7
free( lengths );
return EINVAL;
}
if( ERROR_OCCURED( ipc_data_write_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){
if( ERROR_OCCURRED( ipc_data_write_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){
free( lengths );
return ERROR_CODE;
}
146,7 → 146,7
free( lengths );
return EINVAL;
}
if( ERROR_OCCURED( ipc_data_read_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){
if( ERROR_OCCURRED( ipc_data_read_finalize( callid, lengths, sizeof( size_t ) * ( count + 1 )))){
free( lengths );
return ERROR_CODE;
}
175,7 → 175,7
}
lengths = ( size_t * ) malloc( sizeof( size_t ) * ( count + 1 ));
if( ! lengths ) return ENOMEM;
if( ERROR_OCCURED( ipc_data_read_start( phone, lengths, sizeof( size_t ) * ( count + 1 )))){
if( ERROR_OCCURRED( ipc_data_read_start( phone, lengths, sizeof( size_t ) * ( count + 1 )))){
free( lengths );
return ERROR_CODE;
}
215,7 → 215,7
}
lengths = prepare_lengths( strings, count );
if( ! lengths ) return ENOMEM;
if( ERROR_OCCURED( ipc_data_write_start( phone, lengths, sizeof( size_t ) * ( count + 1 )))){
if( ERROR_OCCURRED( ipc_data_write_start( phone, lengths, sizeof( size_t ) * ( count + 1 )))){
free( lengths );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/structures/char_map.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,57 → 27,51
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
* A&nbsp;character string to integer map header file.
* Character string to integer map.
*/
 
#ifndef __CHAR_MAP_H__
#define __CHAR_MAP_H__
 
/** An&nbsp;invalid assigned value used also if an&nbsp;entry does not exist.
/** Invalid assigned value used also if an&nbsp;entry does not exist.
*/
#define CHAR_MAP_NULL ( -1 )
 
/** A&nbsp;type definition of a&nbsp;character string to integer map.
/** Type definition of the character string to integer map.
* @see char_map
*/
typedef struct char_map char_map_t;
 
/** A&nbsp;type definition of a&nbsp;character string to integer map pointer.
/** Type definition of the character string to integer map pointer.
* @see char_map
*/
typedef char_map_t * char_map_ref;
 
/** A&nbsp;character string to integer map item.
/** Character string to integer map item.
* This structure recursivelly contains itself as a&nbsp;character by character tree.
* The actually mapped character string consists o fall the parent characters and the actual one.
*/
struct char_map{
 
/** An actually mapped character.
/** Actually mapped character.
*/
char c;
 
/** A&nbsp;stored integral value.
/** Stored integral value.
*/
int value;
 
/** A&nbsp;next character array size.
/** Next character array size.
*/
int size;
 
/** The first free position in the next character array.
/** First free position in the next character array.
*/
int next;
 
/** The next character array.
/** Next character array.
*/
char_map_ref * items;
 
/** The consistency check magic value.
/** Consistency check magic value.
*/
int magic;
};
84,13 → 78,13
 
/** Adds the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0') character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/
104,8 → 98,8
/** Excludes the value assigned to the key from the map.
* The entry is cleared from the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
113,8 → 107,8
 
/** Returns the value assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
131,19 → 125,19
* @param map The character string to integer map. Input/output parameter.
* @returns EOK on success.
* @returns EINVAL if the map parameter is NULL.
* @returns ENOMEM if there is no memory left.
* @returns ENOMEM if there is not enough memory left.
*/
int char_map_initialize( char_map_ref map );
 
/** Adds or updates the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\0) character.
* @returns EINVAL if the length parameter zero (0) and the identifier parameter is an empty character string (the first character is the terminating zero ('\\0) character.
* @returns EEXIST if the key character string is already used.
* @returns Other error codes as defined for the char_map_add_item() function.
*/
/branches/network/uspace/srv/net/structures/measured_strings.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,33 → 31,31
*/
 
/** @file
* A&nbsp;character string with measured length header file.
* This structure has been designed for serialization of character strings between modules.
* Character string with measured length.
* The structure has been designed for serialization of character strings between modules.
*/
 
#ifndef __MEASURED_STRINGS_H__
#define __MEASURED_STRINGS_H__
 
/** A&nbsp;type definition of a&nbsp;character string with measured length.
/** Type definition of the character string with measured length.
* @see measured_string
*/
typedef struct measured_string measured_string_t;
 
/** A&nbsp;type definition of a&nbsp;character string with measured length pointer.
/** Type definition of the character string with measured length pointer.
* @see measured_string
*/
typedef measured_string_t * measured_string_ref;
 
/** A&nbsp;character string with measured length.
/** Character string with measured length.
* This structure has been designed for serialization of character strings between modules.
*/
struct measured_string{
 
/** The character string data.
/** Character string data.
*/
char * value;
 
/** The character string length.
/** Character string length.
*/
size_t length;
};
66,9 → 64,9
* If the measured string is being freed, whole memory block is freed.
* The measured string should be used only as a&nbsp;constant.
* @param string The initial character string to be stored. Input parameter.
* @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\0') character otherwise. Input parameter.
* @returns The new bundled charecter string with measured length.
* @returns NULL if there is no memory left.
* @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\\0') character otherwise. Input parameter.
* @returns The new bundled character string with measured length.
* @returns NULL if there is not enough memory left.
*/
measured_string_ref measured_string_create_bulk( const char * string, size_t length );
 
83,7 → 81,7
* @returns EINVAL if the count parameter is zero (0).
* @returns EINVAL if the sent array differs in size.
* @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
* @returns ENOMEM if there is no memory left.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the ipc_data_write_finalize() function.
*/
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count );
112,7 → 110,7
* @returns EINVAL if the strings or data parameter is NULL.
* @returns EINVAL if the phone or count parameter is not positive (<=0).
* @returns EINVAL if the sent array differs in size.
* @returns ENOMEM if there is no memory left.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the ipc_data_read_start() function.
*/
int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count );
/branches/network/uspace/srv/net/structures/generic_field.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,11 → 27,10
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __GENERIC_FIELD_H__
/branches/network/uspace/srv/net/structures/packet/packet_server.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,17
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet server.
* The hosting module has to be compiled with both the packet.c and the packet_server.c source files.
* To function correctly, initialization of the packet map by the pm_init() function has to happen at the first place.
* Then the packet messages have to be processed by the packet_server_message() function.
* The packet map should be released by the pm_destroy() function during the module termination.
* @see IS_NET_PACKET_MESSAGE()
*/
 
#ifndef __NET_PACKET_SERVER_H__
38,6 → 44,15
 
#include <ipc/ipc.h>
 
/** Processes the packet server message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* \todo all possible message returns?
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
*/
int packet_server_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
#endif
/branches/network/uspace/srv/net/structures/packet/packet_header.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet header.
*/
 
#ifndef __NET_PACKET_HEADER_H__
40,27 → 41,73
 
#include "packet.h"
 
/** Packet integrity check magic value.
*/
#define PACKET_MAGIC_VALUE 0x11227788
 
/** Packet header.
*/
struct packet{
/** Packet identifier.
*/
packet_id_t packet_id;
//TODO packet owner not used
/** Packet owner.
*/
services_t owner;
//TODO needed packet mode?
/** Packet mode.
*/
packet_mode_t mode;
/** Packet queue sorting value.
* The packet queue is sorted the ascending order.
*/
int order;
/** Packet metric.
*/
size_t metric;
/** Previous packet in the queue.
*/
packet_id_t previous;
/** Next packet in the queue.
*/
packet_id_t next;
/** Total length of the packet.
* Contains the header, the addresses and the data of the packet.
* Corresponds to the mapped sharable memory block.
*/
size_t length;
/** Source and destination addresses length.
*/
size_t addr_len;
/** Souce address offset in bytes from the beginning of the packet header.
*/
size_t src_addr;
/** Destination address offset in bytes from the beginning of the packet header.
*/
size_t dest_addr;
/** Reserved data prefix length in bytes.
*/
size_t max_prefix;
/** Reserved content length in bytes.
*/
size_t max_content;
/** Actual data start offset in bytes from the beginning of the packet header.
*/
size_t data_start;
/** Actual data end offset in bytes from the beginning of the packet header.
*/
size_t data_end;
/** Integrity check magic value.
*/
int magic_value;
};
 
/** Returns whether the packet is valid.
* @param packet The packet to be checked. Input parameter.
* @returns true if the packet is not NULL and the magic value is correct.
* @returns false otherwise.
*/
static inline int packet_is_valid( const packet_t packet ){
return packet && ( packet->magic_value == PACKET_MAGIC_VALUE );
}
/branches/network/uspace/srv/net/structures/packet/packet_client.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet client implementation.
*/
 
#include <async.h>
50,6 → 51,16
#include "packet_header.h"
#include "packet_client.h"
 
/** Obtains the packet from the packet server as the shared memory block.
* Creates the local packet mapping as well.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference pointer to store the received packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param size The packet total size in bytes. Input parameter.
* @returns EOK on success.
* \todo ipc_share_in_start() error?
* @returns Other error codes as defined for the pm_add() function.
*/
int packet_return( int phone, packet_ref packet, packet_id_t packet_id, size_t size );
 
packet_t packet_copy( int phone, services_t owner, const packet_t packet ){
74,31 → 85,33
return EOK;
}
 
void * packet_prepend( packet_t packet, size_t length ){
void * packet_prefix( packet_t packet, size_t length ){
if(( ! packet_is_valid( packet )) || ( packet->data_start - sizeof( struct packet ) - 2 * packet->addr_len < length )) return NULL;
packet->data_start -= length;
return ( void * ) packet + packet->data_start;
}
 
void * packet_append( packet_t packet, size_t length ){
void * packet_suffix( packet_t packet, size_t length ){
if(( ! packet_is_valid( packet )) || ( packet->data_end + length >= packet->length )) return NULL;
packet->data_end += length;
return ( void * ) packet + packet->data_end - length;
}
 
int packet_trim( packet_t packet, size_t prefix, size_t sufix ){
if(( ! packet_is_valid( packet )) || ( prefix + sufix > packet->data_end - packet->data_start )) return EINVAL;
int packet_trim( packet_t packet, size_t prefix, size_t suffix ){
if( ! packet_is_valid( packet )) return EINVAL;
if( prefix + suffix > packet->data_end - packet->data_start ) return ENOMEM;
packet->data_start += prefix;
packet->data_end -= sufix;
packet->data_end -= suffix;
return EOK;
}
 
packet_id_t packet_get_id( packet_t packet ){
packet_id_t packet_get_id( const packet_t packet ){
return packet_is_valid( packet ) ? packet->packet_id : 0;
}
 
int packet_get_addr( const packet_t packet, uint8_t ** src, uint8_t ** dest ){
if( !( packet_is_valid( packet ) && src && dest )) return 0;
if( !( packet_is_valid( packet ) && src && dest )) return EINVAL;
if( ! packet->addr_len ) return 0;
* src = ( void * ) packet + packet->src_addr;
* dest = ( void * ) packet + packet->dest_addr;
return packet->addr_len;
116,13 → 129,14
 
packet_mode_t packet_get_mode( const packet_t packet ){
if( packet_is_valid( packet )) return packet->mode;
return PM_ONEWAY;
return PM_ONE_WAY;
}
 
int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len ){
size_t padding;
 
if( !( packet_is_valid( packet ) && ( packet->addr_len >= addr_len ))) return EINVAL;
if( ! packet_is_valid( packet )) return EINVAL;
if( packet->addr_len >= addr_len ) return ENOMEM;
padding = packet->addr_len - addr_len;
if( src ){
memcpy(( void * ) packet + packet->src_addr, src, addr_len );
168,20 → 182,21
 
aid_t message;
ipc_call_t answer;
ipcarg_t result;
 
message = async_send_1( phone, NET_PACKET_GET, packet_id, & answer );
* packet = ( packet_t ) as_get_mappable_page( size );
if( ERROR_OCCURED( ipc_share_in_start_0_0( phone, * packet, size ))
|| ERROR_OCCURED( pm_add( * packet ))){
if( ERROR_OCCURRED( ipc_share_in_start_0_0( phone, * packet, size ))
|| ERROR_OCCURRED( pm_add( * packet ))){
munmap( * packet, size );
async_wait_for( message, NULL );
return ERROR_CODE;
}
async_wait_for( message, NULL );
return EOK;
async_wait_for( message, & result );
return result;
}
 
packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_sufix ){
packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix ){
ERROR_DECLARE;
 
packet_id_t packet_id;
188,8 → 203,8
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURED( async_req_5_2( phone, NET_PACKET_CREATE_5, owner, max_content, addr_len, max_prefix, max_sufix, & packet_id, & size ))
|| ERROR_OCCURED( packet_return( phone, & packet, packet_id, size ))){
if( ERROR_OCCURRED( async_req_5_2( phone, NET_PACKET_CREATE_5, owner, max_content, addr_len, max_prefix, max_suffix, & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
202,8 → 217,8
unsigned int size;
packet_t packet;
 
if( ERROR_OCCURED( async_req_2_2( phone, NET_PACKET_CREATE_1, owner, content, & packet_id, & size ))
|| ERROR_OCCURED( packet_return( phone, & packet, packet_id, size ))){
if( ERROR_OCCURRED( async_req_2_2( phone, NET_PACKET_CREATE_1, owner, content, & packet_id, & size ))
|| ERROR_OCCURRED( packet_return( phone, & packet, packet_id, size ))){
return NULL;
}
return packet;
/branches/network/uspace/srv/net/structures/packet/packet.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,13
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet map and queue implementation.
* This file has to be compiled with both the packet server and the client.
*/
 
#include <errno.h>
48,26 → 50,51
#include "packet.h"
 
// TODO power of 2 aritmetic => div and mod speedup?
/** Packet map page size.
*/
#define PACKET_MAP_SIZE 100
 
/** Returns the packet map page index.
* @param packet_id The packet identifier.
*/
#define PACKET_MAP_PAGE( packet_id ) ((( packet_id ) - 1 ) / PACKET_MAP_SIZE )
 
/** Returns the packet index in the corresponding packet map page.
* @param packet_id The packet identifier.
*/
#define PACKET_MAP_INDEX( packet_id ) ((( packet_id ) - 1 ) % PACKET_MAP_SIZE )
 
 
int packet_destroy( packet_t packet );
 
/** Type definition of the packet map page.
*/
typedef packet_t packet_map_t[ PACKET_MAP_SIZE ];
/** Type definition of the packet map page pointer.
*/
typedef packet_map_t * packet_map_ref;
 
/** Packet map.
* Maps packet identifiers to the packet references.
* @see generic_field.h
*/
GENERIC_FIELD_DECLARE( gpm, packet_map_t );
 
GENERIC_FIELD_IMPLEMENT( gpm, packet_map_t );
/** Releases the packet.
* @param packet The packet to be released. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
*/
int packet_destroy( packet_t packet );
 
/** Packet map global data.
*/
static struct{
// TODO lock
gpm_t map;
/** Packet map.
*/
gpm_t packet_map;
} pm_globals;
 
GENERIC_FIELD_IMPLEMENT( gpm, packet_map_t );
 
int packet_destroy( packet_t packet ){
if( ! packet_is_valid( packet )) return EINVAL;
return munmap( packet, packet->length );
74,7 → 101,7
}
 
int pm_init( void ){
return gpm_initialize( & pm_globals.map );
return gpm_initialize( & pm_globals.packet_map );
}
 
packet_t pm_find( packet_id_t packet_id ){
81,8 → 108,8
packet_map_ref map;
 
if( ! packet_id ) return NULL;
if( packet_id > PACKET_MAP_SIZE * gpm_count( & pm_globals.map )) return NULL;
map = gpm_get_index( & pm_globals.map, PACKET_MAP_PAGE( packet_id ));
if( packet_id > PACKET_MAP_SIZE * gpm_count( & pm_globals.packet_map )) return NULL;
map = gpm_get_index( & pm_globals.packet_map, PACKET_MAP_PAGE( packet_id ));
if( ! map ) return NULL;
return ( * map )[ PACKET_MAP_INDEX( packet_id ) ];
}
92,19 → 119,19
 
packet_map_ref map;
 
if(( ! packet_is_valid( packet )) || ( gpm_count( & pm_globals.map ) < -1 )) return EINVAL;
if( PACKET_MAP_PAGE( packet->packet_id ) < gpm_count( & pm_globals.map )){
map = gpm_get_index( & pm_globals.map, PACKET_MAP_PAGE( packet->packet_id ));
if(( ! packet_is_valid( packet )) || ( gpm_count( & pm_globals.packet_map ) < 0 )) return EINVAL;
if( PACKET_MAP_PAGE( packet->packet_id ) < gpm_count( & pm_globals.packet_map )){
map = gpm_get_index( & pm_globals.packet_map, PACKET_MAP_PAGE( packet->packet_id ));
}else{
do{
map = ( packet_map_ref ) malloc( sizeof( packet_map_t ));
if( ! map ) return ENOMEM;
memset( map, 0, sizeof( packet_map_t ));
if(( ERROR_CODE = gpm_add( & pm_globals.map, map )) < 0 ){
if(( ERROR_CODE = gpm_add( & pm_globals.packet_map, map )) < 0 ){
free( map );
return ERROR_CODE;
}
}while( PACKET_MAP_PAGE( packet->packet_id ) >= gpm_count( & pm_globals.map ));
}while( PACKET_MAP_PAGE( packet->packet_id ) >= gpm_count( & pm_globals.packet_map ));
}
( * map )[ PACKET_MAP_INDEX( packet->packet_id ) ] = packet;
return EOK;
116,9 → 143,9
packet_map_ref map;
packet_t packet;
 
count = gpm_count( & pm_globals.map );
count = gpm_count( & pm_globals.packet_map );
while( count > 0 ){
map = gpm_get_index( & pm_globals.map, count - 1 );
map = gpm_get_index( & pm_globals.packet_map, count - 1 );
for( index = PACKET_MAP_SIZE - 1; index >= 0; -- index ){
packet = ( * map )[ index ];
if( packet_is_valid( packet )){
126,7 → 153,7
}
}
}
gpm_destroy( & pm_globals.map );
gpm_destroy( & pm_globals.packet_map );
}
 
packet_t pq_add( packet_t first, packet_t packet, int order, size_t metric ){
/branches/network/uspace/srv/net/structures/packet/packet_client.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,17
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet client.
* The hosting module has to be compiled with both the packet.c and the packet_client.c source files.
* To function correctly, initialization of the packet map by the pm_init() function has to happen at the first place.
* The module should not send the packet messages to the packet server but use the functions provided.
* The packet map should be released by the pm_destroy() function during the module termination.
* @see packet.h
*/
 
#ifndef __NET_PACKET_CLIENT_H__
38,28 → 44,197
 
#include "packet.h"
 
#define PACKET_PREPEND( packet, type ) ( type * ) packet_prepend(( packet ), sizeof( type ))
#define PACKET_APPEND( packet, type ) ( type * ) packet_append(( packet ), sizeof( type ))
#define PACKET_TRIM( packet, prefix, sufix ) packet_trim(( packet ), sizeof( prefix ), sizeof( sufix ))
/** Allocates the specified type right before the actual packet content and returns its pointer.
* The wrapper of the packet_prepend() function.
* @param packet The packet to be used. Input parameter.
* @param type The type to be allocated at the beginning of the packet content. Input parameter.
* @returns The typed pointer to the allocated memory.
* @returns NULL if the packet is not valid.
* @returns NULL if there is not enough memory left.
*/
#define PACKET_PREFIX( packet, type ) ( type * ) packet_prepend(( packet ), sizeof( type ))
 
void * packet_prepend( packet_t packet, size_t length );
void * packet_append( packet_t packet, size_t length );
/** Allocates the specified type right after the actual packet content and returns its pointer.
* The wrapper of the packet_append() function.
* @param packet The packet to be used. Input parameter.
* @param type The type to be allocated at the end of the packet content. Input parameter.
* @returns The typed pointer to the allocated memory.
* @returns NULL if the packet is not valid.
* @returns NULL if there is not enough memory left.
*/
#define PACKET_SUFFIX( packet, type ) ( type * ) packet_append(( packet ), sizeof( type ))
 
/** Trims the actual packet content by the specified prefix and suffix types.
* The wrapper of the packet_trim() function.
* @param packet The packet to be trimmed. Input parameter.
* @param prefix The type of the prefix to be removed from the beginning of the packet content. Input parameter.
* @param suffix The type of the suffix to be removed from the end of the packet content. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if there is not enough memory left.
*/
#define PACKET_TRIM( packet, prefix, suffix ) packet_trim(( packet ), sizeof( prefix ), sizeof( suffix ))
 
/** Allocates the specified space right before the actual packet content and returns its pointer.
* @param packet The packet to be used. Input parameter.
* @param length The space length to be allocated at the beginning of the packet content. Input parameter.
* @returns The pointer to the allocated memory.
* @returns NULL if there is not enough memory left.
*/
void * packet_prefix( packet_t packet, size_t length );
 
/** Allocates the specified space right after the actual packet content and returns its pointer.
* @param packet The packet to be used. Input parameter.
* @param length The space length to be allocated at the end of the packet content. Input parameter.
* @returns The pointer to the allocated memory.
* @returns NULL if there is not enough memory left.
*/
void * packet_suffix( packet_t packet, size_t length );
 
/** Trims the actual packet content by the specified prefix and suffix lengths.
* @param packet The packet to be trimmed. Input parameter.
* @param prefix The prefix length to be removed from the beginning of the packet content. Input parameter.
* @param suffix The suffix length to be removed from the end of the packet content. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
*/
int packet_trim( packet_t packet, size_t prefix, size_t suffix );
 
/** Copies the packet content.
* Obtains the new packet from the packet server.
* @param phone The packet server module phone. Input parameter.
* @param owner The owner of the new packet. Input parameter.
* @param packet The packet reference. Input parameter.
* @returns The packet copy.
* @returns NULL if the source packet ids not valid.
* @returns NULL on error.
* \todo other error?
*/
packet_t packet_copy( int phone, services_t owner, const packet_t packet );
 
/** Copies the specified data to the beginning of the actual packet content.
* Pushes the content end if needed.
* @param packet The packet to be filled. Input parameter.
* @param data The data to be copied. Input parameter.
* @param length The length of the copied data. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
*/
int packet_copy_data( packet_t packet, const void * data, size_t length );
int packet_trim( packet_t packet, size_t prefix, size_t sufix );
int packet_destroy( packet_t packet );
packet_id_t packet_get_id( packet_t packet );
 
/** Returns the packet identifier.
* @param packet The packet. Input parameter.
* @returns The packet identifier.
* @returns Zero (0) if the packet is not valid.
*/
packet_id_t packet_get_id( const packet_t packet );
 
/** Returns the packet content length.
* @param packet The packet. Input parameter.
* @returns The packet content length in bytes.
* @returns Zero (0) if the packet is not valid.
*/
size_t packet_get_data_length( const packet_t packet );
 
/** Returns the pointer to the beginning of the packet content.
* @param packet The packet. Input parameter.
* @returns The pointer to the beginning of the packet content.
* @returns NULL if the packet is not valid.
*/
void * packet_get_data( const packet_t packet );
 
/** Returns the stored packet addresses and their length.
* @param packet The packet. Input parameter.
* @param src The source address. Output parameter.
* @param dest The destination address. Output parameter.
* @returns The addresses length.
* @returns Zero (0) if the addresses are not present.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the src and/or the dest parameter is NULL.
*/
int packet_get_addr( const packet_t packet, uint8_t ** src, uint8_t ** dest );
 
/** Returns the packet operation mode.
* @param packet The packet. Input parameter.
* @returns The packet operation mode.
* @see packet_mode
*/
packet_mode_t packet_get_mode( const packet_t packet );
 
/** Sets the packet addresses.
* @param packet The packet. Input parameter.
* @param src The new source address. Output parameter.
* @param dest The new destination address. Output parameter.
* @param addr_len The addresses length.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
*/
int packet_set_addr( packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len );
 
/** Sets the packet operation mode.
* @param packet The packet. Input parameter.
* @param mode The new packet operation mode. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @see packet_mode
*/
int packet_set_mode( packet_t packet, packet_mode_t mode );
 
/** Sets the packet owner.
* @param packet The packet. Input parameter.
* @param owner The new packet owner. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
*/
int packet_set_owner( packet_t packet, services_t owner );
 
/** Translates the packet identifier to the packet reference.
* Tries to find mapping first.
* Contacts the packet server to share the packet if the mapping is not present.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet parameter is NULL.
* @returns Other error codes as defined for the NET_PACKET_GET_SIZE message.
* \todo errors as packet_return()
*/
int packet_translate( int phone, packet_ref packet, packet_id_t packet_id );
packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_sufix );
 
/** Obtains the packet of the given dimensions.
* Contacts the packet server to return the appropriate packet.
* @param phone The packet server module phone. Input parameter.
* @param owner The owner of the new packet. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @returns The packet reference.
* @returns NULL on error.
* \todo error as NET_PACKET_CREATE_5, packet_return()
*/
packet_t packet_get_5( int phone, services_t owner, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix );
 
/** Obtains the packet of the given content size.
* Contacts the packet server to return the appropriate packet.
* @param phone The packet server module phone. Input parameter.
* @param owner The owner of the new packet. Input parameter.
* @param content The maximal content length in bytes. Input parameter.
* @returns The packet reference.
* @returns NULL on error.
* \todo error as NET_PACKET_CREATE_1, packet_return()
*/
packet_t packet_get_1( int phone, services_t owner, size_t content );
 
/** Releases the packet.
* The packet is marked as free for use.
* The module should not use the packet after this point until it is received or obtained again.
* @param phone The packet server module phone. Input parameter.
* @param packet_id The packet identifier. Input parameter.
*/
void packet_release( int phone, packet_id_t packet_id );
 
#endif
/branches/network/uspace/srv/net/structures/packet/packet.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,36 → 26,104
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet map and queue.
*/
 
#ifndef __NET_PACKET_H__
#define __NET_PACKET_H__
 
/** Packet identifier type.
* Value zero (0) is used as an invalid identifier.
*/
typedef unsigned int packet_id_t;
 
/** Type definition of the packet.
* @see packet
*/
typedef struct packet * packet_t;
typedef packet_t * packet_ref;
 
/** Type definition of the packet pointer.
* @see packet
*/
typedef packet_t * packet_ref;
 
/** Packet operation mode type.
*/
typedef enum packet_mode packet_mode_t;
 
/** Packet operation mode.
*/
enum packet_mode{
PM_ONEWAY,
/** The packet is processed in one direction and can be released at any time.
*/
PM_ONE_WAY,
/** The packet should be returned at the end of the processing back to its initiator.
*/
PM_RETURN
};
 
packet_t pm_find( packet_id_t packet_id );
int pm_add( packet_t packet );
int pm_init( void );
void pm_destroy( void );
/** Finds the packet mapping.
* @param packet_id The packet identifier to be found. Input parameter.
* @returns The found packet reference.
* @returns NULL if the mapping does not exist.
*/
packet_t pm_find( packet_id_t packet_id );
 
/** Adds the packet mapping.
* @param packet The packet to be remembered. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the packet map is not initialized.
* @returns ENOMEM if there is not enough memory left.
*/
int pm_add( packet_t packet );
 
/** Initializes the packet map.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
int pm_init( void );
 
/** Releases the packet map.
*/
void pm_destroy( void );
 
/** Add packet to the sorted queue.
* The queue is sorted in the ascending order.
* The packet is inserted right before the packets of the same order value.
* @param first The first packet of the queue. May be NULL. Input parameter.
* @param packet The packet to be added. Input parameter.
* @param order The packet order value. Input parameter.
* @param metric The metric value of the packet. Input parameter.
* @returns The first packet of the queue. The original first packet may be shifted by the new packet.
* @returns NULL if the packet is not valid.
*/
packet_t pq_add( packet_t first, packet_t packet, int order, size_t metric );
packet_t pq_detach( packet_t packet );
 
/** Detach the packet from the queue.
* @param packet The packet to be detached. Input parameter.
* @returns The next packet in the queue. If the packet is the first one of the queue, this becomes the new first one.
* @returns NULL if the packet is not valid.
*/
packet_t pq_detach( packet_t packet );
 
/** Sets the packet order and metric attributes.
* @param packet The packet to be set. Input parameter.
* @param order The packet order value. Input parameter.
* @param metric The metric value of the packet. Input parameter.
*/
int pq_set( packet_t packet, int order, size_t metric );
 
/** Releases the whole queue.
* Detaches all packets of the queue and calls the packet_release() for each of them.
* @param first The first packet of the queue. Input parameter.
* @param packet_release The releasing function called for each of the packets after its detachment. Input parameter.
*/
void pq_destroy( packet_t first, void ( * packet_release )( packet_t packet ));
 
#endif
/branches/network/uspace/srv/net/structures/packet/packet_server.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,11 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup packet
* @{
*/
 
/** @file
* Packet server implementation.
*/
 
#include <async.h>
50,18 → 51,45
#include "packet_header.h"
#include "packet_server.h"
 
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_ID( call ) ( packet_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the owner message parameter.
*/
#define IPC_GET_OWNER( call ) ( services_t ) IPC_GET_ARG1( * call )
 
/** Returns the maximal content length message parameter.
*/
#define IPC_GET_CONTENT( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the maximal address length message parameter.
*/
#define IPC_GET_ADDR_LEN( call ) ( size_t ) IPC_GET_ARG3( * call )
 
/** Returns the maximal prefix length message parameter.
*/
#define IPC_GET_PREFIX( call ) ( size_t ) IPC_GET_ARG4( * call )
 
/** Returns the maximal suffix length message parameter.
*/
#define IPC_GET_SUFIX( call ) ( size_t ) IPC_GET_ARG5( * call )
 
#define FREE_QUEUES_COUNT 7
 
/** Packet server global data.
*/
static struct{
/** Free packet queues.
*/
packet_t free[ FREE_QUEUES_COUNT ];
/** Packet length upper bounds of the free packet queues.
* The maximal lengths of packets in each queue in the ascending order.
* The last queue is not limited.
*/
int sizes[ FREE_QUEUES_COUNT ];
/** Total packets allocated.
*/
unsigned int count;
} ps_globals = {
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL },
69,10 → 97,54
0
};
 
/** Releases the packet and returns it to the appropriate free packet queue.
* @param packet The packet to be released. Input parameter.
*/
void packet_release( packet_t packet );
packet_t packet_get( services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix );
packet_t packet_create( size_t length, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix );
void packet_init( packet_t packet, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix );
 
/** Returns the packet of dimensions at least as given.
* Tries to reuse free packets first.
* Creates a&nbsp;new packet aligned to the memory page size if none available.
* @param owner The new owner of the packet. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
packet_t packet_get( services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Creates a&nbsp;new packet of dimensions at least as given.
* @param length The total length of the packet, including the header, the addresses and the data of the packet. Input parameter.
* @param owner The new owner of the packet. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
packet_t packet_create( size_t length, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Initializes the packet according to the given dimensions.
* @param packet The packet to be initialized. Input parameter.
* @param owner The new owner of the packet. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
*/
void packet_init( packet_t packet, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Shares the packet memory block.
* @param packet The packet to be shared.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the calling module does not accept the memory.
* @returns ENOMEM if the desired and actual sizes differ.
* @returns Other error codes as defined for the ipc_share_in_finalize() function.
*/
int packet_reply( const packet_t packet );
 
int packet_server_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
122,12 → 194,12
ps_globals.free[ index ] = pq_add( ps_globals.free[ index ], packet, packet->length, packet->length );
}
 
packet_t packet_get( services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix ){
packet_t packet_get( services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
int index;
packet_t packet;
size_t length;
 
length = ALIGN_UP( sizeof( struct packet ) + 2 * addr_len + max_prefix + max_content + max_sufix, PAGE_SIZE );
length = ALIGN_UP( sizeof( struct packet ) + 2 * addr_len + max_prefix + max_content + max_suffix, PAGE_SIZE );
for( index = 0; index < FREE_QUEUES_COUNT - 1; ++ index ){
if( length <= ps_globals.sizes[ index ] ){
packet = ps_globals.free[ index ];
135,15 → 207,15
packet = pm_find( packet->next );
}
if( packet ){
packet_init( packet, owner, addr_len, max_prefix, max_content, max_sufix );
packet_init( packet, owner, addr_len, max_prefix, max_content, max_suffix );
return packet;
}
}
}
return packet_create( length, owner, addr_len, max_prefix, max_content, max_sufix );
return packet_create( length, owner, addr_len, max_prefix, max_content, max_suffix );
}
 
packet_t packet_create( size_t length, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix ){
packet_t packet_create( size_t length, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
ERROR_DECLARE;
 
packet_t packet;
152,11 → 224,11
if( packet == MAP_FAILED ) return NULL;
++ ps_globals.count;
packet->packet_id = ps_globals.count;
packet->mode = PM_ONEWAY;
packet->mode = PM_ONE_WAY;
packet->length = length;
packet_init( packet, owner, addr_len, max_prefix, max_content, max_sufix );
packet_init( packet, owner, addr_len, max_prefix, max_content, max_suffix );
packet->magic_value = PACKET_MAGIC_VALUE;
if( ERROR_OCCURED( pm_add( packet ))){
if( ERROR_OCCURRED( pm_add( packet ))){
munmap( packet, packet->length );
return NULL;
}
164,7 → 236,7
return packet;
}
 
void packet_init( packet_t packet, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_sufix ){
void packet_init( packet_t packet, services_t owner, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix ){
packet->owner = owner;
packet->order = 0;
packet->metric = 0;
/branches/network/uspace/srv/net/structures/char_map.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,7 → 31,8
*/
 
/** @file
* A&nbsp;character string to integer map implementation file.
* Character string to integer map implementation.
* @see char_map.h
*/
 
#include <errno.h>
41,7 → 42,7
 
#include "char_map.h"
 
/** An&nbsp;internal magic value for a&nbsp;consistency check.
/** Internal magic value for a&nbsp;consistency check.
*/
#define CHAR_MAP_MAGIC_VALUE 0x12345611
 
48,11 → 49,11
/** Adds the value with the key to the map.
* Creates new nodes to map the key.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @returns EOK on success.
* @returns ENOMEM if there is no memory left.
* @returns ENOMEM if there is not enough memory left.
* @returns EEXIST if the key character string is already used.
*/
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value );
59,8 → 60,8
 
/** Returns the node assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\0') terminated character string. The key character string is processed until the first terminating zero ('\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\0') character is found. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @returns The node holding the integral value assigned to the key character string.
* @returns NULL if the key is not assigned a&nbsp;node.
*/
/branches/network/uspace/srv/net/structures/generic_char_map.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
79,7 → 79,7
if( ! name##_is_valid( map )) return EINVAL; \
index = name##_items_add( & map->values, value ); \
if( index < 0 ) return index; \
if( ERROR_OCCURED( char_map_add( & map->names, name, length, index ))){ \
if( ERROR_OCCURRED( char_map_add( & map->names, name, length, index ))){ \
name##_items_exclude_index( & map->values, index ); \
return ERROR_CODE; \
} \
121,9 → 121,14
} \
\
int name##_initialize( name##_ref map ){ \
ERROR_DECLARE; \
\
if( ! map ) return EINVAL; \
char_map_initialize( & map->names ); \
name##_items_initialize( & map->values ); \
ERROR_PROPAGATE( char_map_initialize( & map->names )); \
if( ERROR_OCCURRED( name##_items_initialize( & map->values ))){ \
char_map_destroy( & map->names ); \
return ERROR_CODE; \
} \
map->magic = GENERIC_CHAR_MAP_MAGIC_VALUE; \
return EOK; \
} \
/branches/network/uspace/srv/net/structures/int_map.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,11 → 27,10
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __NET_INT_MAP_H__
/branches/network/uspace/srv/net/Doxyfile
0,0 → 1,298
# Doxyfile 1.5.6
 
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "HelenOS Networking subsystem"
PROJECT_NUMBER = "Diploma thesis 2008/2009"
OUTPUT_DIRECTORY = doc/
CREATE_SUBDIRS = YES
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class " \
"The $name widget " \
"The $name file " \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = .
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
IDL_PROPERTY_SUPPORT = YES
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = YES
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
SHOW_FILES = YES
SHOW_NAMESPACES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = YES
WARN_FORMAT = "$file:$line: $text "
WARN_LOGFILE = doc/doxygen_warnings.txt
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./ \
../../doc/doxygroups.h
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM \
*.PY
RECURSIVE = YES
EXCLUDE = netif/include \
netif/ne2k_isa
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = *.svn*
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 4
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT =
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
HTML_DYNAMIC_SECTIONS = YES
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
CHM_INDEX_ENCODING =
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
FORMULA_FONTSIZE = 10
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
DOT_FONTNAME = FreeSans
DOT_FONTPATH =
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = YES
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = YES
CALLER_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = YES
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
/branches/network/uspace/srv/net/networking/startup/networking_startup.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,10 → 27,13
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
* Starts the networking subsystem.
* Performs self test if configured so.
* @see configuration.h
*/
 
#include <async.h>
45,9 → 48,25
#include "../../modules.h"
#include "../../self_test.h"
 
/** Networking startup module name.
*/
#define NAME "Networking startup"
 
/** Module entry point.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the networking module cannot be started.
* @returns Other error codes as defined for the self_test() function.
* @returns Other error codes as defined for the NET_NET_STARTUP message.
*/
int main( int argc, char * argv[] );
 
/** Starts the module.
* @param fname The module absolute name. Input parameter.
* @returns The started module task identifier.
* @returns Other error codes as defined for the task_spawn() function.
*/
task_id_t spawn( const char * fname );
 
int main( int argc, char * argv[] ){
65,7 → 84,7
}
// start networking
networking_phone = connect_to_service( SERVICE_NETWORKING );
if( ERROR_OCCURED( ipc_call_sync_0_0( networking_phone, NET_NET_STARTUP ))){
if( ERROR_OCCURRED( ipc_call_sync_0_0( networking_phone, NET_NET_STARTUP ))){
printf( "\n" NAME " - ERROR %d\n", ERROR_CODE );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/networking/networking.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
187,7 → 187,7
tmp_module->name = name;
tmp_module->filename = filename;
tmp_module->service = service;
if( ERROR_OCCURED( modules_add( modules, tmp_module->name, 0, tmp_module ))){
if( ERROR_OCCURRED( modules_add( modules, tmp_module->name, 0, tmp_module ))){
free( tmp_module );
return ERROR_CODE;
}
404,7 → 404,7
setting = measured_string_create_bulk( value, -1 );
if( ! setting ) return ENOMEM;
// add the configuration setting
if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){
if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
420,7 → 420,7
setting = measured_string_create_bulk( value, 0 );
if( ! setting ) return ENOMEM;
// add the configuration setting
if( ERROR_OCCURED( measured_strings_add( configuration, name, 0, setting ))){
if( ERROR_OCCURRED( measured_strings_add( configuration, name, 0, setting ))){
free( setting );
return ERROR_CODE;
}
450,13 → 450,13
if( ! netif ) return ENOMEM;
netif->id = generate_new_device_id();
ERROR_PROPAGATE( measured_strings_initialize( & netif->configuration ));
if( ERROR_OCCURED( add_configuration( & netif->configuration, "NAME", LO_NAME ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETIF", LO_NAME ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IL", IP_NAME ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "MTU", "1500" ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ))
|| ERROR_OCCURED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){
if( ERROR_OCCURRED( add_configuration( & netif->configuration, "NAME", LO_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETIF", LO_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IL", IP_NAME ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "MTU", "1500" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_CONFIG", "STATIC" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "IP_ADDR", "127.0.0.1" ))
|| ERROR_OCCURRED( add_configuration( & netif->configuration, "NETMASK", "255.0.0.0" ))){
measured_strings_destroy( & netif->configuration );
free( netif );
return ERROR_CODE;
559,7 → 559,7
free( netif );
return ERROR_CODE;
}
if( ERROR_OCCURED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){
if( ERROR_OCCURRED( char_map_add( & networking_globals.netif_names, netif->name, 0, index ))){
netifs_exclude_index( & networking_globals.netifs, index );
return ERROR_CODE;
}
618,7 → 618,7
ERROR_DECLARE;
 
// read configuration files
if( ERROR_OCCURED( read_configuration())) return ERROR_CODE;
if( ERROR_OCCURRED( read_configuration())) return ERROR_CODE;
 
// start network interfaces and needed modules
// start_device( "/sbin/lo", "/sbin/dummy_link_layer" );
/branches/network/uspace/srv/net/modules.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
62,7 → 62,7
 
phone = connect_to_service( need );
if( phone >= 0 ){
if( ERROR_OCCURED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
if( ERROR_OCCURRED( ipc_connect_to_me( phone, arg1, arg2, arg3, & phonehash ))){
async_msg_0( phone, IPC_M_PHONE_HUNGUP );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/messages.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
145,7 → 145,7
NET_NIL_RECEIVED,
/* ( device_id ), packet_send */
NET_NIL_SEND,
/* ( device_id ) -> prefix, content, sufix */
/* ( device_id ) -> prefix, content, suffix */
NET_NIL_PACKET_SPACE,
/* ( device_id ), measured_strings_return( hardware address ) */
NET_NIL_ADDR,
/branches/network/uspace/srv/net/configuration.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,42 → 31,42
*/
 
/** @file
* A&nbsp;networking subsystem compilation configuration file.
* Networking subsystem compilation configuration.
*/
 
#ifndef __NET_CONFIGURATION_H__
#define __NET_CONFIGURATION_H__
 
/** An&nbsp;option to activate the self test.
/** Activate the self test.
*/
#define NET_SELF_TEST 0
 
/** An&nbsp;option to activate the measured strings self test.
* The option NET_SELF_TEST has to be activated.
/** Activate the measured strings self test.
* The NET_SELF_TEST has to be activated.
* @see measured_strings.h
*/
#define NET_SELF_TEST_MEASURED_STRINGS 1
 
/** An&nbsp;option to activate the char map self test.
* The option NET_SELF_TEST has to be activated.
/** Activate the char map self test.
* The NET_SELF_TEST has to be activated.
* @see char_map.h
*/
#define NET_SELF_TEST_CHAR_MAP 0
 
/** An&nbsp;option to activate the integral map self test.
* The option NET_SELF_TEST has to be activated.
/** Activate the integral map self test.
* The NET_SELF_TEST has to be activated.
* @see int_map.h
*/
#define NET_SELF_TEST_INT_MAP 0
 
/** An&nbsp;option to activate the generic field self test.
* The option NET_SELF_TEST has to be activated.
/** Activate the generic field self test.
* The NET_SELF_TEST has to be activated.
* @see generic_field.h
*/
#define NET_SELF_TEST_GENERIC_FIELD 0
 
/** An&nbsp;option to activate the generic char map self test.
* The option NET_SELF_TEST has to be activated.
/** Activate the generic char map self test.
* The NET_SELF_TEST has to be activated.
* @see generic_char_map.h
*/
#define NET_SELF_TEST_GENERIC_CHAR_MAP 0
/branches/network/uspace/srv/net/modules.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
/branches/network/uspace/srv/net/il/arp/arp_header.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,6 → 31,7
*/
 
/** @file
* ARP protocol header.
*/
 
#ifndef __NET_ARP_HEADER_H__
38,14 → 39,35
 
#include <sys/types.h>
 
/** Type definition of an ARP protocol header.
* @see arp_header
*/
typedef struct arp_header arp_header_t;
 
/** Type definition of an ARP protocol header pointer.
* @see arp_header
*/
typedef arp_header_t * arp_header_ref;
 
/** ARP protocol header.
*/
struct arp_header{
/** Hardware type identifier.
* @see hardware.h
*/
uint16_t hardware;
/** Protocol identifier.
*/
uint16_t protocol;
/** Hardware address length in bytes.
*/
uint8_t hardware_length;
/** Protocol address length in bytes.
*/
uint8_t protocol_length;
/** ARP packet type.
* @see arp_oc.h
*/
uint16_t operation;
};
 
/branches/network/uspace/srv/net/il/arp/arp.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,6 → 31,8
*/
 
/** @file
* ARP module implementation.
* @see arp.h
*/
 
#include <as.h>
59,13 → 61,98
//#include "arp_messages.h"
#include "arp_module.h"
 
/** Returns the device identifier message parameter.
*/
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the packet identifier message parameter.
*/
#define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call )
 
/** Returns the protocol service message parameter.
*/
#define IPC_GET_PROTO( call ) ( services_t ) IPC_GET_ARG2( * call )
 
/** Returns the device driver service message parameter.
*/
#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call )
 
/** ARP global data.
*/
arp_globals_t arp_globals;
 
/** Creates new protocol specific data.
* @param proto Protocol specific data. Output parameter.
* @param service Protocol module service. Input parameter.
* @param address Actual protocol device address. Input parameter.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address );
 
/** Registers the device.
* Creates new device entry in the cache or updates the protocol address if the device with the device identifier and the driver service exists.
* @param device_id The device identifier. Input parameter.
* @param service The device driver service. Input parameter.
* @param protocol The protocol service. Input parameter.
* @param address The actual device protocol address.
* @returns EOK on success.
* @returns EEXIST if another device with the same device identifier and different driver service exists.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the measured_strings_return() function.
*/
int arp_device_message( device_id_t device_id, services_t service, services_t protocol, measured_string_ref address );
 
/** Returns the hardware address for the given protocol address.
* Sends the ARP request packet if the hardware address is not found in the cache.
* @param device_id The device identifier. Input parameter.
* @param protocol The protocol service. Input parameter.
* @param target The target protocol address. Input parameter.
* @returns The hardware address of the target.
* @returns NULL if the target parameter is NULL.
* @returns NULL if the device is not found.
* @returns NULL if the device packet is too small to send a&nbsp;request.
* @returns NULL if the hardware address is not found in the cache.
*/
measured_string_ref arp_translate_message( device_id_t device_id, services_t protocol, measured_string_ref target );
 
/** Processes the received ARP packet.
* Updates the source hardware address if the source entry exists or the packet is targeted to my protocol address.
* Responses to the ARP request if the packet is the ARP request and is targeted to my address.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet. Input/output parameter.
* @returns EOK on success.
* @returns EINVAL if the packet is too small to carry the ARP packet.
* @returns EINVAL if the received address lengths differs from the registered values.
* @returns ENOENT if the device is not found in the cache.
* @returns ENOENT if the protocol for the device is not found in the cache.
* @returns ENOMEM if there is not enough memory left.
*/
int arp_receive_message( device_id_t device_id, packet_t packet );
 
/** Clears the device specific data from the cache.
* @param device_id The device identifier. Input parameter.
* @returns EOK on success.
* @returns ENOENT if the device is not found in the cache.
*/
int arp_clear_device_message( device_id_t device_id );
 
/** Clears the device specific data.
* @param device The device specific data.
*/
void clear_device( arp_device_ref device );
 
/** Clears the whole cache.
* @returns EOK on success.
*/
int arp_clean_cache_message( void );
 
/** Processes IPC messages from the registered device driver modules in an infinite loop.
* @param iid The message identifier. Input parameter.
* @param icall The message parameters. Input/output parameter.
*/
void arp_receiver( ipc_callid_t iid, ipc_call_t * icall );
 
DEVICE_MAP_IMPLEMENT( arp_cache, arp_device_t )
 
INT_MAP_IMPLEMENT( arp_protos, arp_proto_t )
72,20 → 159,8
 
GENERIC_CHAR_MAP_IMPLEMENT( arp_addr, measured_string_t )
 
int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address );
int arp_device_message( device_id_t device_id, services_t service, services_t protocol, measured_string_ref address );
measured_string_ref arp_translate_message( device_id_t device, services_t protocol, measured_string_ref target );
int arp_receive_message( device_id_t device_id, packet_t packet );
int arp_clear_device_message( device_id_t device_id );
void clear_device( arp_device_ref device );
int arp_clean_cache_message( void );
void arp_receiver( ipc_callid_t iid, ipc_call_t * icall );
 
/** Initializes the ARP module.
*/
int arp_initialize( void ){
arp_cache_initialize( & arp_globals.cache );
return EOK;
return arp_cache_initialize( & arp_globals.cache );
}
 
int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address ){
96,7 → 171,7
( ** proto ).service = service;
( ** proto ).addr = address;
( ** proto ).addr_data = address->value;
if( ERROR_OCCURED( arp_addr_initialize( &( ** proto).addresses ))){
if( ERROR_OCCURRED( arp_addr_initialize( &( ** proto).addresses ))){
free( * proto );
return ERROR_CODE;
}
124,7 → 199,7
proto->addr_data = address->value;
}else{
ERROR_PROPAGATE( arp_proto_create( & proto, protocol, address ));
if( ERROR_OCCURED( arp_protos_add( & device->protos, proto->service, proto ))){
if( ERROR_OCCURRED( arp_protos_add( & device->protos, proto->service, proto ))){
free( proto );
return ERROR_CODE;
}
135,12 → 210,12
device = ( arp_device_ref ) malloc( sizeof( arp_device_t ));
if( ! device ) return ENOMEM;
device->device_id = device_id;
if( ERROR_OCCURED( arp_protos_initialize( & device->protos ))
|| ERROR_OCCURED( arp_proto_create( & proto, protocol, address ))){
if( ERROR_OCCURRED( arp_protos_initialize( & device->protos ))
|| ERROR_OCCURRED( arp_proto_create( & proto, protocol, address ))){
free( device );
return ERROR_CODE;
}
if( ERROR_OCCURED( arp_protos_add( & device->protos, proto->service, proto ))){
if( ERROR_OCCURRED( arp_protos_add( & device->protos, proto->service, proto ))){
arp_protos_destroy( & device->protos );
free( device );
return ERROR_CODE;
149,7 → 224,7
// bind the new one
device->phone = bind_service( device->service, device->device_id, SERVICE_ARP, 0, arp_receiver );
// get packet dimensions
if( ERROR_OCCURED( async_req_1_4( device->phone, NET_NIL_PACKET_SPACE, device_id, & device->addr_len, & device->prefix, & device->content, & device->sufix ))){
if( ERROR_OCCURRED( async_req_1_4( device->phone, NET_NIL_PACKET_SPACE, device_id, & device->addr_len, & device->prefix, & device->content, & device->suffix ))){
arp_protos_destroy( & device->protos );
free( device );
return ERROR_CODE;
156,7 → 231,7
}
// get hardware address
message = async_send_1( device->phone, NET_NIL_ADDR, device->device_id, & answer );
if( ERROR_OCCURED( measured_strings_return( device->phone, & device->addr, & device->addr_data, 1 ))){
if( ERROR_OCCURRED( measured_strings_return( device->phone, & device->addr, & device->addr_data, 1 ))){
arp_protos_destroy( & device->protos );
free( device );
async_wait_for( message, NULL );
163,7 → 238,7
return ERROR_CODE;
}
async_wait_for( message, & result );
if( ERROR_OCCURED( result )){
if( ERROR_OCCURRED( result )){
free( device->addr );
free( device->addr_data );
arp_protos_destroy( & device->protos );
172,7 → 247,7
}
// get broadcast address
message = async_send_1( device->phone, NET_NIL_BROADCAST_ADDR, device->device_id, & answer );
if( ERROR_OCCURED( measured_strings_return( device->phone, & device->broadcast_addr, & device->broadcast_data, 1 ))){
if( ERROR_OCCURRED( measured_strings_return( device->phone, & device->broadcast_addr, & device->broadcast_data, 1 ))){
free( device->addr );
free( device->addr_data );
arp_protos_destroy( & device->protos );
182,8 → 257,8
}
async_wait_for( message, & result );
// add to the cache
if( ERROR_OCCURED( result )
|| ERROR_OCCURED( arp_cache_add( & arp_globals.cache, device->device_id, device ))){
if( ERROR_OCCURRED( result )
|| ERROR_OCCURRED( arp_cache_add( & arp_globals.cache, device->device_id, device ))){
free( device->addr );
free( device->addr_data );
free( device->broadcast_addr );
197,8 → 272,6
}
 
measured_string_ref arp_translate_message( device_id_t device_id, services_t protocol, measured_string_ref target ){
// ERROR_DECLARE;
 
arp_device_ref device;
arp_proto_ref proto;
measured_string_ref addr;
218,9 → 291,9
if( length > device->content ){
return NULL;
}
packet = packet_get_5( arp_globals.networking_phone, SERVICE_ARP, device->addr_len, device->prefix, length, device->sufix );
packet = packet_get_5( arp_globals.networking_phone, SERVICE_ARP, device->addr_len, device->prefix, length, device->suffix );
if( ! packet ) return NULL;
header = ( arp_header_ref ) packet_append( packet, length );
header = ( arp_header_ref ) packet_suffix( packet, length );
header->hardware = device->hardware;
header->hardware_length = device->addr->length;
header->protocol = protocol_map( device->service, protocol );
234,7 → 307,7
memset((( uint8_t * ) header ) + length, 0, device->addr->length );
length += device->addr->length;
memcpy((( uint8_t * ) header ) + length, target->value, target->length );
// TODO send to the device->broadcast_addr as arp protocol
packet_set_addr( packet, ( uint8_t * ) device->addr->value, ( uint8_t * ) device->broadcast_addr->value, CONVERT_SIZE( char, uint8_t, device->addr->length ));
async_msg_3( device->phone, NET_NETIF_SEND, device_id, SERVICE_ARP, packet_get_id( packet ));
return NULL;
}
253,10 → 326,10
ipcarg_t result;
int index;
ipc_call_t answer;
*/ int8_t * src_hw;
int8_t * src_proto;
int8_t * des_hw;
int8_t * des_proto;
*/ uint8_t * src_hw;
uint8_t * src_proto;
uint8_t * des_hw;
uint8_t * des_proto;
 
length = packet_get_data_length( packet );
if( length <= sizeof( arp_header_t )) return EINVAL;
267,34 → 340,35
if( length < sizeof( arp_header_t ) + ( header->hardware_length + header->protocol_length ) * 2 ) return EINVAL;
proto = arp_protos_find( & device->protos, protocol_unmap( device->service, header->protocol ));
if( ! proto ) return ENOENT;
src_hw = (( int8_t * ) header ) + sizeof( arp_header_t );
src_hw = (( uint8_t * ) header ) + sizeof( arp_header_t );
src_proto = src_hw + header->hardware_length;
des_hw = src_proto + header->protocol_length;
des_proto = des_hw + header->hardware_length;
hw_source = arp_addr_find( & proto->addresses, src_proto, header->protocol_length );
hw_source = arp_addr_find( & proto->addresses, ( char * ) src_proto, CONVERT_SIZE( uint8_t, char, header->protocol_length ));
// exists?
if( hw_source ){
if( hw_source->length != header->hardware_length ) return EINVAL;
memcpy( hw_source->value, src_hw, header->hardware_length );
if( hw_source->length != CONVERT_SIZE( uint8_t, char, header->hardware_length )) return EINVAL;
memcpy( hw_source->value, src_hw, hw_source->length );
}
// is my protocol address?
// TODO query protocol module?
/* proto_target.value = des_proto;
proto_target.length = header->protocol_length;
// TODO send necessary?
message = async_send_0( proto->phone, NET_IL_MY_ADDR, & answer );
if( ERROR_OCCURED( measured_strings_send( device->phone, & proto_target, 1 ))){
if( ERROR_OCCURRED( measured_strings_send( device->phone, & proto_target, 1 ))){
async_wait_for( message, NULL );
return ERROR_CODE;
}
async_wait_for( message, & result );
if( result == EOK ){
*/ if( proto->addr->length != header->hardware_length ) return EINVAL;
if( ! strncmp( proto->addr->value, des_proto, proto->addr->length )){
*/ if( proto->addr->length != CONVERT_SIZE( uint8_t, char, header->hardware_length )) return EINVAL;
if( ! strncmp( proto->addr->value, ( char * ) des_proto, proto->addr->length )){
// not already upadted?
if( ! hw_source ){
hw_source = measured_string_create_bulk( src_hw, header->hardware_length );
hw_source = measured_string_create_bulk(( char * ) src_hw, CONVERT_SIZE( uint8_t, char, header->hardware_length ));
if( ! hw_source ) return ENOMEM;
ERROR_PROPAGATE( arp_addr_add( & proto->addresses, src_proto, header->protocol_length, hw_source ));
ERROR_PROPAGATE( arp_addr_add( & proto->addresses, ( char * ) src_proto, CONVERT_SIZE( uint8_t, char, header->protocol_length ), hw_source ));
}
if( header->operation == ARPOP_REQUEST ){
header->operation = ARPOP_REPLY;
311,8 → 385,8
*/ memcpy( des_proto, src_proto, header->protocol_length );
memcpy( src_proto, proto->addr->value, header->protocol_length );
memcpy( src_hw, des_hw, header->hardware_length );
memcpy( des_hw, hw_source->value, hw_source->length );
// TODO send to the hw_source as arp protocol
memcpy( des_hw, hw_source->value, header->hardware_length );
packet_set_addr( packet, src_hw, des_hw, header->hardware_length );
async_msg_3( device->phone, NET_NETIF_SEND, device_id, SERVICE_ARP, packet_get_id( packet ));
}else{
packet_release( arp_globals.networking_phone, packet_get_id( packet ));
354,7 → 428,7
device = arp_cache_get_index( & arp_globals.cache, count );
if( device ){
clear_device( device );
if( device->broadcast_addr ) free( device->broadcast_addr );
if( device->addr_data ) free( device->addr_data );
if( device->broadcast_data ) free( device->broadcast_data );
}
}
365,7 → 439,6
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
ERROR_DECLARE;
 
// packet_t packet;
measured_string_ref address;
measured_string_ref translation;
char * data;
376,7 → 449,7
return EOK;
case NET_ARP_DEVICE:
ERROR_PROPAGATE( measured_strings_receive( & address, & data, 1 ));
if( ERROR_OCCURED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), IPC_GET_PROTO( call ), address ))){
if( ERROR_OCCURRED( arp_device_message( IPC_GET_DEVICE( call ), IPC_GET_SERVICE( call ), IPC_GET_PROTO( call ), address ))){
free( address );
free( data );
}
399,33 → 472,23
void arp_receiver( ipc_callid_t iid, ipc_call_t * icall ){
ERROR_DECLARE;
 
ipc_callid_t callid;
ipc_call_t call;
// int result;
packet_t packet;
 
/*
* Accept the connection
* - Answer the first IPC_M_CONNECT_ME_TO call.
*/
//TODO auto accept?
//ipc_answer_0( iid, EOK );
 
while( true ){
callid = async_get_call( & call );
switch( IPC_GET_METHOD( call )){
switch( IPC_GET_METHOD( * icall )){
case NET_IL_DEVICE_STATE:
//TODO clear device if off?
break;
case NET_IL_RECEIVED:
if( ! ERROR_OCCURED( packet_translate( arp_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( & call ), packet );
if( ! ERROR_OCCURRED( packet_translate( arp_globals.networking_phone, & packet, IPC_GET_PACKET( icall )))){
ERROR_CODE = arp_receive_message( IPC_GET_DEVICE( icall ), packet );
}
ipc_answer_0( callid, ERROR_CODE );
ipc_answer_0( iid, ERROR_CODE );
break;
default:
ipc_answer_0( callid, ENOTSUP );
ipc_answer_0( iid, ENOTSUP );
}
iid = async_get_call( icall );
}
}
 
/branches/network/uspace/srv/net/il/arp/arp.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,6 → 31,7
*/
 
/** @file
* ARP module.
*/
 
#ifndef __NET_ARP_H__
44,46 → 45,122
#include "../../structures/int_map.h"
#include "../../structures/measured_strings.h"
 
 
/** Type definition of the ARP global data.
* @see arp_globals
*/
typedef struct arp_globals arp_globals_t;
typedef arp_globals_t * arp_globals_ref;
 
/** Type definition of the ARP device specific data.
* @see arp_device
*/
typedef struct arp_device arp_device_t;
 
/** Type definition of the ARP device specific data pointer.
* @see arp_device
*/
typedef arp_device_t * arp_device_ref;
 
/** Type definition of the ARP protocol specific data.
* @see arp_proto
*/
typedef struct arp_proto arp_proto_t;
 
/** Type definition of the ARP protocol specific data pointer.
* @see arp_proto
*/
typedef arp_proto_t * arp_proto_ref;
 
/** ARP address cache.
* Maps devices to the ARP device specific data.
* @see device.h
*/
DEVICE_MAP_DECLARE( arp_cache, arp_device_t )
 
/** ARP protocol map.
* Maps protocol identifiers to the ARP protocol specific data.
* @see int_map.h
*/
INT_MAP_DECLARE( arp_protos, arp_proto_t )
 
/** ARP address map.
* Translates addresses.
* @see generic_char_map.h
*/
GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t )
 
/** ARP device specific data.
*/
struct arp_device{
/** Device identifier.
*/
device_id_t device_id;
/** Hardware type.
*/
ipcarg_t hardware;
ipcarg_t protocol;
/** Reserved packet prefix length.
*/
ipcarg_t prefix;
/** Maximal packet content length.
*/
ipcarg_t content;
ipcarg_t sufix;
/** Reserved packet suffix length.
*/
ipcarg_t suffix;
/** Packet address length.
* The hardware address length is used.
*/
ipcarg_t addr_len;
/** Actual device hardware address.
*/
measured_string_ref addr;
/** Actual device hardware address data.
*/
char * addr_data;
/** Broadcast device hardware address.
*/
measured_string_ref broadcast_addr;
/** Broadcast device hardware address data.
*/
char * broadcast_data;
/** Device driver service.
*/
services_t service;
/** Driver phone.
*/
int phone;
/** Protocol map.
* Address map for each protocol.
*/
arp_protos_t protos;
};
 
/** ARP protocol specific data.
*/
struct arp_proto{
/** Protocol service.
*/
services_t service;
// int phone;
/** Actual device protocol address.
*/
measured_string_ref addr;
/** Actual device protocol address data.
*/
char * addr_data;
/** Address map.
*/
arp_addr_t addresses;
};
 
/** ARP global data.
*/
struct arp_globals{
/** Networking module phone.
*/
int networking_phone;
/** ARP address cache.
*/
arp_cache_t cache;
};
 
/branches/network/uspace/srv/net/il/arp/arp_module.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,6 → 31,10
*/
 
/** @file
* ARP standalone module implementation.
* Contains skeleton module functions mapping.
* The functions are used by the module skeleton as module specific entry points.
* @see module.c
*/
 
#include <async.h>
45,11 → 49,26
#include "arp.h"
#include "arp_module.h"
 
/** ARP module name.
*/
#define NAME "ARP protocol"
 
/** Prints the module name.
* @see NAME
*/
void arp_print_name( void );
int arp_start_module( async_client_conn_t client_connection );
 
/** Starts the ARP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the arp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
*/
int arp_start_module( async_client_conn_t client_connection );
 
/** ARP module global data.
*/
extern arp_globals_t arp_globals;
 
void arp_print_name( void ){
/branches/network/uspace/srv/net/il/arp/arp_oc.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
31,7 → 31,7
*/
 
/** @file
* ARP operation codes according to the online IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
* ARP operation codes 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.
* Names according to the linux src/include/linux/if_arp.h header file.
*/
 
/branches/network/uspace/srv/net/il/arp/arp_module.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
30,16 → 30,34
* @{
*/
 
/**
* @file
/** @file
* ARP module functions.
* The functions are used as ARP module entry points.
*/
 
#ifndef __NET_ARP_MODULE_H__
#define __NET_ARP_MODULE_H__
 
#include <errno.h>
 
#include <ipc/ipc.h>
 
/** Initializes the ARP module.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
int arp_initialize( void );
 
/** Processes the ARP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* \todo all possible message returns?
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see IS_NET_ARP_MESSAGE()
*/
int arp_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
#endif
/branches/network/uspace/srv/net/il/ip/ip_module.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup ip
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __NET_IP_MODULE_H__
/branches/network/uspace/srv/net/il/ip/ip_messages.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,11
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup ip
* @{
*/
 
/**
* @file
/** @file
*/
 
#ifndef __NET_IP_MESSAGES_H__
/branches/network/uspace/srv/net/il/ip/ip_header.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,14 → 26,13
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup ip
* @{
*/
 
/**
* @file
* Interent protocol header and options definitions.
* Names according to the linux src/include/linux/ip.h header file.
/** @file
* Internet protocol header and options definitions.
* Names according to the linux src/include/linux/ip.h header file.
*/
 
#ifndef __NET_IP_HEADER_H__
42,9 → 41,17
#include <byteorder.h>
#include <types.h>
 
/** Type definition of the internet header.
* @see ip_header
*/
typedef struct ip_header ip_header_t;
 
/** Type definition of the internet header pointer.
* @see ip_header
*/
typedef ip_header_t * ip_header_ref;
 
 
/** Internet header.
* The variable options should be included after the header itself and indicated by the increased header length value.
*/
155,7 → 162,7
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_PRECEDENCE_SHIFT 5
#define IPTOS_DELAY_SHIFT 4
#define IPTOS_TROUGHPUT_SHIFT 3
#define IPTOS_THROUGHPUT_SHIFT 3
#define IPTOS_RELIABILITY_SHIFT 2
#define IPTOS_COST_SHIFT 1
 
/branches/network/uspace/srv/net/il/ip/ip.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup ip
* @{
*/
 
/** @file
109,8 → 109,8
// TODO mapping
message = async_send_2( ip_globals.networking_phone, NET_NET_GET_DEVICE_CONF, ip_netif->device_id, count, & answer );
// send names and get settings
if( ERROR_OCCURED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
|| ERROR_OCCURED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
if( ERROR_OCCURRED( measured_strings_send( ip_globals.networking_phone, configuration, count ))
|| ERROR_OCCURRED( measured_strings_return( ip_globals.networking_phone, & settings, & data, count ))){
async_wait_for( message, NULL );
return ERROR_CODE;
}
126,8 → 126,8
free( ip_netif );
return ENOTSUP;
}else if( ip_netif->ipv == 4 ){
if( ERROR_OCCURED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
|| ERROR_OCCURED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
if( ERROR_OCCURRED( inet_pton( AF_INET, settings[ 2 ].value, ( uint8_t * ) & ip_netif->address ))
|| ERROR_OCCURRED( inet_pton( AF_INET, settings[ 3 ].value, ( uint8_t * ) & ip_netif->netmask ))
|| ( inet_pton( AF_INET, settings[ 4 ].value, ( uint8_t * ) & ip_netif->gateway ) == EINVAL )
|| ( inet_pton( AF_INET, settings[ 5 ].value, ( uint8_t * ) & ip_netif->broadcast ) == EINVAL )
|| ( inet_pton( AF_INET, settings[ 6 ].value, ( uint8_t * ) & ip_netif->dns1 ) == EINVAL )
170,7 → 170,7
}
// TODO mapping
ip_netif->phone = bind_service( service, ip_netif->device_id, SERVICE_IP, 0, ip_driver_receiver );
if( ERROR_OCCURED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
if( ERROR_OCCURRED( ip_netifs_add( & ip_globals.netifs, ip_netif->device_id, ip_netif ))){
free( ip_netif );
return ERROR_CODE;
}
214,7 → 214,7
// TODO packer received
case NET_IL_RECEIVED:
case NET_NIL_RECEIVED:
if( ! ERROR_OCCURED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
if( ! ERROR_OCCURRED( result = packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( & call )))){
//result = ip_receive_message( IPC_GET_DEVICE( call ), packet );
}
ipc_answer_0( callid, result );
237,7 → 237,7
if( ! proto ) return ENOMEM;
proto->protocol = protocol;
proto->phone = phone;
if( ERROR_OCCURED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){
if( ERROR_OCCURRED( ip_protos_add( & ip_globals.protos, proto->protocol, proto ))){
free( proto );
return ERROR_CODE;
}
268,7 → 268,7
case IPC_M_CONNECT_TO_ME:
return ip_register_message( IPC_GET_PROTO( call ), IPC_GET_PHONE( call ));
case NET_IP_SEND:
if( ERROR_OCCURED( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){
if( ERROR_OCCURRED( packet_translate( ip_globals.networking_phone, & packet, IPC_GET_PACKET( call )))){
printf( "\nIP send E %d", ERROR_CODE );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/il/ip/ip.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup ip
* @{
*/
 
/**
/branches/network/uspace/srv/net/il/ip/ip_module.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,7 → 26,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
/** @addtogroup ip
* @{
*/
 
71,6 → 71,7
 
async_manager();
 
pm_destroy();
return EOK;
}
 
/branches/network/uspace/srv/net/netif/device.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup netif
* @{
*/
 
/**
* @file
/** @file
* Device identifier, state and usage statistics.
*/
 
#ifndef __NET_DEVICE_ID_TYPE_H__
42,51 → 42,119
#define DEVICE_MAP_DECLARE INT_MAP_DECLARE
#define DEVICE_MAP_IMPLEMENT INT_MAP_IMPLEMENT
 
/** Device identifier type.
*/
typedef int device_id_t;
 
/** Device state type.
*/
typedef enum device_state device_state_t;
 
/** Type definition of the device usage statistics.
* @see device_stats
*/
typedef struct device_stats device_stats_t;
 
/** Type definition of the device usage statistics pointer.
* @see device_stats
*/
typedef device_stats_t * device_stats_ref;
 
/** Device state.
*/
enum device_state{
/** Device not present or not initialized.
*/
NETIF_NULL = 0,
/** Device present and stopped.
*/
NETIF_STOPPED,
/** Device present and active.
*/
NETIF_ACTIVE,
/** Device present but unable to transmit.
*/
NETIF_CARRIER_LOST
};
 
// based on linux_kernel/include/linux/netdevice.h
 
/** Device usage statistics.
* Based on linux_kernel/include/linux/netdevice.h.
*/
struct device_stats{
unsigned long rx_packets; /* total packets received */
unsigned long tx_packets; /* total packets transmitted */
unsigned long rx_bytes; /* total bytes received */
unsigned long tx_bytes; /* total bytes transmitted */
unsigned long rx_errors; /* bad packets received */
unsigned long tx_errors; /* packet transmit problems */
unsigned long rx_dropped; /* no space in linux buffers */
unsigned long tx_dropped; /* no space available in linux */
unsigned long multicast; /* multicast packets received */
/** Total packets received.
*/
unsigned long rx_packets;
/** Total packets transmitted.
*/
unsigned long tx_packets;
/** Total bytes received.
*/
unsigned long rx_bytes;
/** Total bytes transmitted.
*/
unsigned long tx_bytes;
/** Bad packets received counter.
*/
unsigned long rx_errors;
/** Packet transmition problems counter.
*/
unsigned long tx_errors;
/** No space in buffers counter.
*/
unsigned long rx_dropped;
/** No space available counter.
*/
unsigned long tx_dropped;
/** Total multicast packets received.
*/
unsigned long multicast;
/** The number of collisions due to congestion on the medium.
*/
unsigned long collisions;
 
/* detailed rx_errors: */
/** Received packet length error counter.
*/
unsigned long rx_length_errors;
unsigned long rx_over_errors; /* receiver ring buff overflow */
unsigned long rx_crc_errors; /* recved pkt with crc error */
unsigned long rx_frame_errors; /* recv'd frame alignment error */
unsigned long rx_fifo_errors; /* recv'r fifo overrun */
unsigned long rx_missed_errors; /* receiver missed packet */
/** Receiver buffer overflow counter.
*/
unsigned long rx_over_errors;
/** Received packet with crc error counter.
*/
unsigned long rx_crc_errors;
/** Received frame alignment error counter.
*/
unsigned long rx_frame_errors;
/** Receiver fifo overrun counter.
*/
unsigned long rx_fifo_errors;
/** Receiver missed packet counter.
*/
unsigned long rx_missed_errors;
 
/* detailed tx_errors */
/** Transmitter aborted counter.
*/
unsigned long tx_aborted_errors;
/** Transmitter carrier errors counter.
*/
unsigned long tx_carrier_errors;
/** Transmitter fifo overrun counter.
*/
unsigned long tx_fifo_errors;
/** Transmitter carrier errors counter.
*/
unsigned long tx_heartbeat_errors;
/** Transmitter window errors counter.
*/
unsigned long tx_window_errors;
 
/* for cslip etc */
/** Total compressed packets received.
*/
unsigned long rx_compressed;
/** Total compressed packet transmitted.
*/
unsigned long tx_compressed;
};
 
/branches/network/uspace/srv/net/netif/netif.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup netif
* @{
*/
 
/** @file
169,10 → 169,12
async_set_client_connection( client_connection );
netif_globals.networking_phone = connect_to_service( SERVICE_NETWORKING );
device_map_initialize( & netif_globals.device_map );
ERROR_PROPAGATE( pm_init());
ERROR_PROPAGATE( initialize());
ERROR_PROPAGATE( pm_init());
 
async_manager();
 
pm_destroy();
return EOK;
}
 
/branches/network/uspace/srv/net/netif/lo/lo.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,8 → 26,8
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup lo
* @{
*/
 
/** @file
73,7 → 73,7
ERROR_PROPAGATE( find_device( device_id, & device ));
if( device->state != state ){
device->state = state;
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL, NULL, NULL, NULL );
nil_message( device, NET_NIL_DEVICE_STATE, device->state, NULL );
}
return EOK;
}
93,7 → 93,7
( ** device ).state = NETIF_STOPPED;
( ** device ).flags = NULL;
( ** device ).mtu = DEFAULT_MTU;
if( ERROR_OCCURED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
if( ERROR_OCCURRED( device_map_add( & netif_globals.device_map, ( ** device ).device_id, * device ))){
free( * device );
* device = NULL;
return ERROR_CODE;
138,8 → 138,8
// get configuration
message = async_send_2( netif_globals.networking_phone, NET_NET_GET_DEVICE_CONF, device->device_id, count, & answer );
// send names and get settings
if( ERROR_OCCURED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
|| ERROR_OCCURED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
if( ERROR_OCCURRED( measured_strings_send( netif_globals.networking_phone, configuration, count ))
|| ERROR_OCCURRED( measured_strings_return( netif_globals.networking_phone, & settings, & data, count ))){
async_wait_for( message, NULL );
return ERROR_CODE;
}
178,9 → 178,9
++ device->stats.rx_dropped;
return EOK;
}
async_msg_2( device->nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id( received ));
nil_message( device, NET_NIL_RECEIVED, packet_get_id( received ), NULL );
// message = async_send_1( device->nil_phone, NET_NIL_RECEIVED, ( device_id ), & answer );
// if( ERROR_OCCURED( packet_send( received, device->nil_phone ))){
// if( ERROR_OCCURRED( packet_send( received, device->nil_phone ))){
// ++ device->stats.rx_dropped;
// }
// if( result != EOK ) ++ device->stats.rx_dropped;
/branches/network/uspace/srv/net/netif/netif.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
26,12 → 26,12
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
/** @addtogroup net
* @{
/** @addtogroup netif
* @{
*/
 
/**
* @file
/** @file
* Network interface module skeleton.
*/
 
#ifndef __NET_NETIF_H__
39,31 → 39,88
 
#include "device.h"
 
#define nil_message( device, message, arg2, arg3, result1, result2, result3 ) \
/** Sends the notification message to the registered network interface layer module.
* Wrapper of the async_msg_3().
* The first message argument is always the device identifier.
* @param device The device specific data. Input parameter.
* @param message The message to be sent. Input parameter.
* @param arg2 The second message argument. Input parameter.
* @param arg3 The third message argument. Input parameter.
*/
#define nil_message( device, message, arg2, arg3 ) \
if(( device )->nil_phone >= 0 ) async_msg_3(( device )->nil_phone, ( message ), ( device )->device_id, arg2, arg3 )
 
typedef struct device device_t;
typedef device_t * device_ref;
/** Network interface module skeleton global data.
*/
typedef struct netif_globals netif_globals_t;
 
/** Type definition of the device specific data.
* @see netif_device
*/
typedef struct netif_device device_t;
 
/** Type definition of the device specific data pointer.
* @see netif_device
*/
typedef device_t * device_ref;
 
/** Device map.
* Maps device identifiers to the network interface device specific data.
* @see device.h
*/
DEVICE_MAP_DECLARE( device_map, device_t );
 
struct device{
/** Network interface device specific data.
*/
struct netif_device{
/** Device identifier.
*/
device_id_t device_id;
/** Receiving network interface layer phone.
*/
int nil_phone;
/** Usage statistics.
*/
device_stats_t stats;
/** Actual device state.
*/
device_state_t state;
// TODO needed?
/** Various device flags.
*/
int flags;
/** Maximum transmission unit.
* The maximum packet content to be transmited.
*/
size_t mtu;
/** Driver specific data.
*/
void * specific;
};
 
/** Network interface module skeleton global data.
*/
struct netif_globals{
/** Networking module phone.
*/
int networking_phone;
/** Device map.
*/
device_map_t device_map;
};
 
/** Finds the device specific data.
* @param device_id The device identifier. Input parameter.
* @param device The device specific data. Output parameter.
* @returns EOK on success.
* @returns ENOENT if device is not found.
* @returns EPERM if the device is not initialized.
*/
int find_device( device_id_t device_id, device_ref * device );
 
/** Clears the usage statistics.
* @param stats The usage statistics. Input parameter.
*/
void null_device_stats( device_stats_ref stats );
 
#endif
/branches/network/uspace/srv/net/module.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
103,7 → 103,7
 
printf("\nTask %d - ", task_get_id());
module_print_name();
if( ERROR_OCCURED( module_start( client_connection ))){
if( ERROR_OCCURRED( module_start( client_connection ))){
printf( " - ERROR %i", ERROR_CODE );
return ERROR_CODE;
}
/branches/network/uspace/srv/net/self_test.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
/branches/network/uspace/srv/net/sockaddr.c
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/branches/network/uspace/srv/net/self_test.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
27,7 → 27,7
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/** @file
/branches/network/uspace/srv/net/err.h
1,5 → 1,5
/*
* Copyright (c) 2008 Lukas Mejdrech
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
48,17 → 48,17
*/
#define ERROR_DECLARE int ERROR_CODE
 
/** Stores the value as an error code and checks if an error occured.
/** Stores the value as an error code and checks if an error occurred.
* @param value The value to be checked. May be a function call. Input parameter.
* @returns FALSE if the value indicates success (EOK).
* @returns TRUE otherwise.
*/
#define ERROR_OCCURED( value ) (( ERROR_CODE = ( value )) != EOK )
#define ERROR_OCCURRED( value ) (( ERROR_CODE = ( value )) != EOK )
 
/** Checks if an error occured and immediatelly exits the actual function returning the error code.
/** Checks if an error occurred and immediately exits the actual function returning the error code.
* @param value The value to be checked. May be a function call. Input parameter.
*/
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURED( value )) return ERROR_CODE
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURRED( value )) return ERROR_CODE
 
#endif