|
@@ -38,8 +38,9 @@ static pthread_mutex_t lock_stats; //!< mutex for stats locking |
|
|
* in_addr_t to devAEM_t conversion utility function
|
|
|
* in_addr_t to devAEM_t conversion utility function
|
|
|
* @param in_addr Internet address (host byte order)
|
|
|
* @param in_addr Internet address (host byte order)
|
|
|
* @return devAEM_t representation of the address
|
|
|
* @return devAEM_t representation of the address
|
|
|
* @example
|
|
|
|
|
|
* @code{.c}
|
|
|
|
|
|
|
|
|
* @note
|
|
|
|
|
|
* for example:
|
|
|
|
|
|
* @code
|
|
|
* devAEM_t dev = addr2devAEM (ntohl(clntAddr.sin_addr.s_addr));
|
|
|
* devAEM_t dev = addr2devAEM (ntohl(clntAddr.sin_addr.s_addr));
|
|
|
* @endcode
|
|
|
* @endcode
|
|
|
*/
|
|
|
*/
|
|
@@ -51,8 +52,9 @@ devAEM_t addr2devAEM (in_addr_t in_addr) { |
|
|
* devAEM_t to in_addr_t conversion utility function
|
|
|
* devAEM_t to in_addr_t conversion utility function
|
|
|
* @param dev devAEM_t address
|
|
|
* @param dev devAEM_t address
|
|
|
* @return Internet address (host byte order)
|
|
|
* @return Internet address (host byte order)
|
|
|
* @example
|
|
|
|
|
|
* @code{.c}
|
|
|
|
|
|
|
|
|
* @note
|
|
|
|
|
|
* for example:
|
|
|
|
|
|
* @code
|
|
|
* sockaddr_in_t srvAddr;
|
|
|
* sockaddr_in_t srvAddr;
|
|
|
* srvAddr.sin_addr.s_addr = htonl (devAEM2addr (dev));
|
|
|
* srvAddr.sin_addr.s_addr = htonl (devAEM2addr (dev));
|
|
|
* @endcode
|
|
|
* @endcode
|
|
@@ -121,7 +123,7 @@ status_t log_init (void) { |
|
|
* Logs incoming messages
|
|
|
* Logs incoming messages
|
|
|
* @param msg Pointer to msg to log
|
|
|
* @param msg Pointer to msg to log
|
|
|
* @note
|
|
|
* @note
|
|
|
* This function depends on \sa settings.outLevel
|
|
|
|
|
|
|
|
|
* This function depends on settings.outLevel
|
|
|
*/
|
|
|
*/
|
|
|
void log_msg_in (msg_t* msg) {
|
|
|
void log_msg_in (msg_t* msg) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
@@ -143,7 +145,7 @@ void log_msg_in (msg_t* msg) { |
|
|
* @param msg Pointer to msg to log
|
|
|
* @param msg Pointer to msg to log
|
|
|
* @param dev device that accepts the message
|
|
|
* @param dev device that accepts the message
|
|
|
* @note
|
|
|
* @note
|
|
|
* This function depends on \sa settings.outLevel
|
|
|
|
|
|
|
|
|
* This function depends on settings.outLevel
|
|
|
*/
|
|
|
*/
|
|
|
void log_msg_out (msg_t* msg, devAEM_t dev) {
|
|
|
void log_msg_out (msg_t* msg, devAEM_t dev) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
@@ -164,7 +166,7 @@ void log_msg_out (msg_t* msg, devAEM_t dev) { |
|
|
* Logs new messages
|
|
|
* Logs new messages
|
|
|
* @param msg Pointer to msg to log
|
|
|
* @param msg Pointer to msg to log
|
|
|
* @note
|
|
|
* @note
|
|
|
* This function depends on \sa settings.outLevel
|
|
|
|
|
|
|
|
|
* This function depends on settings.outLevel
|
|
|
*/
|
|
|
*/
|
|
|
void log_msg_new (msg_t* msg) {
|
|
|
void log_msg_new (msg_t* msg) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
|
if (settings.outLevel >= OUTLEVEL_1) {
|
|
@@ -389,7 +391,7 @@ status_t devList_init (devList_t* devList) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/*!
|
|
|
/*!
|
|
|
* Returns an iterator for \sa devList AND \sa msg_t.recipients
|
|
|
|
|
|
|
|
|
* Returns an iterator for devList AND msg_t.recipients
|
|
|
* @param dev The device to search
|
|
|
* @param dev The device to search
|
|
|
* @return The iterator, namely the index to devList array in which is the \p dev
|
|
|
* @return The iterator, namely the index to devList array in which is the \p dev
|
|
|
*/
|
|
|
*/
|
|
@@ -464,27 +466,26 @@ mIter_t msgList_preInc (mIter_t* it) { |
|
|
* @return The iterator values
|
|
|
* @return The iterator values
|
|
|
*/
|
|
|
*/
|
|
|
mIter_t msgList_preDec (mIter_t* it) {
|
|
|
mIter_t msgList_preDec (mIter_t* it) {
|
|
|
if (--*it < 0) *it = MSG_LIST_SIZE;
|
|
|
|
|
|
|
|
|
if (--*it < 0) *it = MSG_LIST_SIZE-1;
|
|
|
return *it;
|
|
|
return *it;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/*!
|
|
|
/*!
|
|
|
* @param this Pointer to msgList to use
|
|
|
* @param this Pointer to msgList to use
|
|
|
* @return An iterator to the first message of \sa MSG_LIST_SIZE
|
|
|
|
|
|
|
|
|
* @return An iterator to the first message of MSG_LIST_SIZE
|
|
|
* of msgList.m[]
|
|
|
* of msgList.m[]
|
|
|
* @note
|
|
|
* @note
|
|
|
* As the msgList is a ring buffer we can not have a sensible end() iterator.
|
|
|
* As the msgList is a ring buffer we can not have a sensible end() iterator.
|
|
|
* end() will eventually merge with begin() when the size reaches \sa MSG_LIST_SIZE
|
|
|
|
|
|
|
|
|
* end() will eventually merge with begin() when the size reaches MSG_LIST_SIZE
|
|
|
* For that reason in all of our loops through msgList we shall take a begin()
|
|
|
* For that reason in all of our loops through msgList we shall take a begin()
|
|
|
* iterator and loop using size as sentinel
|
|
|
|
|
|
* @example
|
|
|
|
|
|
* @code{.c}
|
|
|
|
|
|
|
|
|
* iterator and loop using size as sentinel for example:
|
|
|
|
|
|
* @code
|
|
|
* mIter_t it = msgList_begin (&msgList); // get a message iterator
|
|
|
* mIter_t it = msgList_begin (&msgList); // get a message iterator
|
|
|
* size_t size= msgList_size(&msgList); // get current msgList size
|
|
|
* size_t size= msgList_size(&msgList); // get current msgList size
|
|
|
* for (size_t i=0 ; i<size ; ++i, msgList_preInc (&it)) { // don't forget to increase iterator
|
|
|
* for (size_t i=0 ; i<size ; ++i, msgList_preInc (&it)) { // don't forget to increase iterator
|
|
|
* // use msgList[it]
|
|
|
* // use msgList[it]
|
|
|
* }
|
|
|
* }
|
|
|
* @endcode
|
|
|
|
|
|
|
|
|
* @endcode
|
|
|
*/
|
|
|
*/
|
|
|
mIter_t msgList_begin (msgList_t* this) {
|
|
|
mIter_t msgList_begin (msgList_t* this) {
|
|
|
return this->first;
|
|
|
return this->first;
|
|
@@ -492,7 +493,7 @@ mIter_t msgList_begin (msgList_t* this) { |
|
|
|
|
|
|
|
|
/*!
|
|
|
/*!
|
|
|
* @param this Pointer to msgList to use
|
|
|
* @param this Pointer to msgList to use
|
|
|
* @return An iterator to the last inserted message of \sa MSG_LIST_SIZE
|
|
|
|
|
|
|
|
|
* @return An iterator to the last inserted message of MSG_LIST_SIZE
|
|
|
* of msgList.m[]
|
|
|
* of msgList.m[]
|
|
|
*/
|
|
|
*/
|
|
|
mIter_t msgList_last (msgList_t* this) {
|
|
|
mIter_t msgList_last (msgList_t* this) {
|
|
@@ -504,17 +505,16 @@ mIter_t msgList_last (msgList_t* this) { |
|
|
* @return The current used slots of msgList
|
|
|
* @return The current used slots of msgList
|
|
|
* @note
|
|
|
* @note
|
|
|
* As the msgList is a ring buffer we can not have a sensible end() iterator.
|
|
|
* As the msgList is a ring buffer we can not have a sensible end() iterator.
|
|
|
* end() will eventually merge with begin() when the size reaches \sa MSG_LIST_SIZE
|
|
|
|
|
|
|
|
|
* end() will eventually merge with begin() when the size reaches MSG_LIST_SIZE
|
|
|
* For that reason in all of our loops through msgList we shall take a begin()
|
|
|
* For that reason in all of our loops through msgList we shall take a begin()
|
|
|
* iterator and loop using size as sentinel
|
|
|
* iterator and loop using size as sentinel
|
|
|
* @example
|
|
|
|
|
|
* @code{.c}
|
|
|
|
|
|
|
|
|
* @code
|
|
|
* mIter_t it = msgList_begin (&msgList); // get a message iterator
|
|
|
* mIter_t it = msgList_begin (&msgList); // get a message iterator
|
|
|
* size_t size= msgList_size(&msgList); // get current msgList size
|
|
|
* size_t size= msgList_size(&msgList); // get current msgList size
|
|
|
* for (size_t i=0 ; i<size ; ++i, msgList_preInc (&it)) { // don't forget to increase iterator
|
|
|
* for (size_t i=0 ; i<size ; ++i, msgList_preInc (&it)) { // don't forget to increase iterator
|
|
|
* // use msgList[it]
|
|
|
* // use msgList[it]
|
|
|
* }
|
|
|
* }
|
|
|
* @endcode
|
|
|
|
|
|
|
|
|
* @endcode
|
|
|
*/
|
|
|
*/
|
|
|
size_t msgList_size (msgList_t* this) {
|
|
|
size_t msgList_size (msgList_t* this) {
|
|
|
return this->size;
|
|
|
return this->size;
|
|
@@ -574,7 +574,7 @@ void msgList_release () { pthread_mutex_unlock (&lock_msgList); } |
|
|
|
|
|
|
|
|
/*!
|
|
|
/*!
|
|
|
* Initialize statistics
|
|
|
* Initialize statistics
|
|
|
* @param s Pointer to \sa stat_t struct to initialize
|
|
|
|
|
|
|
|
|
* @param s Pointer to stat_t struct to initialize
|
|
|
* @return The status of the operation
|
|
|
* @return The status of the operation
|
|
|
*/
|
|
|
*/
|
|
|
status_t stats_init (stats_t* s) {
|
|
|
status_t stats_init (stats_t* s) {
|
|
|