summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/devkit/tests/libmme/utests/src/mme_utests.c')
-rw-r--r--cleopatre/devkit/tests/libmme/utests/src/mme_utests.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c b/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
index bcdad42abb..02260e3a21 100644
--- a/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
+++ b/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
@@ -181,7 +181,7 @@ static int send_message()
{
MME_t *mh = &hdr;
int nbpkt;
- unsigned short hfmi;
+ uint fmi_nf_mi, fmi_fmsn;
unsigned int fo; /* current fragment offset */
unsigned int fs; /* current fragment size */
int i;
@@ -196,10 +196,11 @@ static int send_message()
mh = (MME_t *)frame_tx;
/* we will be sending the same num of packets as we received */
- nbpkt = ( mh->fmi & 0x0f ) + 1; /* clear out higher bits, keep only bits 0-3 */
+ fmi_nf_mi = (mh->fmi >> 4) & 0xf;
+ nbpkt = fmi_nf_mi + 1; /* clear out higher bits, keep only bits 0-3 */
/* set fragmentation info, nb of fragments */
- hfmi = nbpkt - 1;
+ fmi_fmsn = fmi_nf_mi ? 1 : 0;
/* initialize fragment offset to the begining of the payload*/
fo = thr_ctx->head;
@@ -209,13 +210,8 @@ static int send_message()
/*
* --- Set per-message fragmentation info, current fragment number ---
*/
- /* clear out higher bits, keep only bits 0-3 */
- hfmi &= 0x0f;
- /* set bits 4-7 to a new value */
- hfmi |= i << 4 ;
-
- /* We now have correct hfmi, so we can set our pkg field (in network byteorder) */
- mh->fmi = hfmi;
+ /* We now have correct fmi, so we can set our pkg field (in network byte order) */
+ mh->fmi = (fmi_fmsn << 8) | (fmi_nf_mi << 4) | i;
/*
* --- Append payload ---
@@ -332,7 +328,6 @@ static void* thread_receiver(void *unused)
uint32_t *check_frame;
int i;
#endif
- unsigned short hfmi; /* fmi in host byte order */
int rcv_len = 0;
unsigned char *pkt;
int nbpkt;
@@ -343,6 +338,7 @@ static void* thread_receiver(void *unused)
struct timeval waittime;
fd_set fds;
int res;
+ uint fmi_fn_mi, fmi_nf_mi, fmi_fmsn;
TRACE("Thread 'receiver' starting...\n");
@@ -430,8 +426,10 @@ static void* thread_receiver(void *unused)
} /* for */
/* check if the packet we received is the last one */
- hfmi = mh->fmi;
- if ( hfmi >> 4 == (hfmi & 0x0f) )
+ fmi_fmsn = mh->fmi >> 8;
+ fmi_nf_mi = (mh->fmi & 0xf0) >> 4;
+ fmi_fn_mi = mh->fmi & 0xf;
+ if (fmi_nf_mi == fmi_fn_mi)
last_pkt = 1;
/* skip the MME header */
@@ -472,18 +470,12 @@ static void* thread_receiver(void *unused)
memset(thr_buff + HEAD, 0xa, MSG_LEN/2);
memset(thr_buff + HEAD + MSG_LEN/2, 0xb, MSG_LEN/2);
- /* set the fragmentation information */
- hfmi &= 0;
-
/* calculate number of mme packets needed */
- nbpkt = (thr_ctx->tail - thr_ctx->head) / ( PKTSIZE - sizeof(MME_t) );
- if ( (thr_ctx->tail - thr_ctx->head) % ( PKTSIZE - sizeof(MME_t) ) > 0 )
- {
- nbpkt++;
- }
- /* set fragmentation info, nb of fragments */
- hfmi = nbpkt - 1;
- mh->fmi = hfmi;
+ fmi_nf_mi = (thr_ctx->tail - thr_ctx->head) / ( PKTSIZE - sizeof(MME_t));
+ fmi_fn_mi = 0;
+ fmi_fmsn = fmi_nf_mi ? 1 : 0;
+ nbpkt = fmi_nf_mi + 1;
+ mh->fmi = (fmi_fmsn << 8) | (fmi_nf_mi << 4) | fmi_fn_mi;
/* inverse the addresses */
memcpy(tmp_addr, mh->mme_dest, 6);