GNS3 – Problems Compiling IOUYAP

Posted on Leave a commentPosted in C++, Fedora, Linux, Networks

Following the series of posts over recent months relating to the installation of GNS3; 1) Installing GNS3 on Fedora, CentOS and RHEL and 2) GNS3 Installation on Fedora 22 I have decided to put together a complete guide from start to finish chronicling my every step to ensure my GNS3 installation is correct and fully working.

It is at this point that I feel that I should not just share the normal story of “everything went fine… what problems?? I didn’t have a single issue installing the software!!!”  Well, for the most part I could have got away with a statement like that.  Unfortunately though when I reached the point of installing iouyap, things didn’t go quite as smoothly as one would hope.

As per my previous guides and the instructions that ship with iouyap (version 0.95) I ran the following;

$ bison --yacc -dv netmap_parse.y
$ flex netmap_scan.l
$ gcc -Wall -g *.c -o iouyap -liniparser -lpthread

I was the confronted with a wall of potential errors, and not knowing exactly what they meant, I thought it best to investigate…  The output from the last command line above was;

[toby@thebay iouyap-0.95]$ sudo gcc -Wall -g *.c -o iouyap -liniparser -lpthread
In file included from iouyap.c:49:0:
iouyap.c: In function ‘foreign_listener’:
iouyap.c:420:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t {aka long int}’ [-Wformat=]
debug_log_fmt ("received %d bytes (sfd=%d)\n",
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.h:128:5: note: in expansion of macro ‘STMT’
STMT( log_prefix(); fprintf(stderr, fmt, ## __VA_ARGS__); )
^
iouyap.h:138:26: note: in expansion of macro ‘log_fmt’
STMT( if (DEBUG_LOG) log_fmt(fmt, ## __VA_ARGS__); )
^
iouyap.c:420:9: note: in expansion of macro ‘debug_log_fmt’
debug_log_fmt ("received %d bytes (sfd=%d)\n",
^
iouyap.c:458:28: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t {aka long int}’ [-Wformat=]
log_fmt ("sendto() only sent %d of %d bytes!"
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.c:458:19: note: in expansion of macro ‘log_fmt’
log_fmt ("sendto() only sent %d of %d bytes!"
^
iouyap.c:458:28: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘ssize_t {aka long int}’ [-Wformat=]
log_fmt ("sendto() only sent %d of %d bytes!"
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.c:458:19: note: in expansion of macro ‘log_fmt’
log_fmt ("sendto() only sent %d of %d bytes!"
^
iouyap.c: In function ‘iou_listener’:
iouyap.c:536:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t {aka long int}’ [-Wformat=]
debug_log_fmt ("received %d bytes for port %d (sfd=%d)\n",
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.h:128:5: note: in expansion of macro ‘STMT’
STMT( log_prefix(); fprintf(stderr, fmt, ## __VA_ARGS__); )
^
iouyap.h:138:26: note: in expansion of macro ‘log_fmt’
STMT( if (DEBUG_LOG) log_fmt(fmt, ## __VA_ARGS__); )
^
iouyap.c:536:9: note: in expansion of macro ‘debug_log_fmt’
debug_log_fmt ("received %d bytes for port %d (sfd=%d)\n",
^
iouyap.c:563:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t {aka long int}’ [-Wformat=]
log_fmt ("write() only sent %d of %d bytes! (sfd=%d)\n",
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.c:563:15: note: in expansion of macro ‘log_fmt’
log_fmt ("write() only sent %d of %d bytes! (sfd=%d)\n",
^
iouyap.c:563:24: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘ssize_t {aka long int}’ [-Wformat=]
log_fmt ("write() only sent %d of %d bytes! (sfd=%d)\n",
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
iouyap.c:563:15: note: in expansion of macro ‘log_fmt’
log_fmt ("write() only sent %d of %d bytes! (sfd=%d)\n",
^
In file included from netmap.c:34:0:
netmap.c: In function ‘dump_port_table’:
netmap.c:372:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
log_fmt ("%d:%d/%d talks to %d other node(s):\n", yap_appl_id,
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
netmap.c:372:7: note: in expansion of macro ‘log_fmt’
log_fmt ("%d:%d/%d talks to %d other node(s):\n", yap_appl_id,
^

After some monkeying about, I reduced these errors to;

In file included from netmap.c:34:0:
netmap.c: In function ‘dump_port_table’:
netmap.c:372:16: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
log_fmt ("%d:%d/%d talks to %d other node(s):\n", yap_appl_id,
^
iouyap.h:103:28: note: in definition of macro ‘STMT’
#define STMT( code )  do { code } while (0)
^
netmap.c:372:7: note: in expansion of macro ‘log_fmt’
log_fmt ("%d:%d/%d talks to %d other node(s):\n", yap_appl_id,
^

the diff output is as follows;

diff iouyap.c ../../iouyap-0.95_original/iouyap-0.95/iouyap.c
383,384c383
<   /* ssize_t bytes_received, bytes_sent; */
<   int bytes_received, bytes_sent; --- >   ssize_t bytes_received, bytes_sent;
503,504c502
<   /* ssize_t bytes_received, bytes_sent; */
<   int bytes_received, bytes_sent; --- >   ssize_t bytes_received, bytes_sent;

Now I’m no C++ developer, not even close, and the last thing to resolve in netmap.c just didn’t make sense. So I paid the gns3 website a visit, and magically less than 24 hours after I had downloaded the 1.3.8 version there was a new release… 1.3.9.

Sadly the IOUYAP package there also contained the issue, in the end I resorted to good old fashioned tactics… I got hold of the source code from github and the issues I was facing were fixed in the version I checked out.  You can see the results below;

[toby@thebay GNS3-1.3.9]$ git clone https://github.com/GNS3/iouyap.git
Cloning into 'iouyap'...
remote: Counting objects: 78, done.
remote: Total 78 (delta 0), reused 0 (delta 0), pack-reused 78
Unpacking objects: 100% (78/78), done.
Checking connectivity... done.
[toby@thebay GNS3-1.3.9]$ ls
dynamips-0.2.14      gns3-gui-1.3.9      gns3-server-1.3.9      iouyap       iouyap-0.95.zip  ubridge-0.9.0.zip  vpcs-0.6.1.zip
dynamips-0.2.14.zip  gns3-gui-1.3.9.zip  gns3-server-1.3.9.zip  iouyap-0.95  ubridge-0.9.0    vpcs-0.6.1
[toby@thebay GNS3-1.3.9]$ cd iouyap
[toby@thebay iouyap]$ ls
config.c  dictionary.h  iouyap.c  iouyap.ini  Makefile  netmap.c  netmap_parse.y  README.rst
config.h  iniparser.h   iouyap.h  LICENSE     NETMAP    netmap.h  netmap_scan.l
[toby@thebay iouyap]$ make
gcc  -g -DDEBUG -Wall   -c -o iouyap.o iouyap.c
bison -y -d netmap_parse.y
mv -f y.tab.c netmap_parse.c
gcc  -g -DDEBUG -Wall   -c -o netmap_parse.o netmap_parse.c
flex  -t netmap_scan.l > netmap_scan.c
gcc  -g -DDEBUG -Wall   -c -o netmap_scan.o netmap_scan.c
gcc  -g -DDEBUG -Wall   -c -o netmap.o netmap.c
gcc  -g -DDEBUG -Wall   -c -o config.o config.c
gcc    iouyap.o netmap_parse.o netmap_scan.o netmap.o config.o  -liniparser -lpthread -o iouyap
rm netmap_scan.c netmap_parse.c
[toby@thebay iouyap]$ sudo make install
[sudo] password for toby:
chmod +x iouyap
sudo cp iouyap /usr/local/bin
sudo setcap cap_net_admin,cap_net_raw=ep iouyap

Taa Daa!