[zebra 23338] Re: Need to include a new program in zebra project

Paul URVOAS <[email protected]> Mon, 1 Aug 2011 09:51:19 +0200
Newsgroups gmane.network.zebra
Message-ID <CALaN9wxGda9-n7sjGt4QMaXRXHwAjnPuoyCpupdL5BqXdc+1xw@mail.gmail.com>
--===============2138106931==
Content-Type: multipart/alternative; boundary=0016363ba2c688834604a96ce58c

--0016363ba2c688834604a96ce58c
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

The program I want to add to Zebra is in the directory /zebra/meas

I do not have any skills with automake/autoconf. Which line I have to add i=
n
/meas/Makefile.am ??


The source code is as follow :

##### meas_main.c

#include "zebra.h"
#include "stream.h"

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close(s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;

#define PORT 2616

enum DragonMeasMessage {
Message1 =3D 1,
Message2 =3D 2
};



int
main (int argc, char **argv)
{
int n=3D0;
SOCKET sock;
SOCKADDR_IN sin;

u_int8_t message =3D Message1;
u_int8_t msgLength;;

struct stream *s;

/* Cr=C3=A9ation de la socket */
sock =3D socket(AF_INET, SOCK_STREAM, 0);

/* Configuration de la connexion */
sin.sin_addr.s_addr =3D htonl (INADDR_LOOPBACK);
sin.sin_family =3D AF_INET;
sin.sin_port =3D htons(PORT);

/* Si le client arrive =C3  se connecter */
if(connect(sock, (SOCKADDR*)&sin, sizeof(sin)) !=3D SOCKET_ERROR)
printf("Connexion =C3  %s sur le port %d\n", inet_ntoa(sin.sin_addr),
htons(sin.sin_port));
else
printf("Impossible de se connecter\n");


stream_putl(s, msgLength);
stream_putl(s, message);
//write (sock, STREAM_DATA(s), msgLength);


/* On ferme la socket pr=C3=A9c=C3=A9demment ouverte */
closesocket(sock);
exit (0);
}

#####


2011/7/29 Yasuhiro Ohara <[email protected]>

>
> The most simple way is to add 3 lines in Makefile.am,
> and run automake/autoconf.
>
> Could you show me the source code ?
>
> regards,
> yasu
>
> From: Paul URVOAS <[email protected]>
> Subject: [zebra 23336] Need to include a new program in zebra project
> Date: Fri, 29 Jul 2011 11:37:23 +0200
> Message-ID: <
> CALaN9wx+pUu-ix31yuKprQoUkm5BzkLTsLY9ZdE9by3xp5cBpQ@mail.gmail.com>
>
> > Hi,
> >
> > I am begining a project using zebra in order to develop a GMPLS
> > implementation.
> >
> > I would like to create a new process which would communicate with ospfd
> > using sockets (functions stream_put) and therefore I want to include
> > zebra.h. When I want to compile my program manually, I get the compiler
> > message : *stream_putl undefined reference*.
> >
> > Should I have to include my program in zebra project using makefile etc=
..
> If
> > yes how can I get the makefiles I need ?
> >
> > Should I have to compile my program manually ? (this is a pretty simple
> > program just using zebra.h)
> >
> > If you have some tips, please let me know ;)
> >
> >
> > Paul,
> > Intern France T=E9l=E9com
>

--0016363ba2c688834604a96ce58c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

The program I want to add to Zebra is in the directory /zebra/meas<div><br>=
</div><div>I do not have any skills with automake/autoconf. Which line I ha=
ve to add in /meas/Makefile.am ??</div><div><br></div><div><br></div><div>
The source code is as follow :</div><div><br></div><div>##### meas_main.c</=
div><div><br></div><div><div>#include &quot;zebra.h&quot;</div><div>#includ=
e &quot;stream.h&quot;</div><div><br></div><div>#include &lt;sys/types.h&gt=
;</div>
<div>#include &lt;sys/socket.h&gt;</div><div>#include &lt;netinet/in.h&gt;<=
/div><div>#include &lt;arpa/inet.h&gt;</div><div>#include &lt;unistd.h&gt;<=
/div><div>#define INVALID_SOCKET -1</div><div>#define SOCKET_ERROR -1</div>
<div>#define closesocket(s) close(s)</div><div>typedef int SOCKET;</div><di=
v>typedef struct sockaddr_in SOCKADDR_IN;</div><div>typedef struct sockaddr=
 SOCKADDR;</div><div><br></div><div>#define PORT 2616</div><div><br></div>
<div>enum DragonMeasMessage {</div><div><span class=3D"Apple-tab-span" styl=
e=3D"white-space:pre">	</span>Message1 =3D 1,</div><div><span class=3D"Appl=
e-tab-span" style=3D"white-space:pre">	</span>Message2 =3D 2</div><div>};</=
div><div>
<br></div><div><br></div><div><br></div><div>int</div><div>main (int argc, =
char **argv)</div><div>{</div><div><span class=3D"Apple-tab-span" style=3D"=
white-space:pre">	</span>int n=3D0;</div><div><span class=3D"Apple-tab-span=
" style=3D"white-space:pre">	</span>SOCKET sock;</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>SOCKA=
DDR_IN sin;</div><div><br></div><div><span class=3D"Apple-tab-span" style=
=3D"white-space:pre">	</span>u_int8_t message =3D Message1;</div><div><span=
 class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>u_int8_t msgLen=
gth;;</div>
<div><br></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre=
">	</span>struct stream *s;</div><div><br></div><div><span class=3D"Apple-t=
ab-span" style=3D"white-space:pre">	</span>/* Cr=C3=A9ation de la socket */=
</div><div>
<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>sock =3D s=
ocket(AF_INET, SOCK_STREAM, 0);</div><div><br></div><div><span class=3D"App=
le-tab-span" style=3D"white-space:pre">	</span>/* Configuration de la conne=
xion */</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>sin.s=
in_addr.s_addr =3D htonl (INADDR_LOOPBACK);</div><div><span class=3D"Apple-=
tab-span" style=3D"white-space:pre">	</span>sin.sin_family =3D AF_INET;</di=
v><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>sin=
.sin_port =3D htons(PORT);</div>
<div><br></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre=
">	</span>/* Si le client arrive =C3 =A0se connecter */</div><div><span cla=
ss=3D"Apple-tab-span" style=3D"white-space:pre">	</span>if(connect(sock, (S=
OCKADDR*)&amp;sin, sizeof(sin)) !=3D SOCKET_ERROR)</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span>prin=
tf(&quot;Connexion =C3 =A0%s sur le port %d\n&quot;, inet_ntoa(sin.sin_addr=
), htons(sin.sin_port));</div><div><span class=3D"Apple-tab-span" style=3D"=
white-space:pre">	</span>else</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span>prin=
tf(&quot;Impossible de se connecter\n&quot;);</div><div><br></div><div><br>=
</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span=
>stream_putl(s, msgLength);</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>strea=
m_putl(s, message);</div><div><span class=3D"Apple-tab-span" style=3D"white=
-space:pre">	</span>//write (sock, STREAM_DATA(s), msgLength);</div><div><b=
r></div>
<div><br></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre=
">	</span>/* On ferme la socket pr=C3=A9c=C3=A9demment ouverte */</div><div=
><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>closesock=
et(sock);</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>exit =
(0);</div><div>}</div><div><br></div><div>#####</div><div><br></div><br><di=
v class=3D"gmail_quote">2011/7/29 Yasuhiro Ohara <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:[email protected]">[email protected]</a>&gt;</span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex;"><br>
The most simple way is to add 3 lines in Makefile.am,<br>
and run automake/autoconf.<br>
<br>
Could you show me the source code ?<br>
<br>
regards,<br>
yasu<br>
<br>
From: Paul URVOAS &lt;<a href=3D"mailto:[email protected]">paul.urvoas@=
gmail.com</a>&gt;<br>
Subject: [zebra 23336] Need to include a new program in zebra project<br>
Date: Fri, 29 Jul 2011 11:37:23 +0200<br>
Message-ID: &lt;<a href=3D"mailto:CALaN9wx%2BpUu-ix31yuKprQoUkm5BzkLTsLY9Zd=
[email protected]">CALaN9wx+pUu-ix31yuKprQoUkm5BzkLTsLY9ZdE9by3xp=
[email protected]</a>&gt;<br>
<div><div></div><div class=3D"h5"><br>
&gt; Hi,<br>
&gt;<br>
&gt; I am begining a project using zebra in order to develop a GMPLS<br>
&gt; implementation.<br>
&gt;<br>
&gt; I would like to create a new process which would communicate with ospf=
d<br>
&gt; using sockets (functions stream_put) and therefore I want to include<b=
r>
&gt; zebra.h. When I want to compile my program manually, I get the compile=
r<br>
&gt; message : *stream_putl undefined reference*.<br>
&gt;<br>
&gt; Should I have to include my program in zebra project using makefile et=
c.. If<br>
&gt; yes how can I get the makefiles I need ?<br>
&gt;<br>
&gt; Should I have to compile my program manually ? (this is a pretty simpl=
e<br>
&gt; program just using zebra.h)<br>
&gt;<br>
&gt; If you have some tips, please let me know ;)<br>
&gt;<br>
&gt;<br>
&gt; Paul,<br>
&gt; Intern France T=E9l=E9com<br>
</div></div></blockquote></div><br></div>

--0016363ba2c688834604a96ce58c--

--===============2138106931==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Zebra mailing list
[email protected]
http://ml.zebra.org/mailman/listinfo/zebra

--===============2138106931==--