2014-07-07 07:53:42 +00:00
|
|
|
/** Message related functions
|
2014-06-05 09:34:29 +00:00
|
|
|
*
|
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2014, Institute for Automation of Complex Power Systems, EONERC
|
2014-06-28 06:40:52 +00:00
|
|
|
* @file
|
2014-06-05 09:34:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MSG_H_
|
|
|
|
#define _MSG_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2014-07-07 07:53:42 +00:00
|
|
|
#include "msg_format.h"
|
2014-07-04 15:58:11 +00:00
|
|
|
|
|
|
|
struct node;
|
|
|
|
|
2014-07-18 16:05:49 +00:00
|
|
|
/** Swap a message to host byte order.
|
|
|
|
*
|
|
|
|
* Message can either be transmitted in little or big endian
|
|
|
|
* format. The actual endianess for a message is defined by the
|
|
|
|
* msg::byteorder field.
|
|
|
|
* Received message are usally converted to the endianess of the host.
|
|
|
|
* This is required for further sanity checks of the sequence number
|
|
|
|
* or parsing of the data.
|
|
|
|
*
|
|
|
|
* @param m A pointer to the message
|
|
|
|
*/
|
|
|
|
void msg_swap(struct msg *m);
|
|
|
|
|
2014-06-05 09:35:32 +00:00
|
|
|
/** Print a raw UDP message in human readable form.
|
2014-06-05 09:34:53 +00:00
|
|
|
*
|
|
|
|
* @param f The file stream
|
2014-08-31 14:43:28 +00:00
|
|
|
* @param m A pointer to the message
|
2014-12-05 12:26:47 +01:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-05 09:34:53 +00:00
|
|
|
*/
|
|
|
|
int msg_fprint(FILE *f, struct msg *m);
|
|
|
|
|
2014-06-05 09:35:32 +00:00
|
|
|
/** Read a message from a file stream.
|
2014-06-05 09:34:53 +00:00
|
|
|
*
|
|
|
|
* @param f The file stream
|
|
|
|
* @param m A pointer to the message
|
2014-12-05 12:26:47 +01:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-05 09:34:53 +00:00
|
|
|
*/
|
|
|
|
int msg_fscan(FILE *f, struct msg *m);
|
2014-06-05 09:34:29 +00:00
|
|
|
|
2014-06-05 09:35:32 +00:00
|
|
|
/** Change the values of an existing message in a random fashion.
|
2014-06-05 09:34:29 +00:00
|
|
|
*
|
2014-06-05 09:35:32 +00:00
|
|
|
* @param m A pointer to the message whose values will be updated
|
2014-06-05 09:34:29 +00:00
|
|
|
*/
|
2014-06-05 09:34:53 +00:00
|
|
|
void msg_random(struct msg *m);
|
2014-06-05 09:34:29 +00:00
|
|
|
|
|
|
|
#endif /* _MSG_H_ */
|