crc creating error and aborting compilation

Asked by Ashok Kumar on 2014-10-09

Hi Didier,
                     After a long time I am back again working in ROHC module, but today when I compiled my code that include rohc library seems to show an error which was not there when I compiled lastly few months before. Could you please help me to sort out this problem??

My command window output looks like the following:

 bcg@BCGA53:~/Ashok_Kumar/ROHC_Codes/ROHC-1.6.1/Compressed/rohc-1.6.1$ cd lib/
bcg@BCGA53:~/Ashok_Kumar/ROHC_Codes/ROHC-1.6.1/Compressed/rohc-1.6.1/lib$ sudo gcc -o rohctest $(pkg-config rohc --cflags) rohctest.c $(pkg-config rohc --libs)
bcg@BCGA53:~/Ashok_Kumar/ROHC_Codes/ROHC-1.6.1/Compressed/rohc-1.6.1/lib$ ./rohctest
This program will compress one single IPv4 packet
create the ROHC compressor
please define a callback for compressor traces
[rohc_comp.c:1102 rohc_comp_set_wlsb_window_width()] width of W-LSB sliding window set to 4
[rohc_comp.c:1159 rohc_comp_set_periodic_refreshes()] IR timeout for context periodic refreshes set to 1700
[rohc_comp.c:1161 rohc_comp_set_periodic_refreshes()] FO timeout for context periodic refreshes set to 700
[rohc_comp.c:1585 rohc_comp_add_rtp_port()] port 1234 added to the UDP port list for RTP traffic
[rohc_comp.c:1585 rohc_comp_add_rtp_port()] port 36780 added to the UDP port list for RTP traffic
[rohc_comp.c:1585 rohc_comp_add_rtp_port()] port 33238 added to the UDP port list for RTP traffic
[rohc_comp.c:1585 rohc_comp_add_rtp_port()] port 5020 added to the UDP port list for RTP traffic
[rohc_comp.c:1585 rohc_comp_add_rtp_port()] port 5002 added to the UDP port list for RTP traffic
rohctest: crc.c:980: rohc_crc_get_polynom: Assertion `0' failed.
Aborted
bcg@BCGA53:~/Ashok_Kumar/ROHC_Codes/ROHC-1.6.1/Compressed/rohc-1.6.1/lib$

Question information

Language:
English Edit question
Status:
Solved
For:
rohc Edit question
Assignee:
No assignee Edit question
Solved by:
Ashok Kumar
Solved:
2014-12-09
Last query:
2014-12-09
Last reply:
2014-12-03
Ashok Kumar (ashokkm-9) said : #1

The associated app such as sniffer and simple_rohc_program compiled during build seems to work without any error. But any new code of using rohc library creating this assertion error. What needs to be done in order to rectify?? Any valuable suggestion..

Launchpad Janitor (janitor) said : #2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Hello,

What version of the ROHC library to you use? Is it 1.6.1 as shown in the paths?

Do you call the rohc_crc_get_polynom() function directly in your code? If yes, what is the value of the first parameter?

Regards,
Didier

Ashok Kumar (ashokkm-9) said : #4

Hi Didier,

I am using the same 1.6.1 library only as you mentioned. I tried to compile the program "simple_rohc_program.c" which was already there in lib folder of rohc-1.6.1 which resulted in this error. i didnt used any rohc_crc_get_polynom( ) in my code.

Hi,

I have just compiled the simple_rohc_program. It works fine. Please copy/paste the
code from the file "rohctest.c" on http://pastebin.com/ so I can look at it.

In addition, could you please test with the latest version 1.7.0 as follow:
$ wget http://rohc-lib.org/download/rohc-1.7.x/1.7.0/rohc-1.7.0.tar.xz
$ tar -xJf rohc-1.7.0.tar.xz
$ cd rohc-1.7.0/
$ ./configure --enable-examples
$ make all
$ ./examples/simple_rohc_program

Regards,
Didier

Ashok Kumar (ashokkm-9) said : #6

Hi,
      I already mentioned that(second comment on 2014-10-15) during the initial build, simple_rohc_program.o file is created for simple_rohc_program.c and seems to execute successfully .But, when I modify the program simple_rohc_program.c or when I try to use the library for my own program using the command "gcc -o mytest $(pkg-config rohc --cflags) mytest.c $(pkg-config --libs)" its creating that error.

Ashok Kumar (ashokkm-9) said : #7

Hi,
     My program code "mytest.c" is given below:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<netinet/if_ether.h>
#include<net/ethernet.h>
#include<netinet/ip.h>
#include<netinet/udp.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<rohc.h>
#include<rohc_comp.h>
#include<rohc_decomp.h>
#define BUFFER_SIZE 2048

void PrintData(unsigned char* ,int);
static int gen_random_num(const struct rohc_comp *const comp, void *const user_context);

int raw_sock,i,j;
FILE *logfile;
struct sockaddr_in source,dest;

int main(int argc, char **argv)
{
 int saddr_size, data_size;
 struct sockaddr saddr;
 struct in_addr in;
 struct rohc_comp *compressor;
 struct rohc_decomp *decompressor;
 unsigned short iphdrlen;
 unsigned int ip_packet_len, rohc_packet_len;
 unsigned char BUFFER[BUFFER_SIZE], rohc_packet[BUFFER_SIZE], op_packet[BUFFER_SIZE];
 int ret;

 printf("\n Creating ROHC compressor......\n\n");
 compressor = rohc_alloc_compressor(15,0,0,0);
 if(compressor == NULL)
  {
   fprintf(stderr,"\n Failed creating compressor!!\n");
   rohc_free_compressor(compressor);
  }

   if(!rohc_comp_set_random_cb(compressor, gen_random_num, NULL))
   {
    fprintf(stderr, "\n Failed to set the compressor callback random numbers!!\n");
    rohc_free_compressor(compressor);
   }

 printf("\n Enabling the profile");
 rohc_activate_profile(compressor, ROHC_PROFILE_UNCOMPRESSED);
 rohc_activate_profile(compressor, ROHC_PROFILE_UDP);
 rohc_activate_profile(compressor, ROHC_PROFILE_IP);

 printf("\n Creating ROHC Decompressor.....");
  decompressor=rohc_alloc_decompressor(compressor);
  if(decompressor == NULL)
  {
   fprintf(stderr,"\n Failed creating decompressor!!\n");
   rohc_free_decompressor(decompressor);
  }

   if(!rohc_decomp_set_traces_cb(decompressor, NULL))
   {
    fprintf(stderr,"\n Failed to set callback traces for decompressor!!");
    rohc_free_decompressor(decompressor);
   }

 logfile=fopen("log.txt","w");
 if(logfile == NULL) printf("\n Unable to create file");

 raw_sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);

 if(raw_sock < 0)
 {
  printf("\n Socket error; try with sudo");
  return 1;
 }
 while(1)
 {
  saddr_size = sizeof(saddr);
  data_size = recvfrom(raw_sock, BUFFER, BUFFER_SIZE, 0, &saddr, &saddr_size);
  if(data_size < 0)
  {
   printf("\n Error of recvfrom(), failed to get packets");
   return 1;
  }

  struct iphdr *iph = (struct iphdr*)BUFFER;
  iphdrlen = iph->ihl*4;
  memset(&source, 0, sizeof(source));
     source.sin_addr.s_addr = iph->saddr;
  memset(&dest, 0, sizeof(dest));
     dest.sin_addr.s_addr = iph->daddr;

  fprintf(logfile,"\n###########################################################");
  fprintf(logfile,"\n***********************IP*************************\n");
  fprintf(logfile,"\nIP Header\n");
  fprintf(logfile," |-IP Version : %d\n",(unsigned int)iph->version);
  fprintf(logfile," |-IP Header Length : %d DWORDS or %d Bytes\n",(unsigned int)iph->ihl,((unsigned int)(iph->ihl))*4);
  fprintf(logfile," |-Type Of Service : %d\n",(unsigned int)iph->tos);
  fprintf(logfile," |-IP Total Length : %d Bytes(Size of Packet)\n",ntohs(iph->tot_len));
  fprintf(logfile," |-Identification : %d\n",ntohs(iph->id));
  fprintf(logfile," |-TTL : %d\n",(unsigned int)iph->ttl);
  fprintf(logfile," |-Protocol : %d\n",(unsigned int)iph->protocol);
  fprintf(logfile," |-Checksum : %d\n",ntohs(iph->check));
  fprintf(logfile," |-Source IP : %s\n",inet_ntoa(source.sin_addr));
  fprintf(logfile," |-Destination IP : %s\n",inet_ntoa(dest.sin_addr));

  struct udphdr *udph = (struct udphdr*)(BUFFER + iphdrlen);

  fprintf(logfile,"\n\n***********************UDP*************************\n");

  fprintf(logfile,"\nUDP Header\n");
  fprintf(logfile," |-Source Port : %d\n" , ntohs(udph->source));
  fprintf(logfile," |-Destination Port : %d\n" , ntohs(udph->dest));
  fprintf(logfile," |-UDP Length : %d\n" , ntohs(udph->len));
  fprintf(logfile," |-UDP Checksum : %d\n" , ntohs(udph->check));

  fprintf(logfile,"\n************************************************************\n");

  fprintf(logfile,"\n");
  fprintf(logfile,"IP Header\n");
  PrintData(BUFFER , iphdrlen);

  fprintf(logfile,"UDP Header\n");
  PrintData(BUFFER+iphdrlen , sizeof udph);

  fprintf(logfile,"Data Payload\n");
  PrintData(BUFFER + iphdrlen + sizeof udph ,( data_size - sizeof udph - iph->ihl * 4 ));

  fprintf(logfile,"\n###########################################################");

  printf("\n Compressing the UDP/IP packet...\n\n");

  ret=rohc_compress2(compressor,BUFFER,data_size,rohc_packet, BUFFER_SIZE, &rohc_packet_len);

  if(ret!=ROHC_OK)
  {
   fprintf(stderr, "Compression of IP packet failed\n");
   rohc_free_compressor(compressor);
   return 1;
  }

  printf("\n ROHC packet after compression:\n");
  for(i = 0; i < ((unsigned int) rohc_packet_len); i++)
     {
     printf("0x%02x ", rohc_packet[i]);
     if(i != 0 && ((i + 1) % 8) == 0)
     {
        printf("\n");
     }
     }

  printf("\n\n Total number of bytes:%d", i);

     if(i != 0 && (i % 8) != 0)
     {
     printf("\n");
     }

  printf("\n Decompressing the UDP/IP packet....\n");
  ret=rohc_decompress(decompressor,rohc_packet,rohc_packet_len,op_packet,BUFFER_SIZE);
  if(ret <= 0)
  {
   fprintf(stderr, "Decompression failed\n");
   rohc_free_decompressor(decompressor);
  }

  printf("\n IP packet after Decompression:\n\n");
  for(i = 0; i < ((unsigned int) ret); i++)
     {
     printf("0x%02x ", op_packet[i]);
     if(i != 0 && ((i + 1) % 8) == 0)
     {
        printf("\n");
     }
     }

  printf("\n\n Total number of bytes:%d", i);

     if(i != 0 && (i % 8) != 0)
     {
     printf("\n");
     }

 }
 close(raw_sock);
 printf("\n Finished");

 printf("\n Destroy the Compressor and Decompressor");
 rohc_free_compressor(compressor);
 rohc_free_decompressor(decompressor);
 return 0;
}

static int gen_random_num(const struct rohc_comp *const comp,void *const user_context)
{
 return rand();
}

void PrintData (unsigned char* data , int Size)
{

    for(i=0 ; i < Size ; i++)
    {
        if( i!=0 && i%16==0)
        {
            fprintf(logfile," ");
            for(j=i-16 ; j<i ; j++)
            {
                if(data[j]>=32 && data[j]<=128)
                    fprintf(logfile,"%c",(unsigned char)data[j]);

                else fprintf(logfile,".");
            }
            fprintf(logfile,"\n");
        }

        if(i%16==0) fprintf(logfile," ");
            fprintf(logfile," %02X",(unsigned int)data[i]);

        if( i==Size-1)
        {
            for(j=0;j<15-i%16;j++) fprintf(logfile," ");

            fprintf(logfile," ");

            for(j=i-i%16 ; j<=i ; j++)
            {
                if(data[j]>=32 && data[j]<=128) fprintf(logfile,"%c",(unsigned char)data[j]);
                else fprintf(logfile,".");
            }
            fprintf(logfile,"\n");
        }
    }
}

Hello,

Your program builds and works fine with both library 1.6.1 and 1.7.0. Building it emits many deprecation warnings, but it builds nevertheless.

My best hypothesis is that you have an old version of the ROHC library installed on your system. Please run the following commands to try to discover it:
$ pkg-config rohc --modversion
$ ls -l /usr/lib/librohc*
$ ls -l /usr/lib64/librohc*
$ ls -l /usr/local/lib/librohc*
$ ls -l /usr/local/lib64/librohc*
$ ls -l /usr/include/rohc*
$ ls -l /usr/local/include/rohc*

Regards,
Didier

Ashok Kumar (ashokkm-9) said : #9

Hi Didier,

This what I get,

bcg@BCGA53:~$ pkg-config rohc --modversion
1.7.0
bcg@BCGA53:~$ ls -l /usr/lib/librohc*
-rwxr-xr-x 1 root root 944 2014-10-13 11:26 /usr/lib/librohc_common.la
lrwxrwxrwx 1 root root 23 2014-10-13 11:26 /usr/lib/librohc_common.so -> librohc_common.so.0.2.0
lrwxrwxrwx 1 root root 23 2014-10-13 11:26 /usr/lib/librohc_common.so.0 -> librohc_common.so.0.2.0
-rwxr-xr-x 1 root root 123698 2014-03-28 10:46 /usr/lib/librohc_common.so.0.1.0
-rwxr-xr-x 1 root root 97788 2014-10-13 11:26 /usr/lib/librohc_common.so.0.2.0
-rwxr-xr-x 1 root root 984 2014-10-13 11:26 /usr/lib/librohc_comp.la
lrwxrwxrwx 1 root root 21 2014-10-13 11:26 /usr/lib/librohc_comp.so -> librohc_comp.so.0.2.0
lrwxrwxrwx 1 root root 21 2014-10-13 11:26 /usr/lib/librohc_comp.so.0 -> librohc_comp.so.0.2.0
-rwxr-xr-x 1 root root 343950 2014-03-28 10:46 /usr/lib/librohc_comp.so.0.1.0
-rwxr-xr-x 1 root root 777954 2014-10-13 11:26 /usr/lib/librohc_comp.so.0.2.0
-rwxr-xr-x 1 root root 1044 2014-10-13 11:26 /usr/lib/librohc_decomp.la
lrwxrwxrwx 1 root root 23 2014-10-13 11:26 /usr/lib/librohc_decomp.so -> librohc_decomp.so.0.2.0
lrwxrwxrwx 1 root root 23 2014-10-13 11:26 /usr/lib/librohc_decomp.so.0 -> librohc_decomp.so.0.2.0
-rwxr-xr-x 1 root root 350341 2014-03-28 10:46 /usr/lib/librohc_decomp.so.0.1.0
-rwxr-xr-x 1 root root 780617 2014-10-13 11:26 /usr/lib/librohc_decomp.so.0.2.0
-rwxr-xr-x 1 root root 1081 2014-10-13 11:26 /usr/lib/librohc.la
lrwxrwxrwx 1 root root 16 2014-10-13 11:26 /usr/lib/librohc.so -> librohc.so.0.2.0
lrwxrwxrwx 1 root root 16 2014-10-13 11:26 /usr/lib/librohc.so.0 -> librohc.so.0.2.0
-rwxr-xr-x 1 root root 6592 2014-10-13 11:26 /usr/lib/librohc.so.0.2.0
bcg@BCGA53:~$ ls -l /usr/lib64/librohc*
ls: cannot access /usr/lib64/librohc*: No such file or directory
bcg@BCGA53:~$ sudo ls -l /usr/lib64/librohc*
[sudo] password for bcg:
ls: cannot access /usr/lib64/librohc*: No such file or directory
bcg@BCGA53:~$ ls -l /usr/local/lib/librohc*
-rwxr-xr-x 1 root root 950 2014-12-01 09:44 /usr/local/lib/librohc_common.la
lrwxrwxrwx 1 root root 23 2014-12-01 09:44 /usr/local/lib/librohc_common.so -> librohc_common.so.0.2.0
lrwxrwxrwx 1 root root 23 2014-12-01 09:44 /usr/local/lib/librohc_common.so.0 -> librohc_common.so.0.2.0
-rwxr-xr-x 1 root root 115279 2014-10-09 15:11 /usr/local/lib/librohc_common.so.0.0.0
-rwxr-xr-x 1 root root 121992 2014-10-13 12:34 /usr/local/lib/librohc_common.so.0.1.0
-rwxr-xr-x 1 root root 97780 2014-12-01 09:44 /usr/local/lib/librohc_common.so.0.2.0
-rwxr-xr-x 1 root root 996 2014-12-01 09:44 /usr/local/lib/librohc_comp.la
lrwxrwxrwx 1 root root 21 2014-12-01 09:44 /usr/local/lib/librohc_comp.so -> librohc_comp.so.0.2.0
lrwxrwxrwx 1 root root 21 2014-12-01 09:44 /usr/local/lib/librohc_comp.so.0 -> librohc_comp.so.0.2.0
-rwxr-xr-x 1 root root 325082 2014-10-09 15:11 /usr/local/lib/librohc_comp.so.0.0.0
-rwxr-xr-x 1 root root 401561 2014-10-13 12:34 /usr/local/lib/librohc_comp.so.0.1.0
-rwxr-xr-x 1 root root 777946 2014-12-01 09:44 /usr/local/lib/librohc_comp.so.0.2.0
-rwxr-xr-x 1 root root 1062 2014-12-01 09:44 /usr/local/lib/librohc_decomp.la
lrwxrwxrwx 1 root root 23 2014-12-01 09:44 /usr/local/lib/librohc_decomp.so -> librohc_decomp.so.0.2.0
lrwxrwxrwx 1 root root 23 2014-12-01 09:44 /usr/local/lib/librohc_decomp.so.0 -> librohc_decomp.so.0.2.0
-rwxr-xr-x 1 root root 315887 2014-10-09 15:11 /usr/local/lib/librohc_decomp.so.0.0.0
-rwxr-xr-x 1 root root 374059 2014-10-13 12:34 /usr/local/lib/librohc_decomp.so.0.1.0
-rwxr-xr-x 1 root root 780609 2014-12-01 09:44 /usr/local/lib/librohc_decomp.so.0.2.0
-rwxr-xr-x 1 root root 1117 2014-12-01 09:44 /usr/local/lib/librohc.la
lrwxrwxrwx 1 root root 16 2014-12-01 09:44 /usr/local/lib/librohc.so -> librohc.so.0.2.0
lrwxrwxrwx 1 root root 16 2014-12-01 09:44 /usr/local/lib/librohc.so.0 -> librohc.so.0.2.0
-rwxr-xr-x 1 root root 6592 2014-12-01 09:44 /usr/local/lib/librohc.so.0.2.0
bcg@BCGA53:~$ ls -l /usr/local/lib64/librohc*
ls: cannot access /usr/local/lib64/librohc*: No such file or directory
bcg@BCGA53:~$ sudo ls -l /usr/local/lib64/librohc*
ls: cannot access /usr/local/lib64/librohc*: No such file or directory
bcg@BCGA53:~$ ls -l /usr/include/rohc*
-rw-r--r-- 1 root root 1304 2014-10-13 11:26 /usr/include/rohc_comp.h
-rw-r--r-- 1 root root 1318 2014-10-13 11:26 /usr/include/rohc_decomp.h
-rw-r--r-- 1 root root 1279 2014-10-13 11:26 /usr/include/rohc.h
-rw-r--r-- 1 root root 1335 2014-10-13 11:26 /usr/include/rohc_packets.h
-rw-r--r-- 1 root root 1328 2014-10-13 11:26 /usr/include/rohc_traces.h

/usr/include/rohc:
total 88
-rw-r--r-- 1 root root 6964 2014-10-13 11:26 rohc_buf.h
-rw-r--r-- 1 root root 28164 2014-10-13 11:26 rohc_comp.h
-rw-r--r-- 1 root root 16658 2014-10-13 11:26 rohc_decomp.h
-rw-r--r-- 1 root root 12102 2014-10-13 11:26 rohc.h
-rw-r--r-- 1 root root 6375 2014-10-13 11:26 rohc_packets.h
-rw-r--r-- 1 root root 1715 2014-10-13 11:26 rohc_time.h
-rw-r--r-- 1 root root 6632 2014-10-13 11:26 rohc_traces.h
bcg@BCGA53:~$ ls -l /usr/local/include/rohc*
-rw-r--r-- 1 root root 1304 2014-12-01 09:44 /usr/local/include/rohc_comp.h
-rw-r--r-- 1 root root 1318 2014-12-01 09:44 /usr/local/include/rohc_decomp.h
-rw-r--r-- 1 root root 1279 2014-12-01 09:44 /usr/local/include/rohc.h
-rw-r--r-- 1 root root 1335 2014-12-01 09:44 /usr/local/include/rohc_packets.h
-rw-r--r-- 1 root root 1328 2014-12-01 09:44 /usr/local/include/rohc_traces.h

/usr/local/include/rohc:
total 88
-rw-r--r-- 1 root root 6964 2014-12-01 09:44 rohc_buf.h
-rw-r--r-- 1 root root 28164 2014-12-01 09:44 rohc_comp.h
-rw-r--r-- 1 root root 16658 2014-12-01 09:44 rohc_decomp.h
-rw-r--r-- 1 root root 12102 2014-12-01 09:44 rohc.h
-rw-r--r-- 1 root root 6375 2014-12-01 09:44 rohc_packets.h
-rw-r--r-- 1 root root 1715 2014-12-01 09:44 rohc_time.h
-rw-r--r-- 1 root root 6632 2014-12-01 09:44 rohc_traces.h
bcg@BCGA53:~$

Hello,

You have 2 instances of the ROHC library installed. The best thing to do is removing both of them, then re-install the latest (1.7.0 version).

Remove instance from /usr (run commands as root or with sudo)
$ rm -rf /usr/lib/librohc*
$ rm -rf /usr/include/rohc*
$ rm -rf /usr/lib/pkgconfig/rohc.pc

Remove instance from /usr/local (run commands as root or with sudo)
$ rm -rf /usr/local/lib/librohc*
$ rm -rf /usr/local/include/rohc*
$ rm -rf /usr/local/lib/pkgconfig/rohc.pc

Then, install version 1.7.0:
$ wget http://rohc-lib.org/download/rohc-1.7.x/1.7.0/rohc-1.7.0.tar.xz
$ tar -xJf rohc-1.7.0.tar.xz
$ cd rohc-1.7.0/
$ ./configure --enable-examples --prefix=/usr
$ make all
$ make install

Finally, try again to build your program.

Regards,
Didier

Ashok Kumar (ashokkm-9) said : #11

Hi,
      Thanks Didier, it worked....