Choco OS  V.0.16.9.0
Join to the chocolate world
Udp - User Datagram Protocol

Module for handling UDP protocol datagrams. More...

Data Structures

struct  PACKED
 stores IPv6 address More...
 
union  oC_Udp_Packet_t
 stores UDP packet More...
 

Typedefs

typedef struct PACKED oC_Udp_Header_t
 stores UDP header
 
typedef union PACKED oC_Udp_PseudoHeader_t
 pseudo UDP header required only for checksum calculation
 
typedef struct PACKED oC_Udp_Datagram_t
 stores UDP datagram
 
typedef struct Udp_t * oC_Udp_t
 stores information about UDP state More...
 

Enumerations

Functions

oC_ErrorCode_t oC_Udp_TurnOn (void)
 turns on UDP module More...
 
oC_ErrorCode_t oC_Udp_TurnOff (void)
 turns off UDP module More...
 
bool oC_Udp_IsPortReserved (oC_Udp_Port_t Port, oC_Process_t Process)
 checks if the given UDP port is reserved More...
 
oC_ErrorCode_t oC_Udp_ReservePort (oC_Udp_Port_t *Port, oC_Time_t Timeout)
 reserves a UDP port More...
 
oC_ErrorCode_t oC_Udp_ReleasePort (oC_Udp_Port_t Port, oC_Time_t Timeout)
 releases a port More...
 
oC_ErrorCode_t oC_Udp_ReleaseAllPortsReservedBy (oC_Process_t Process, oC_Time_t Timeout)
 releases all ports reserved by the process More...
 
uint16_t oC_Udp_Packet_GetMaximumDataSize (oC_Net_PacketType_t Type)
 returns maximum size of the data for UDP packet
 
oC_Udp_Packet_toC_Udp_Packet_New (Allocator_t PacketAllocator, oC_Net_PacketType_t Type, const void *Data, uint16_t Size)
 allocates memory for a UDP packet More...
 
bool oC_Udp_Packet_Delete (oC_Udp_Packet_t **Packet)
 release memory allocated for a UDP packet
 
uint16_t oC_Udp_Packet_GetDataSize (const oC_Udp_Packet_t *Packet)
 returns size of the data inside UDP packet
 
bool oC_Udp_Packet_SetData (oC_Udp_Packet_t *Packet, const void *Data, uint16_t Size)
 sets data inside UDP packet
 
oC_ErrorCode_t oC_Udp_Packet_ReadData (const oC_Udp_Packet_t *Packet, void *outData, uint16_t Size)
 reads data of the UDP packet
 
void * oC_Udp_Packet_GetDataReference (oC_Udp_Packet_t *Packet)
 returns reference to the data inside UDP packet
 
oC_ErrorCode_t oC_Udp_Send (oC_Netif_t Netif, oC_Udp_Port_t LocalPort, const oC_Net_Address_t *Destination, oC_Udp_Packet_t *Packet, oC_Time_t Timeout)
 sends UDP packet More...
 
oC_ErrorCode_t oC_Udp_Receive (oC_Netif_t Netif, oC_Udp_Port_t LocalPort, oC_Udp_Packet_t *Packet, oC_Time_t Timeout)
 receives UDP packet More...
 
oC_ErrorCode_t oC_Udp_CalculateChecksum (oC_Udp_Packet_t *Packet, bool *outChecksumCorrect, uint16_t *outExpectedChecksum)
 Calculates checksum for UDP packet. More...
 

Detailed Description

Typedef Documentation

typedef struct Udp_t* oC_Udp_t

The type is for storing data of the UDP instance. It has to be created by #oC_Udp_New before usage and destroyed by #oC_Udp_Delete when it is not needed anymore

Definition at line 330 of file oc_udp.h.

Enumeration Type Documentation

The type is for storing UDP port

See also
oC_Udp_Port_MAX
Enumerator
oC_Udp_Port_Empty 

Special value for marks port as not filled.

oC_Udp_Port_MAX 

maximum number of ports

oC_Udp_Port_TCPMUX 

have been assigned to TCPMUX by IANA, but by design only TCP is specified.

oC_Udp_Port_RemoteJobEntry 

Remote job entry.

oC_Udp_Port_Echo 

Echo Protocol.

oC_Udp_Port_Daytime 

Daytime Protocol.

oC_Udp_Port_QuoteOfTheDay 

Quote of the Day (QOTD)

oC_Udp_Port_MessageSend 

Message Send Protocol.

oC_Udp_Port_CHARGEN 

Character Generator Protocol (CHARGEN)

oC_Udp_Port_FTP 

File Transfer Protocol (FTP) data transfer.

oC_Udp_Port_Telnet 

Telnet protocol—unencrypted text communications.

oC_Udp_Port_SMTP 

Simple Mail Transfer Protocol (SMTP), used for e-mail routing between mail servers.

oC_Udp_Port_Time 

Time Protocol.

oC_Udp_Port_RAP 

Route Access Protocol (RAP)

oC_Udp_Port_RLP 

Resource Location Protocol (RLP)[importance?]—used for determining the location of higher level services from hosts on a network.

oC_Udp_Port_HostNameServer 

Host Name Server Protocol.

oC_Udp_Port_WHOIS 

WHOIS protocol.

oC_Udp_Port_TACACS 

TACACS+ Login Host protocol.

oC_Udp_Port_RemoteMailChecking 

Remote Mail Checking Protocol.

oC_Udp_Port_XNSTime 

Xerox Network Systems (XNS) Time Protocol.

oC_Udp_Port_DNS 

Domain Name System (DNS)

oC_Udp_Port_XNSClearingHouse 

Xerox Network Systems (XNS) clearinghouse.

oC_Udp_Port_XNSAuthentication 

Xerox Network Systems (XNS) authentication.

oC_Udp_Port_AnyPrivateTerminalAccess 

Any private terminal access.

oC_Udp_Port_XNSMail 

Xerox Network Systems (XNS) Mail.

oC_Udp_Port_BOOTPServer 

Bootstrap Protocol (BOOTP) server; also used by Dynamic Host Configuration Protocol (DHCP)

oC_Udp_Port_BOOTPClient 

Bootstrap Protocol (BOOTP) client; also used by Dynamic Host Configuration Protocol (DHCP)

oC_Udp_Port_TFTP 

Trivial File Transfer Protocol (TFTP)

oC_Udp_Port_Gopher 

Gopher protocol.

oC_Udp_Port_NETRJS 

NETRJS protocol.

oC_Udp_Port_AnyPrivateDialOutService 

Any private dial out service.

oC_Udp_Port_AnyPrivateRemoteJobEntry 

Any private Remote job entry.

oC_Udp_Port_Finger 

Finger protocol.

oC_Udp_Port_KerberosAuthenticationSystem 

Kerberos authentication system.

oC_Udp_Port_DNSIX 

dnsix (DoD Network Security for Information Exchange) Securit Attribute Token Map

oC_Udp_Port_NICHostName 

NIC host name.

oC_Udp_Port_TSAP 

ISO Transport Service Access Point (TSAP) Class 0 protocol;.

oC_Udp_Port_DICOM 

Digital Imaging and Communications in Medicine (DICOM; also port 11112)

oC_Udp_Port_CCSONameserver 

CCSO Nameserver.

oC_Udp_Port_RTelnet 

Remote User Telnet Service (RTelnet)

oC_Udp_Port_SNA 

IBM Systems Network Architecture (SNA) gateway access server.

oC_Udp_Port_POP2 

Post Office Protocol, version 2 (POP2)

oC_Udp_Port_POP3 

Post Office Protocol, version 3 (POP3)

oC_Udp_Port_OncRpc 

Open Network Computing Remote Procedure Call (ONC RPC, sometimes referred to as Sun RPC)

oC_Udp_Port_Auth 

Authentication Service (auth), the precedessor to identification protocol.

Used to determine an user's identity of a particular TCP connection.

oC_Udp_Port_SFTP 

Simple File Transfer Protocol.

oC_Udp_Port_UUCPMappingProject 

UUCP Mapping Project (path service)

oC_Udp_Port_SQLServices 

Structured Query Language (SQL) Services.

oC_Udp_Port_NNTP 

Network News Transfer Protocol (NNTP), retrieval of newsgroup messages.

oC_Udp_Port_NTP 

Network Time Protocol (NTP), used for time synchronization.

oC_Udp_Port_FormerlyUnisysUnitaryLogin 

Formerly Unisys Unitary Login, renamed by Unisys to NXEdit.

Used by Unisys Programmer's Workbench for Clearpath MCP, an IDE for Unisys MCP software development

oC_Udp_Port_DCEEndpointResolution 

DCE endpoint resolution.

oC_Udp_Port_MicrosoftEPMAP 

Microsoft EPMAP (End Point Mapper), also known as DCE/RPC Locator service, used to remotely manage services including DHCP server, DNS server and WINS.

Also used by DCOM

oC_Udp_Port_NetBIOS 

NetBIOS Name Service, used for name registration and resolution.

oC_Udp_Port_NetBIOSDatagram 

NetBIOS Datagram Service.

oC_Udp_Port_NetBIOSSession 

NetBIOS Session Service.

oC_Udp_Port_IMAP 

Internet Message Access Protocol (IMAP), management of electronic mail messages on a server.

oC_Udp_Port_BFTP 

Background File Transfer Program (BFTP)

oC_Udp_Port_SGMP 

Simple Gateway Monitoring Protocol (SGMP), a protocol for remote inspection and alteration of gateway management information.

oC_Udp_Port_SQL 

Structured Query Language (SQL) Service.

oC_Udp_Port_DMSP 

Distributed Mail System Protocol (DMSP, sometimes referred to as Pcmail)

oC_Udp_Port_SNMP 

Simple Network Management Protocol (SNMP)

oC_Udp_Port_SNMPTRAP 

Simple Network Management Protocol Trap (SNMPTRAP)

oC_Udp_Port_PrintServer 

Print server.

oC_Udp_Port_XDMCP 

X Display Manager Control Protocol (XDMCP), used for remote logins to an X Display Manager server.

oC_Udp_Port_IRC 

Internet Relay Chat (IRC)

oC_Udp_Port_SMUX 

SNMP multiplexing protocol (SMUX)

oC_Udp_Port_AppleTalkRoutingMaintenance 

AppleTalk Routing Maintenance.

oC_Udp_Port_QuickMailTransferProtocol 

Quick Mail Transfer Protocol.

oC_Udp_Port_ANSIZ39_50 

ANSI Z39.50.

oC_Udp_Port_IPX 

Internetwork Packet Exchange (IPX)

oC_Udp_Port_MPP 

Message posting protocol (MPP)

oC_Udp_Port_IMAPVer3 

Internet Message Access Protocol (IMAP), version 3.

oC_Udp_Port_ESRO 

Efficient Short Remote Operations (ESRO)

oC_Udp_Port_Arcisdms 

Arcisdms.

oC_Udp_Port_BGMP 

Border Gateway Multicast Protocol (BGMP)

oC_Udp_Port_http_mgmt 

http-mgmt

oC_Udp_Port_TSP 

PKIX Time Stamp Protocol (TSP)

oC_Udp_Port_PTPEvent 

Precision Time Protocol (PTP) event messages.

oC_Udp_Port_PTPGeneral 

Precision Time Protocol (PTP) general messages.

oC_Udp_Port_MATIP 

Mapping of Airline Traffic over Internet Protocol (MATIP) type A.

oC_Udp_Port_MATIPTypeB 

MATIP type B.

oC_Udp_Port_Cloanto_net_1 

cloanto-net-1 (used by Cloanto Amiga Explorer and VMs)

oC_Udp_Port_ODMR 

On-Demand Mail Relay (ODMR)

oC_Udp_Port_Rpc2portmap 

Rpc2portmap.

oC_Udp_Port_CodaAuth2 

codaauth2, Coda authentication server

oC_Udp_Port_SecureCast1 

securecast1, outgoing packets to NAI's SecureCast serversAs of 2000

oC_Udp_Port_ClearCaseAlbd 

ClearCase albd.

oC_Udp_Port_HPDataAlarmManager 

HP data alarm manager.

oC_Udp_Port_ARemoteNetworkServerSystem 

A Remote Network Server System.

oC_Udp_Port_AURP 

AURP (AppleTalk Update-based Routing Protocol)

oC_Udp_Port_LDAP 

Lightweight Directory Access Protocol (LDAP)

oC_Udp_Port_DigitalEquipmentCorporationDEC 

Digital Equipment Corporation DECnet (Phase V+) over TCP/IP.

oC_Udp_Port_UPS 

Uninterruptible power supply (UPS)

oC_Udp_Port_SLP 

Service Location Protocol (SLP)

oC_Udp_Port_NNSP 

NNSP, part of Network News Transfer Protocol.

oC_Udp_Port_MobileIpAgent 

Mobile IP Agent (RFC 5944)

oC_Udp_Port_SNPP 

Simple Network Paging Protocol (SNPP), RFC 1568.

oC_Udp_Port_KerberosChangeSetPassword 

Kerberos Change/Set password.

oC_Udp_Port_TcpNetHaspsrv 

tcpnethaspsrv, Aladdin Knowledge Systems Hasp services

oC_Udp_Port_ISAKMP 

Internet Security Association and Key Management Protocol (ISAKMP) / Internet Key Exchange (IKE)

oC_Udp_Port_Modbus 

Modbus Protocol.

oC_Udp_Port_Citadel 

Citadel, multiservice protocol for dedicated clients for the Citadel groupware system.

oC_Udp_Port_FCP 

FirstClass Protocol (FCP), used by FirstClass client/server groupware system.

oC_Udp_Port_ComSat 

comsat, together with biff

oC_Udp_Port_Who 

Who.

oC_Udp_Port_Syslog 

Syslog, used for system logging.

oC_Udp_Port_Talk 

Talk.

oC_Udp_Port_NTalk 

NTalk.

oC_Udp_Port_RIP 

Routing Information Protocol (RIP)

oC_Udp_Port_RIPng 

Routing Information Protocol Next Generation (RIPng)

oC_Udp_Port_NCP 

NetWare Core Protocol (NCP) is used for a variety things such as access to primary NetWare server resources, Time Synchronization, etc.

oC_Udp_Port_TimedTimeserver 

Timed, Timeserver.

oC_Udp_Port_RPC 

Remote procedure call (RPC)

oC_Udp_Port_NetwallForEmergencyBroadcasts 

netwall, For Emergency Broadcasts

oC_Udp_Port_Commerce 

commerce (Commerce Applications)

oC_Udp_Port_DHCPv6Client 

DHCPv6 client.

oC_Udp_Port_DHCPv6Server 

DHCPv6 server.

oC_Udp_Port_NewRwhoNewWho 

new-rwho, new-who

oC_Udp_Port_RTSP 

Real Time Streaming Protocol (RTSP)

oC_Udp_Port_RMonitorRemoteMonitor 

rmonitor, Remote Monitor

oC_Udp_Port_Monitor 

monitor

oC_Udp_Port_NNTPS 

NNTP over TLS/SSL (NNTPS)

oC_Udp_Port_HTTP 

HTTP RPC Ep Map, Remote procedure call over Hypertext Transfer Protocol, often used by Distributed Component Object Model services and Microsoft Exchange Server.

oC_Udp_Port_ASFRemoteManagementAndControl 

ASF Remote Management and Control Protocol (ASF-RMCP) & IPMI Remote Management Protocol.

oC_Udp_Port_IPP 

Internet Printing Protocol (IPP)

oC_Udp_Port_RLZDBase 

RLZ DBase.

oC_Udp_Port_LDAPS 

Lightweight Directory Access Protocol over TLS/SSL (LDAPS)

oC_Udp_Port_MSDPMulticastSourceDiscovery 

MSDP, Multicast Source Discovery Protocol.

oC_Udp_Port_SupportSoftNexusRemoteControl 

SupportSoft Nexus Remote Command (control/listening), a proxy gateway connecting remote control traffic.

oC_Udp_Port_SANity 

SANity.

oC_Udp_Port_LDP 

Label Distribution Protocol (LDP), a routing protocol used in MPLS networks.

oC_Udp_Port_IEEE_MMS 

IEEE-MMS.

oC_Udp_Port_SupportSoftNexusRemoteData 

SupportSoft Nexus Remote Command (data), a proxy gateway connecting remote control traffic.

oC_Udp_Port_TincVPNDaemon 

Tinc VPN daemon.

oC_Udp_Port_IBMRMC 

IBM RMC (Remote monitoring and Control) protocol, used by System p5 AIX Integrated Virtualization Manager (IVM) and Hardware Management Console to connect managed logical partitions (LPAR) to enable dynamic partition reconfiguration.

oC_Udp_Port_Doom 

Doom, first online first-person shooter.

oC_Udp_Port_REALM_RUSD 

REALM-RUSD (ApplianceWare Server Appliance Management Protocol)

oC_Udp_Port_VATP 

Velneo Application Transfer Protocol (VATP)

oC_Udp_Port_Linux 

Linux-HA high-availability heartbeat.

oC_Udp_Port_OLSR 

Optimized Link State Routing (OLSR)

oC_Udp_Port_Kerberos 

Kerberos (protocol) administration.

oC_Udp_Port_kerberos_IvKerberosVersionIV 

kerberos-iv, Kerberos version IV

oC_Udp_Port_RRH 

Reverse Routing Header (RRH)

oC_Udp_Port_TellSend 

tell send

oC_Udp_Port_mdbs_daemon 

mdbs-daemon

oC_Udp_Port_NETCONFOverSSH 

NETCONF over SSH.

oC_Udp_Port_NETCONFOverBEEP 

NETCONF over BEEP.

oC_Udp_Port_NETCONFHTTPS 

NETCONF for SOAP over HTTPS.

oC_Udp_Port_NETCONFBEEP 

NETCONF for SOAP over BEEP.

oC_Udp_Port_GDOI 

Group Domain Of Interpretation (GDOI) protocol.

oC_Udp_Port_DNSOverTLS 

DNS over TLS (RFC 7858)

oC_Udp_Port_OWAMP 

OWAMP control (RFC 4656)

oC_Udp_Port_TWAMP 

TWAMP control (RFC 5357)

oC_Udp_Port_FTPSData 

FTPS Protocol (data), FTP over TLS/SSL.

oC_Udp_Port_FTPSControl 

FTPS Protocol (control), FTP over TLS/SSL.

oC_Udp_Port_NAS 

Netnews Administration System (NAS)

oC_Udp_Port_TelnetOverTLS_SSL 

Telnet protocol over TLS/SSL.

oC_Udp_Port_NumberOfSpecialPorts 

number of special ports, that are reserved for special service

Definition at line 74 of file oc_udp.h.

Function Documentation

oC_ErrorCode_t oC_Udp_CalculateChecksum ( oC_Udp_Packet_t Packet,
bool *  outChecksumCorrect,
uint16_t *  outExpectedChecksum 
)

The function is for calculating checksum for UDP packets. The packet has to be in the host byte endianess.

Parameters
PacketPacket to calculate a checksum
outChecksumCorrectDestination for a flag that will be set if checksum is correct (or NULL if not used)
outExpectedChecksumDestination for a checksum (or NULL if not used)
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_AddressNotInRam Packet does not point to the RAM section
oC_ErrorCode_OutputAddressNotInRAM outChecksumCorrect or outExpectedChecksum does not point to the RAM section

Definition at line 926 of file oc_udp.c.

bool oC_Udp_IsPortReserved ( oC_Udp_Port_t  Port,
oC_Process_t  Process 
)

The function checks if the given port is reserved. If Process parameter is not NULL, the function will check if the given port is reserved by this process.

Parameters
PortPort to check
ProcessProcess which check if it is an owner of the port
Returns
true if the port is reserved

Definition at line 235 of file oc_udp.c.

oC_Udp_Packet_t* oC_Udp_Packet_New ( Allocator_t  PacketAllocator,
oC_Net_PacketType_t  Type,
const void *  Data,
uint16_t  Size 
)

The function is for allocating memory for the UDP packet. It calculates memory required for the packet including all headers of sub-layers. Memory should be released, when is not needed anymore by using the function oC_Udp_Packet_Delete

Note
In case of failure, error can be read from the errors stack
Parameters
PacketAllocatorAllocator for the Memory Manager
TypeType of the packet (IPv4 or IPv6)
DataAddress of the data to put inside the UDP packet. It can be NULL if you dont want to fill it now
SizeSize of the data inside UDP packet
Returns
pointer to the allocated memory
See also
oC_Udp_Packet_Delete

Definition at line 547 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_Receive ( oC_Netif_t  Netif,
oC_Udp_Port_t  LocalPort,
oC_Udp_Packet_t Packet,
oC_Time_t  Timeout 
)

The function is for receiving UDP packets at the selected UDP port. The port has to be reserved for the current process, otherwise receiving is not possible.

Note
Remember that you have to reserve a local port by using function oC_Udp_ReservePort before usage.
Warning
Function will receive only packets that matches Packet type, so if the type of the Packet is set to IPv4, the function will receive only packets that contains IPv4 address!
Parameters
NetifNetwork interface to receive packet from or NULL if not used
LocalPortLocal UDP port to which at receive a packet
PacketDestination for a received packet. It should be allocated by the function oC_Udp_Packet_New
TimeoutMaximum time for the send request
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_NetifNotCorrect Netif is not correct (address is not correct or not valid anymore) and it is not NULL
oC_ErrorCode_PortNotCorrect LocalPort is not correct
oC_ErrorCode_TimeNotCorrect Timeout value is lower than 0!!
oC_ErrorCode_OutputAddressNotInRAM Packet does not point to the RAM section
oC_ErrorCode_PortNotReserved The given LocalPort is not reserved by using the function oC_Udp_ReservePort
oC_ErrorCode_PortReservedByDifferentProcess The given LocalPort is already reserved by different process. Please use another one
oC_ErrorCode_SizeNotCorrect Size of the UDP packet is set to 0
oC_ErrorCode_PortBusy The given local port is busy (Maximum time for the request elapsed)
oC_ErrorCode_ModuleBusy Module is busy (Maximum time for the request elapsed)
oC_ErrorCode_Timeout Maximum time for the request elapsed
oC_ErrorCode_OutputBufferTooSmall Packet buffer is too small to receive a packet
See also
oC_Udp_Receive, oC_Udp_TurnOn, oC_Udp_ReservePort, oC_Udp_Packet_New

Definition at line 852 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_ReleaseAllPortsReservedBy ( oC_Process_t  Process,
oC_Time_t  Timeout 
)

Only one application can use a port at once, otherwise it can cause loosing of datagrams. This function allows to release all reserved port that are owned by the given process when they are not needed anymore.

Note
This function can be called only by the root user. It is not enough to have admin privileges - you have to be a root.
Parameters
ProcessProcess that reserved some UDP ports
TimeoutMaximum time to wait for the module readiness
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_ProcessNotCorrect Process is not correct or not valid anymore
oC_ErrorCode_TimeNotCorrect Timeout value is lower than 0!!
oC_ErrorCode_Timeout Module is still busy and maximum time for this operation has elapsed
oC_ErrorCode_PossibleOnlyForRoot Function can be called only by the root user. You are not permitted to perform this
See also
oC_Udp_Receive, oC_Udp_Send, oC_Udp_TurnOn, oC_Udp_ReleasePort

Definition at line 481 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_ReleasePort ( oC_Udp_Port_t  Port,
oC_Time_t  Timeout 
)

Only one application can use a port at once, otherwise it can cause loosing of datagrams. This function allows to release reserved port when it is not needed anymore. Reservation is performed for a current process and only this process will be able to use the reserved port. Usually all reserved ports are automatically released, when the process is killed.

Parameters
PortLocal port reserved by calling a function oC_Udp_ReservePort
TimeoutMaximum time to wait for the module readiness
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_PortNotCorrect Port is not correct UDP port
oC_ErrorCode_TimeNotCorrect Timeout value is lower than 0!!
oC_ErrorCode_Timeout Module is still busy and maximum time for this operation has elapsed
oC_ErrorCode_PortNotReserved The given LocalPort is not reserved by using the function oC_Udp_ReservePort
oC_ErrorCode_PortReservedByDifferentProcess The given LocalPort is reserved by different process.
oC_ErrorCode_PortBusy The given LocalPort is currently in use.
oC_ErrorCode_CannotDeleteObject Cannot delete Mutex related with the local port.
See also
oC_Udp_Receive, oC_Udp_Send, oC_Udp_TurnOn, oC_Udp_ReleasePort

Definition at line 412 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_ReservePort ( oC_Udp_Port_t Port,
oC_Time_t  Timeout 
)

Only one application can use a port at once, otherwise it can cause loosing of datagrams. This function allows to reserve a port before usage. Reservation is performed for a current process and only this process will be able to use the reserved port.

Warning
Only root user can use special ports
Parameters
PortAddress to the reserved port on output. On input it is port to reserve. It can be oC_Udp_Port_Empty if you want to find first available port
TimeoutMaximum time for the operation
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_OutputAddressNotInRAM Port does not point to RAM section
oC_ErrorCode_PortNotAvailable The are no free ports or the selected one is already reserved
oC_ErrorCode_TimeNotCorrect Timeout value is lower than 0!!
oC_ErrorCode_Timeout Port is still busy and maximum time for this operation has elapsed
oC_ErrorCode_ModuleBusy Module is still busy and maximum time for this operation has elapsed
oC_ErrorCode_PermissionDenied You are not allowed to use the selected UDP port (only root can use special ports)
See also
oC_Udp_Receive, oC_Udp_Send, oC_Udp_TurnOn, oC_Udp_ReleasePort

Definition at line 281 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_Send ( oC_Netif_t  Netif,
oC_Udp_Port_t  LocalPort,
const oC_Net_Address_t Destination,
oC_Udp_Packet_t Packet,
oC_Time_t  Timeout 
)

The function prepares UDP packet and sends it to the recipient. Remember that you have to reserve a local port by using function oC_Udp_ReservePort before usage.

Parameters
NetifPointer to the configured network interface or NULL if not used
LocalPortLocal port of the UDP for receiving (the port on which the recipient should respond). It should be reserved by the function oC_Udp_ReservePort before usage
DestinationDestination address where the packet should be sent (with the Port filled as destination port)
PacketUDP packet to send allocated by the function oC_Udp_Packet_New
TimeoutMaximum time for the send request
Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_NetifNotCorrect Netif is not correct (address is not correct or not valid anymore) and it is not NULL
oC_ErrorCode_PortNotCorrect Destination->Port or LocalPort is not correct
oC_ErrorCode_OutputAddressNotInRAM Packet does not point to the RAM section
oC_ErrorCode_WrongAddress Destination is not correct memory address
oC_ErrorCode_IpAddressNotCorrect Destination stores IP address that is not correct (probably type is not set)
oC_ErrorCode_SizeNotCorrect Size of the UDP packet is set to 0
oC_ErrorCode_TimeNotCorrect Timeout value is lower than 0!!
oC_ErrorCode_Timeout Maximum time for the request elapsed
oC_ErrorCode_PortNotReserved The given LocalPort is not reserved by using the function oC_Udp_ReservePort
oC_ErrorCode_PortReservedByDifferentProcess The given LocalPort is already reserved by different process. Please use another one
oC_ErrorCode_SizeTooBig Size of the UDP packet is set to too big value (it exceed maximum size of the packet)
oC_ErrorCode_PacketNotCorrect UDP packet is not correct (probably IP type is not set correctly)
oC_ErrorCode_TypeNotCorrect UDP packet type and destination address type are not the same
oC_ErrorCode_CannotFindNetifForTheAddress Netif is not given (NULL) but we cannot find any that can achieve the given address
oC_ErrorCode_ModuleBusy Module is busy (Maximum time for the request elapsed)
oC_ErrorCode_PortBusy The given local port is busy (Maximum time for the request elapsed)
See also
oC_Udp_Receive, oC_Udp_TurnOn, oC_Udp_ReservePort, oC_Udp_Packet_New

Definition at line 732 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_TurnOff ( void  )

The function is for turning off UDP module. The module has to be turned off before usage and turned off when is not needed.

Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleNotStartedYet UDP module is not turned on. Please call oC_Udp_TurnOn first
oC_ErrorCode_ReleaseError Cannot release memory
See also
oC_Udp_TurnOn

Definition at line 188 of file oc_udp.c.

oC_ErrorCode_t oC_Udp_TurnOn ( void  )

The function is for turning on UDP module. The module has to be turned on before usage.

Returns
code of error or oC_ErrorCode_None if success

List of standard error codes, that can be returned by the function:

Code of error Description
oC_ErrorCode_ModuleIsTurnedOn UDP module is already turned on.
oC_ErrorCode_AllocationError Cannot allocate memory
See also
oC_Udp_TurnOff

Definition at line 132 of file oc_udp.c.