Choco OS  V.0.16.9.0
Join to the chocolate world
oc_net.h File Reference

File with interface for the NET module. More...

#include <oc_memory.h>
#include <oc_stdio.h>
#include <oc_baudrate.h>
#include <oc_compiler.h>
#include <oc_string.h>
#include <oc_stdlib.h>
#include <oc_array.h>
#include <oc_debug.h>
#include <oc_memman.h>
#include <oc_math.h>

Go to the source code of this file.

Data Structures

struct  oC_Net_HardwareAddress_t
 stores hardware address More...
 
struct  PACKED
 stores IPv6 address More...
 
struct  PACKED
 stores IPv6 address More...
 
struct  PACKED
 stores IPv6 address More...
 
struct  PACKED
 stores IPv6 address More...
 
struct  PACKED
 stores IPv6 address More...
 
union  oC_Net_Packet_t
 stores network packet More...
 
struct  oC_Net_Frame_t
 stores informations about the frame to send More...
 
struct  oC_Net_QueueStatus_t
 stores status of network queue More...
 
struct  oC_Net_Address_t
 stores network address More...
 
struct  oC_Net_Ipv4Info_t
 stores network interface IPv4 informations More...
 
struct  oC_Net_Ipv6Info_t
 stores network interface IPv6 informations More...
 
struct  oC_Net_Info_t
 stores network interface informations More...
 

Typedefs

typedef uint8_t oC_Net_MacAddress_t[MAC_ADDRESS_LENGTH]
 stores MAC address
 
typedef uint32_t oC_Net_Ipv4_t
 stores IPv4 address More...
 
typedef struct PACKED oC_Net_Ipv6_t
 stores IPv6 address More...
 
typedef struct PACKED oC_Net_Ipv4PacketHeader_t
 contains IPv4 packet header More...
 
typedef struct PACKED oC_Net_Ipv6PacketHeader_t
 contains IPv6 packet header More...
 
typedef struct PACKED oC_Net_Ipv4Packet_t
 stores IPv4 packet More...
 
typedef struct PACKED oC_Net_Ipv6Packet_t
 stores IPv6 packet More...
 
typedef uint32_t oC_Net_InterfaceIndex_t
 stores index of the interface More...
 
typedef char oC_Net_InterfaceName_t[IFNAMSIZ]
 stores name of the network interface More...
 
typedef char oC_Net_FriendlyInterfaceName_t[MAXIMUM_FRIENDLY_INTERFACE_NAME]
 type for storing friendly name string More...
 
typedef uint16_t oC_Net_Port_t
 Port of the network address. More...
 
typedef uint32_t oC_Net_Cost_t
 stores cost of the network connection
 

Enumerations

Functions

static uint16_t oC_Net_ConvertUint16ToNetworkEndianess (uint16_t v)
 converts uint16_t to network byte order
 
static uint32_t oC_Net_ConvertUint32ToNetworkEndianess (uint32_t v)
 converts uint32_t to network byte order
 
static uint16_t oC_Net_ConvertUint16FromNetworkEndianess (uint16_t v)
 converts uint16_t from network byte order
 
static uint32_t oC_Net_ConvertUint32FromNetworkEndianess (uint32_t v)
 converts uint32_t from network byte order
 
static void oC_Net_ConvertBufferToNetworkEndianess (void *Buffer, uint16_t Size)
 converts buffer to network endianess
 
static void oC_Net_ConvertBufferFromNetworkEndianess (void *Buffer, uint16_t Size)
 converts buffer from network endianess
 
static int oC_Net_PrepareInterfaceName (oC_Net_InterfaceName_t *outName, const char *Prefix, oC_Net_InterfaceIndex_t Index)
 prepares interface name string More...
 
static int oC_Net_MacAddressFromString (const char *MacAddressString, oC_Net_MacAddress_t outMacAddress)
 reads MAC address from the string More...
 
static const char * oC_Net_GetProtocolName (oC_Net_Protocol_t Protocol)
 returns user friendly name of the protocol
 
static oC_ErrorCode_t oC_Net_HardwareAddressToString (const oC_Net_HardwareAddress_t *HardwareAddress, oC_Net_HardwareType_t Type, char *outString, oC_MemorySize_t Size)
 prints HW address to the string More...
 
static oC_ErrorCode_t oC_Net_Ipv4AddressToString (oC_Net_Ipv4_t Address, char *outString, oC_MemorySize_t Size)
 prints IPv4 address to the string More...
 
static oC_ErrorCode_t oC_Net_AddressToString (const oC_Net_Address_t *Address, char *outString, oC_MemorySize_t Size)
 prints IP to the string More...
 
static oC_ErrorCode_t oC_Net_AddressFromString (const char *Address, oC_Net_Address_t *outAddress)
 reads IP address from the string More...
 
static bool oC_Net_IsAddressCorrect (const oC_Net_Address_t *Address)
 returns true if the given address is correct More...
 
static bool oC_Net_IsAddressEmpty (const oC_Net_Address_t *Address)
 returns true if the given address is empty More...
 
static bool oC_Net_Ipv4_IsAddressInSubnet (oC_Net_Ipv4_t IP, oC_Net_Ipv4_t Subnet, oC_Net_Ipv4_t Mask)
 checks if the IPv4 address belongs to the given subnetwork More...
 
static bool oC_Net_IsAddressInSubnet (const oC_Net_Address_t *Address, const oC_Net_Address_t *Subnet, const oC_Net_Address_t *Mask)
 checks if the address is in subnet More...
 
static bool oC_Net_AreAddressesTheSame (const oC_Net_Address_t *Address1, const oC_Net_Address_t *Address2)
 returns true if both pointers stores the same address More...
 
static uint16_t oC_Net_GetMaximumPacketDataSize (oC_Net_PacketType_t Type)
 returns maximum size of the packet data
 
static uint16_t oC_Net_GetPacketSize (const oC_Net_Packet_t *Packet, bool WithHeader)
 returns size of the packet More...
 
static bool oC_Net_ConvertHeaderToNetworkEndianess (oC_Net_Packet_t *Packet)
 converts header to network endianess
 
static bool oC_Net_ConvertHeaderFromNetworkEndianess (oC_Net_Packet_t *Packet)
 converts header from network endianess
 
static oC_MemorySize_t oC_Net_GetHardwareAddressSize (oC_Net_HardwareType_t Type)
 returns size of the hardware address (in bytes)
 
static oC_MemorySize_t oC_Net_GetAddressSize (const oC_Net_Address_t *Address)
 returns size of IP address
 
static const char * oC_Net_GetHardwareTypeName (oC_Net_HardwareType_t Type)
 returns name of the hardware type
 
static oC_ErrorCode_t oC_Net_ReadLayerName (oC_Net_Layer_t Layer, char *outName, oC_MemorySize_t Size)
 reads network layer name
 
static oC_ErrorCode_t oC_Net_ReadLayerByName (oC_Net_Layer_t *outLayer, const char *Name)
 returns network OSI layer according to its name
 
static bool oC_Net_IsMainLayer (oC_Net_Layer_t Layer, oC_Net_Layer_t MainLayer)
 returns true if Layer is part of the MainLayer
 
static oC_Net_PacketType_t oC_Net_Packet_GetType (const oC_Net_Packet_t *Packet)
 returns type of the packet More...
 
static bool oC_Net_Packet_SetSize (oC_Net_Packet_t *Packet, uint16_t Size)
 sets size of the packet
 
static void * oC_Net_Packet_GetDataReference (oC_Net_Packet_t *Packet)
 returns reference to the payload in the packet
 
static void oC_Net_Packet_SetAddress (oC_Net_Packet_t *Packet, const oC_Net_Address_t *Source, const oC_Net_Address_t *Destination)
 sets addresses in the packet
 
static void oC_Net_Packet_SetData (oC_Net_Packet_t *Packet, const void *Data, uint16_t Size)
 sets payload in the packet
 
static oC_Net_Packet_toC_Net_Packet_New (Allocator_t Allocator, oC_Net_PacketType_t Type, void *Data, uint16_t Size)
 allocates memory for a packet
 
static bool oC_Net_Packet_Delete (oC_Net_Packet_t **Packet)
 releases memory allocated for a packet
 
static uint16_t oC_Net_CalculateChecksum (const void *Buffer, uint16_t Size, uint16_t InitialValue, bool ConvertEndianess, bool PrepareChecksumToSend)
 
static uint16_t oC_Net_Packet_CalculateChecksum (oC_Net_Packet_t *Packet)
 calculates checksum for a packet (it only calculates it and does not fill it!)
 

Detailed Description


Author
Patryk Kubiak
Note
Copyright (C) 2016 Patryk Kubiak patry.nosp@m.k.ku.nosp@m.biak9.nosp@m.0@gm.nosp@m.ail.c.nosp@m.om

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Definition in file oc_net.h.

Typedef Documentation

typedef char oC_Net_FriendlyInterfaceName_t[MAXIMUM_FRIENDLY_INTERFACE_NAME]

The type is for storing friendly name string of the network interface (the string that is easy to understand and remember for human).

Definition at line 393 of file oc_net.h.