OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
endianconv.c File Reference
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "endianconv.h"
Include dependency graph for endianconv.c:

Go to the source code of this file.

Functions

int AddDintToMessage (const EipUint32 data, EipUint8 **const buffer)
 Converts UINT32 data from host to little endian and writes it to buffer. More...
 
int AddIntToMessage (const EipUint16 data, EipUint8 **const buffer)
 converts UINT16 data from host to little endian an writes it to buffer. More...
 
int AddSintToMessage (const EipUint8 data, EipUint8 **const buffer)
 converts UINT8 data from host to little endian an writes it to buffer. More...
 
void DetermineEndianess ()
 Detects Endianess of the platform and sets global g_nOpENerPlatformEndianess variable accordingly. More...
 
int EncapsulateIpAddress (EipUint16 port, EipUint32 address, EipByte **communication_buffer)
 Encapsulate the sockaddr information as necessary for the Common Packet Format data items. More...
 
int FillNextNMessageOctetsWith (CipOctet value, unsigned int amount_of_bytes_written, CipOctet **message)
 
int FillNextNMessageOctetsWithValueAndMoveToNextPosition (CipOctet value, unsigned int amount_of_filled_bytes, CipOctet **message)
 
CipByte GetByteFromMessage (const CipOctet **const buffer_address)
 
EipUint32 GetDintFromMessage (const EipUint8 **const buffer)
 Reads EIP_UINT32 from *buffer and converts little endian to host. More...
 
int GetEndianess ()
 Returns global variable g_nOpENerPlatformEndianess, whereas 0 equals little endian and 1 equals big endian. More...
 
EipUint16 GetIntFromMessage (const EipUint8 **const buffer)
 Reads EIP_UINT16 from *buffer and converts little endian to host. More...
 
EipUint8 GetSintFromMessage (const EipUint8 **const buffer)
 Reads EIP_UINT8 from *buffer and converts little endian to host. More...
 
CipUdint GetUdintFromMessage (const CipOctet **const buffer_address)
 
CipUint GetUintFromMessage (const CipOctet **const buffer_address)
 
CipUsint GetUsintFromMessage (const CipOctet **const buffer_address)
 
CipWord GetWordFromMessage (const CipOctet **const buffer_address)
 
int MoveMessageNOctets (const int amount_of_bytes_moved, const CipOctet **message_runner)
 

Variables

OpenerEndianess g_opener_platform_endianess = kOpenerEndianessUnknown
 

Function Documentation

void DetermineEndianess ( void  )

Detects Endianess of the platform and sets global g_nOpENerPlatformEndianess variable accordingly.

Detects Endianess of the platform and sets global variable g_nOpENerPlatformEndianess accordingly, whereas 0 equals little endian and 1 equals big endian

Definition at line 239 of file endianconv.c.

References g_opener_platform_endianess, kOpENerEndianessBig, and kOpENerEndianessLittle.

Referenced by EncapsulationInit().

Here is the caller graph for this function:

int EncapsulateIpAddress ( EipUint16  port,
EipUint32  address,
EipByte **  communication_buffer 
)

Encapsulate the sockaddr information as necessary for the Common Packet Format data items.

Converts and adds the provided port and IP address into an common packet format message

Parameters
portPort of the socket, has to be provided in big-endian
addressIP address of the socket, has to be provided in big-endian
communication_bufferThe message buffer for sending the message

Definition at line 197 of file endianconv.c.

References AddDintToMessage(), AddIntToMessage(), g_opener_platform_endianess, kOpENerEndianessBig, and kOpENerEndianessLittle.

Referenced by AssembleLinearMessage(), and EncapsulateListIdentityResponseMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

int FillNextNMessageOctetsWith ( CipOctet  value,
unsigned int  amount_of_bytes_written,
CipOctet **  message 
)

Definition at line 264 of file endianconv.c.

Referenced by FillNextNMessageOctetsWithValueAndMoveToNextPosition().

Here is the caller graph for this function:

int FillNextNMessageOctetsWithValueAndMoveToNextPosition ( CipOctet  value,
unsigned int  amount_of_filled_bytes,
CipOctet **  message 
)

Definition at line 271 of file endianconv.c.

References FillNextNMessageOctetsWith(), and MoveMessageNOctets().

Referenced by AssembleLinearMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

CipByte GetByteFromMessage ( const CipOctet **const  buffer_address)

Definition at line 36 of file endianconv.c.

int GetEndianess ( void  )

Returns global variable g_nOpENerPlatformEndianess, whereas 0 equals little endian and 1 equals big endian.

Return the endianess identified on system startup.

Returns
0 equals little endian and 1 equals big endian

Definition at line 254 of file endianconv.c.

References g_opener_platform_endianess.

CipUdint GetUdintFromMessage ( const CipOctet **const  buffer_address)

Definition at line 90 of file endianconv.c.

CipUint GetUintFromMessage ( const CipOctet **const  buffer_address)

Definition at line 64 of file endianconv.c.

CipUsint GetUsintFromMessage ( const CipOctet **const  buffer_address)

Definition at line 43 of file endianconv.c.

CipWord GetWordFromMessage ( const CipOctet **const  buffer_address)

Definition at line 71 of file endianconv.c.

int MoveMessageNOctets ( const int  amount_of_bytes_moved,
const CipOctet **  message_runner 
)

Definition at line 258 of file endianconv.c.

Referenced by CipEpathEncodeConnectionEpath(), CipEpathGetLogicalValue(), CipEpathSetLogicalValue(), ConnectionObjectInitializeFromMessage(), DetermineDelayTime(), EncapsulateListIdentityResponseMessage(), FillNextNMessageOctetsWithValueAndMoveToNextPosition(), GetElectronicKeyFormat4FromMessage(), and SkipEncapsulationHeader().

Here is the caller graph for this function:

Variable Documentation

OpenerEndianess g_opener_platform_endianess = kOpenerEndianessUnknown

Definition at line 20 of file endianconv.c.

Referenced by DetermineEndianess(), EncapsulateIpAddress(), and GetEndianess().