Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

ip.c File Reference

ip.c File Reference

IPv4 and IPv6 common routines. More...

Go to the source code of this file.

Functions

error_t ipSendDatagram (NetInterface *interface, IpPseudoHeader *pseudoHeader, NetBuffer *buffer, size_t offset, uint8_t ttl)
 Send an IP datagram.
error_t ipSelectSourceAddr (NetInterface **interface, const IpAddr *destAddr, IpAddr *srcAddr)
 IP source address selection.
uint16_t ipCalcChecksum (const void *data, size_t length)
 IP checksum calculation.
uint16_t ipCalcChecksumEx (const NetBuffer *buffer, size_t offset, size_t length)
 Calculate IP checksum over a multi-part buffer.
uint16_t ipCalcUpperLayerChecksum (const void *pseudoHeader, size_t pseudoHeaderLength, const void *data, size_t dataLength)
 Calculate IP upper-layer checksum.
uint16_t ipCalcUpperLayerChecksumEx (const void *pseudoHeader, size_t pseudoHeaderLength, const NetBuffer *buffer, size_t offset, size_t length)
 Calculate IP upper-layer checksum over a multi-part buffer.
NetBufferipAllocBuffer (size_t length, size_t *offset)
 Allocate a buffer to hold an IP packet.
error_t ipJoinMulticastGroup (NetInterface *interface, const IpAddr *groupAddr)
 Join the specified host group.
error_t ipLeaveMulticastGroup (NetInterface *interface, const IpAddr *groupAddr)
 Leave the specified host group.
bool_t ipIsUnspecifiedAddr (const IpAddr *ipAddr)
 Compare an IP address against the unspecified address.
error_t ipStringToAddr (const char_t *str, IpAddr *ipAddr)
 Convert a string representation of an IP address to a binary IP address.
char_t * ipAddrToString (const IpAddr *ipAddr, char_t *str)
 Convert a binary IP address to a string representation.

Detailed Description

IPv4 and IPv6 common routines.

License

Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

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 Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author:
Oryx Embedded SARL (www.oryx-embedded.com)
Version:
1.7.6

Definition in file ip.c.


Function Documentation

char_t* ipAddrToString ( const IpAddr ipAddr,
char_t *  str 
)

Convert a binary IP address to a string representation.

Parameters:
[in]ipAddrBinary representation of the IP address
[out]strNULL-terminated string representing the IP address
Returns:
Pointer to the formatted string

Definition at line 652 of file ip.c.

NetBuffer* ipAllocBuffer ( size_t  length,
size_t *  offset 
)

Allocate a buffer to hold an IP packet.

Parameters:
[in]lengthDesired payload length
[out]offsetOffset to the first byte of the payload
Returns:
The function returns a pointer to the newly allocated buffer. If the system is out of resources, NULL is returned

Definition at line 447 of file ip.c.

uint16_t ipCalcChecksum ( const void *  data,
size_t  length 
)

IP checksum calculation.

Parameters:
[in]dataPointer to the data over which to calculate the IP checksum
[in]lengthNumber of bytes to process
Returns:
Checksum value

Definition at line 145 of file ip.c.

uint16_t ipCalcChecksumEx ( const NetBuffer buffer,
size_t  offset,
size_t  length 
)

Calculate IP checksum over a multi-part buffer.

Parameters:
[in]bufferPointer to the multi-part buffer
[in]offsetOffset from the beginning of the buffer
[in]lengthNumber of bytes to process
Returns:
Checksum value

Definition at line 182 of file ip.c.

uint16_t ipCalcUpperLayerChecksum ( const void *  pseudoHeader,
size_t  pseudoHeaderLength,
const void *  data,
size_t  dataLength 
)

Calculate IP upper-layer checksum.

Parameters:
[in]pseudoHeaderPointer to the pseudo header
[in]pseudoHeaderLengthPseudo header length
[in]dataPointer to the upper-layer data
[in]dataLengthUpper-layer data length
Returns:
Checksum value

Definition at line 350 of file ip.c.

uint16_t ipCalcUpperLayerChecksumEx ( const void *  pseudoHeader,
size_t  pseudoHeaderLength,
const NetBuffer buffer,
size_t  offset,
size_t  length 
)

Calculate IP upper-layer checksum over a multi-part buffer.

Parameters:
[in]pseudoHeaderPointer to the pseudo header
[in]pseudoHeaderLengthPseudo header length
[in]bufferMulti-part buffer containing the upper-layer data
[in]offsetOffset from the first data byte to process
[in]lengthNumber of data bytes to process
Returns:
Checksum value

Definition at line 409 of file ip.c.

bool_t ipIsUnspecifiedAddr ( const IpAddr ipAddr )

Compare an IP address against the unspecified address.

Parameters:
[in]ipAddrIP address
Returns:
TRUE if the IP address is unspecified, else FALSE

Definition at line 579 of file ip.c.

error_t ipJoinMulticastGroup ( NetInterface *  interface,
const IpAddr groupAddr 
)

Join the specified host group.

Parameters:
[in]interfaceUnderlying network interface (optional parameter)
[in]groupAddrIP address identifying the host group to join
Returns:
Error code

Definition at line 492 of file ip.c.

error_t ipLeaveMulticastGroup ( NetInterface *  interface,
const IpAddr groupAddr 
)

Leave the specified host group.

Parameters:
[in]interfaceUnderlying network interface (optional parameter)
[in]groupAddrIP address identifying the host group to leave
Returns:
Error code

Definition at line 542 of file ip.c.

error_t ipSelectSourceAddr ( NetInterface **  interface,
const IpAddr destAddr,
IpAddr srcAddr 
)

IP source address selection.

This function selects the source address and the relevant network interface to be used in order to join the specified destination address

Parameters:
[in,out]interfaceA pointer to a valid network interface may be provided as a hint. The function returns a pointer identifying the interface to be used
[in]destAddrDestination IP address
[out]srcAddrLocal IP address to be used
Returns:
Error code

Definition at line 105 of file ip.c.

error_t ipSendDatagram ( NetInterface *  interface,
IpPseudoHeader pseudoHeader,
NetBuffer buffer,
size_t  offset,
uint8_t  ttl 
)

Send an IP datagram.

Parameters:
[in]interfaceUnderlying network interface
[in]pseudoHeaderIP pseudo header
[in]bufferMulti-part buffer containing the payload
[in]offsetOffset to the first payload byte
[in]ttlTTL value. Default Time-To-Live is used when this parameter is zero
Returns:
Error code

Definition at line 56 of file ip.c.

error_t ipStringToAddr ( const char_t *  str,
IpAddr ipAddr 
)

Convert a string representation of an IP address to a binary IP address.

Parameters:
[in]strNULL-terminated string representing the IP address
[out]ipAddrBinary representation of the IP address
Returns:
Error code

Definition at line 613 of file ip.c.