/*====================================================================*
*
* void ARPCPrint (FILE *fp, void const * memory, size_t extent);
*
* mme.h
*
* print formatted VS_ARPC payload on the specified output stream;
* this implementation is generic; memory is the start address of
* the message data (&RDATA [RDATAOFFSET]) and extent is the data
* length (RDATALENGTH); the call might look like this ...
*
* ARPCPrint (fp, &ARPC->RDATA [ARPC->RDATAOFFSET], LE16TOH (ARPC->RDATALENGTH));
*
* ... where LE16TOH () performs host endian conversion;
*
* This software and documentation is the property of Atheros
* Corporation, Ocala, Florida. It is provided 'as is' without
* expressed or implied warranty of any kind to anyone for any
* reason. Atheros assumes no responsibility or liability for
* errors or omissions in the software or documentation and
* reserves the right to make changes without notification.
*
* Atheros customers may modify and distribute the software
* without obligation to Atheros. Since use of this software
* is optional, users shall bear sole responsibility and
* liability for any consequences of it's use.
*
*. Atheros Powerline Toolkit for HomePlug AV;
*: Published 2007 by Intellon Corp. ALL RIGHTS RESERVED;
*; For demonstration; Not for production use;
*
* Contributor(s):
* Charles Maier <charles.maier@atheros.com>
*
*--------------------------------------------------------------------*/
#ifndef ARPCPRINT_SOURCE
#define ARPCPRINT_SOURCE
#include <stdio.h>
#include "../tools/types.h"
#include "../tools/endian.h"
void ARPCPrint (FILE *fp, void const * memory, size_t extent)
{
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_arpc_data
{
uint32_t BYPASS;
uint16_t ARPCID;
uint16_t DATALENGTH;
uint8_t DATAOFFSET;
uint8_t RESERVED [3];
uint16_t ARGOFFSET;
uint16_t STROFFSET;
uint16_t ARGLENGTH;
uint16_t STRLENGTH;
uint8_t LIST [1];
}
* data = (struct vs_arpc_data *)(memory);
#ifndef __GNUC__
#pragma pack (pop)
#endif
#if 0
fprintf (fp, "BYPASS=%d ", data->BYPASS);
fprintf (fp, "ARPCID=%d ", data->ARPCID);
fprintf (fp, "DATALENGTH=%d ", LE16TOH (data->DATALENGTH));
fprintf (fp, "DATAOFFSET=%d ", data->DATAOFFSET);
fprintf (fp, "ARGOFFSET=%d ", LE16TOH (data->ARGOFFSET));
fprintf (fp, "STROFFSET=%d ", LE16TOH (data->STROFFSET));
fprintf (fp, "ARGLENGTH=%d ", LE16TOH (data->ARGLENGTH));
fprintf (fp, "STRLENGTH=%d ", LE16TOH (data->STRLENGTH));
fprintf (fp, "FORMAT=[%s]\n", &data->LIST [LE16TOH (data->STROFFSET)]);
#endif
vfprintf (fp, (char *)(&data->LIST [LE16TOH (data->STROFFSET)]), (void *)(&data->LIST [LE16TOH (data->ARGOFFSET)]));
fprintf (fp, "\n");
return;
}
/*====================================================================*
* test/demo program (for little-endian hosts);
*--------------------------------------------------------------------*/
#if 0
int main (int argc, const char * argv [])
{
#ifndef __GNUC__
#pragma pack (push,1)
#endif
struct __packed vs_arpc_data
{
uint32_t BYPASS;
uint16_t ARPCID;
uint16_t DATALENGTH;
uint8_t DATAOFFSET;
uint8_t RESERVED [3];
uint16_t ARGOFFSET;
uint16_t STROFFSET;
uint16_t ARGLENGTH;
uint16_t STRLENGTH;
uint8_t LIST [100];
}
data =
{
(uint32_t)(0),
(uint16_t)(0xA5A5),
(uint16_t)(29),
(uint8_t) (0),
{
0,
0,
0
},
(uint16_t)(21),
(uint16_t)(0),
(uint16_t)(8),
(uint16_t)(21),
{
'H',
'e',
'l',
'l',
'o',
' ',
'W',
'o',
'l',
'r',
'd',
'!',
' ',
'%',
'd',
' ',
'%',
'0',
'8',
'X',
'\0',
1,
0,
0,
0,
2,
0,
0,
0,
},
};
#ifndef __GNUC__
#pragma pack (pop)
#endif
ARPCPrint (stdout, &data, sizeof (data));
return (0);
}
#endif
/*====================================================================*
*
*--------------------------------------------------------------------*/
#endif