gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r18975 - in libmwmodem/src: main tests


From: gnunet
Subject: [GNUnet-SVN] r18975 - in libmwmodem/src: main tests
Date: Wed, 4 Jan 2012 12:12:27 +0100

Author: ruppa
Date: 2012-01-04 12:12:27 +0100 (Wed, 04 Jan 2012)
New Revision: 18975

Modified:
   libmwmodem/src/main/libmwmodem.c
   libmwmodem/src/tests/libmwmodem_test_ipv4.c
Log:


Modified: libmwmodem/src/main/libmwmodem.c
===================================================================
--- libmwmodem/src/main/libmwmodem.c    2012-01-04 10:53:27 UTC (rev 18974)
+++ libmwmodem/src/main/libmwmodem.c    2012-01-04 11:12:27 UTC (rev 18975)
@@ -135,14 +135,18 @@
 }
 
 //channel information at the udp package
-struct MWChannel {
+struct MWChannel_1Byte_fields {
   uint8_t index;
   uint8_t modcod;
   uint8_t queue;
-  uint32_t datasent;
-  uint32_t symbolratelimit;
 };
 
+
+struct MWChannel_4Byte_fields{
+         uint32_t datasent;
+         uint32_t symbolratelimit;
+};
+
 //UDP Package content
 struct MWHeader
 {
@@ -152,19 +156,18 @@
   uint8_t channelmax;
 };
 
-
 void MWMODEM_run (struct MWMODEM_Context *fc)
 {
        struct MWMODEM_Package package;
        char *ptr;
-       struct MWMODEM_Channel *list;
        struct sockaddr *from;
        struct sockaddr_in fromv4;
        struct sockaddr_in6 fromv6;
        socklen_t from_length;
        struct MWMODEM_Channel channel;
        struct MWHeader *hdr;
-       struct MWChannel *chl;
+       struct MWChannel_1Byte_fields *chl;
+       struct MWChannel_4Byte_fields *chl2;
        ssize_t rret;
        int package_length;
 
@@ -230,8 +233,8 @@
                        package.symbolrate = ntohl(hdr->symbolrate);
                        package.num_channels = (uint8_t) hdr->channelmax;
 
-                       struct MWMODEM_Channel list2[package.num_channels];
-                       list = list2;
+                       struct MWMODEM_Channel *list;
+                       list = malloc(24);
 
                        unsigned int i, currentBufferZelle;
                        currentBufferZelle = 13;
@@ -239,42 +242,50 @@
                        {
                                ptr = &buffer[currentBufferZelle];
 
-                               chl = (struct MWChannel *) ptr; // later: bus 
errors on SPARC architectures
+                               chl = (struct MWChannel_1Byte_fields *) ptr;// 
later: bus errors on SPARC architectures
 
+                               currentBufferZelle +=3;
+
+                               ptr = &buffer[currentBufferZelle];
+
+                               chl2 = (struct MWChannel_4Byte_fields *) ptr;
+
                                if(chl->index==i)
                                {
-
-                                       if(chl->modcod>MWMODEM_MOD_DUMMY
-                                                       && 
chl->modcod<MWMODEM_MOD_RESERVED)
+                                       printf("%d\n", chl->modcod);
+                                       if((chl->modcod>MWMODEM_MOD_DUMMY && 
chl->modcod<MWMODEM_MOD_RESERVED))
                                        {
-                                               channel.modcode = (uint8_t) 
chl->modcod;
+                                               channel.modcode =  chl->modcod;
                                        }
                                        else
                                        {
                                                fprintf(stderr, "Error no 
correct satellite modcode!\n");
+                                               free(list);
                                                return;
                                        }
+                                       printf("%d\n", channel.modcode);
 
                                        channel.queue = (uint8_t) chl->queue;
 
                                        if (channel.queue> 64 || channel.queue 
<0)
                                        {
                                                fprintf(stderr, "Error Frames 
out of borders!");
+                                               free(list);
                                                return;
                                        }
-                                       printf("%d\n", ntohl(chl->datasent));
-                                       channel.datasent = ntohl(chl->datasent);
+                                       //printf("%d\n", ntohl(chl2->datasent));
+                                       channel.datasent = 
ntohl(chl2->datasent);
 
-                                       channel.symbolratelimit = 
ntohl(chl->symbolratelimit);
+                                       channel.symbolratelimit = 
ntohl(chl2->symbolratelimit);
 
                                        list[i] = channel;
-
+                                       printf("%d\n", list[0].modcode);
                                        currentBufferZelle+=11;
                                }
                        }
+                       package.channel = (const struct MWMODEM_Channel *) list;
+                       free(list); printf("%d\n", package.channel[0].modcode);
                }
-       
-       package.channel =(const struct MWMODEM_Channel *) list;
 
        fc->cb(fc->cls, &package);
 

Modified: libmwmodem/src/tests/libmwmodem_test_ipv4.c
===================================================================
--- libmwmodem/src/tests/libmwmodem_test_ipv4.c 2012-01-04 10:53:27 UTC (rev 
18974)
+++ libmwmodem/src/tests/libmwmodem_test_ipv4.c 2012-01-04 11:12:27 UTC (rev 
18975)
@@ -58,28 +58,27 @@
                global_ret = 5;
                return;
        }
-
-       const struct MWMODEM_Channel *channel = &package->channel[0];
-
-       if (channel->modcode != (uint8_t)1)
+       printf("%d\n", package->channel[0].modcode);
+       if (package->channel[0].modcode != 1)
        {
                fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->modcode!\n");
                global_ret = 6;
                return;
        }
-       if (channel->queue != 11)
+       if (package->channel[0].queue != 11)
        {
                fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->queue!\n");
                global_ret = 7;
                return;
        }
-       if (channel->datasent != 10)
+//     printf("%d\n", package->channel[0].datasent);
+       if (package->channel[0].datasent != 10)
        {
                fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->datasent!\n");
                global_ret = 8;
                return;
        }
-       if (channel->symbolratelimit != 12)
+       if (package->channel[0].symbolratelimit != 12)
        {
                fprintf(stderr, "Error: failure of Test from MWMODEM_run in 
MWMODEM_InformationCallback at package->channel[0]->symbolratelimit!\n");
                global_ret = 9;
@@ -145,7 +144,6 @@
        buffer[17] = d.channel[0].datasent >> 8;
        buffer[18] = d.channel[0].datasent >> 16;
        buffer[19] = d.channel[0].datasent >> 24;
-       printf("%d\n", ntohl(d.channel[0].datasent));
        buffer[20] = d.channel[0].symbolratelimit;
        buffer[21] = d.channel[0].symbolratelimit >> 8;
        buffer[22] = d.channel[0].symbolratelimit >> 16;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]