[PATCH] lwip translator: Remove unused reference to config.h

2018-05-02 Thread Joan Lledó
---
 lwip/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lwip/Makefile b/lwip/Makefile
index c5f3c8cb..d0ddfd38 100644
--- a/lwip/Makefile
+++ b/lwip/Makefile
@@ -47,4 +47,3 @@ iioctl-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
 
 # cpp doesn't automatically make dependencies for -imacros dependencies. argh.
 lwip_io_S.h ioServer.c lwip_socket_S.h socketServer.c: mig-mutate.h
-$(OBJS): config.h
-- 
2.14.0




Re: [PATCH] LwIP translator

2017-12-19 Thread Joan Lledó
Hi,

2017-12-19 19:21 GMT+01:00 Samuel Thibault :
> Is it not actually valid for posix systems in general? (except the
> cond_wait thing which I patched over)

That's what the port/ folder contains:
  - lwipopts.h is for configuring the stack parameters
  - cc.h is for integrating the stack in our system
  - sys_arch.{c,h} are valid for all Unix systems and are already
upstream, but not in the main repository, they are in lwip-contrib,
used for testing and examples. I took them from there and these have
BSD header.

Besides, in the port/ folder in my dhclient branch I have some code
needed to make it work with dhcp after patching dhclient-script. You
may remember I sent a patch[1] to dhcp maintainers.

2017-12-19 19:47 GMT+01:00 Svante Signell :
> I thought you sent that patch to upstream. Why not?

I sent it, it's upstream but not in 2.0.3, it will be part of the next release.

> What about Samuel make a first release, and you take over later on? It would 
> be
> really nice to try LwIP out as a user (and get rid of pfinet in due time).
>

I'll do what's best for the project, if you guys decide so, It's OK
for me. I never contributed to Debian, it might be a good idea to not
start from scratch.

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=875566



Re: [PATCH] LwIP translator

2017-12-19 Thread Svante Signell
On Tue, 2017-12-19 at 19:21 +0100, Samuel Thibault wrote:
> Joan Lledó, on mar. 19 déc. 2017 19:11:40 +0100, wrote:

> > - The patches in debian/patches are not enough to make the server
> > work, for instance, we're calling lwip_poll() which is not in 2.0.3
> > nor any patch in the package.

I thought you sent that patch to upstream. Why not?

> I know, it's just in order to get the package into Debian, going through
> NEW takes time.

See below.

> > I suggest to be myself who maintain the lwip packages, If we're in no
> > hurry, I'd could do it from February on.
> 
> I'm fine with it, it'd just be sad we don't have it before :)

What about Samuel make a first release, and you take over later on? It would be
really nice to try LwIP out as a user (and get rid of pfinet in due time).



Re: [PATCH] LwIP translator

2017-12-19 Thread Samuel Thibault
Joan Lledó, on mar. 19 déc. 2017 19:11:40 +0100, wrote:
> 2017-12-18 20:03 GMT+01:00 Samuel Thibault :
> > I am talking about the files you created in your repository, they are
> > hold a GPL copyright notice.  I guess at some point we will want to see
> > them maintained within lwip, and thus BSD-licensed.
> >
> 
> I've been reviewing the reposotory you attached and have some comments:
> 
> - All files I added are not intended to go upstream, they are all in
> port/ folder which is valid only for us.

Is it not actually valid for posix systems in general? (except the
cond_wait thing which I patched over)

> - The patches in debian/patches are not enough to make the server
> work, for instance, we're calling lwip_poll() which is not in 2.0.3
> nor any patch in the package.

I know, it's just in order to get the package into Debian, going through
NEW takes time.

> I suggest to be myself who maintain the lwip packages, If we're in no
> hurry, I'd could do it from February on.

I'm fine with it, it'd just be sad we don't have it before :)

Samuel



Re: [PATCH] LwIP translator

2017-12-19 Thread Joan Lledó
Hi Samuel,

2017-12-18 20:03 GMT+01:00 Samuel Thibault :
> I am talking about the files you created in your repository, they are
> hold a GPL copyright notice.  I guess at some point we will want to see
> them maintained within lwip, and thus BSD-licensed.
>

I've been reviewing the reposotory you attached and have some comments:

- All files I added are not intended to go upstream, they are all in
port/ folder which is valid only for us.
- The patches in debian/patches are not enough to make the server
work, for instance, we're calling lwip_poll() which is not in 2.0.3
nor any patch in the package.

I suggest to be myself who maintain the lwip packages, If we're in no
hurry, I'd could do it from February on.



Re: [PATCH] LwIP translator

2017-12-18 Thread Joan Lledó
2017-12-18 17:28 GMT+01:00 Samuel Thibault :
> BTW, your lwip code should probably be made BSD-licensed, just like the
> rest of lwip.

Mmm, I think I don't know what you mean, if I send patches to a
BSD-licensed project, they are BSD too, right?



Re: [PATCH] LwIP translator

2017-12-18 Thread James Clarke
On 18 Dec 2017, at 17:09, Samuel Thibault  wrote:
> James Clarke, on lun. 18 déc. 2017 17:06:28 +, wrote:
>> On 18 Dec 2017, at 16:28, Samuel Thibault  wrote:
>>> Joan Lledó, on lun. 18 déc. 2017 17:10:42 +0100, wrote:
 2017-12-18 14:46 GMT+01:00 Samuel Thibault :
> We need to know what is not yet in upstream, what will
> eventually get to upstream, and what may not get to
> upstream.
 
 There're also some patches that are in upstream, I think it would be
 simpler for me to first upgrade liblwip to 2.0.3 and then take that
 version as start point to create the list of pending patches.
>>> 
>>> Ok.  In the meanwhile I have prepared an upload for lwip to Debian, I
>>> have borrowed some code I could find in your tree and hacked a bit, see 
>>> 
>>> git clone https://anonscm.debian.org/collab-maint/lwip.git
>> 
>> You missed the initial /git/ there (and in Vcs-Git).
> 
> It looks like dh-make is bogus then, that's what set this URL.

*sigh* Fixed in 2016, but no upload yet[1] (also [2] more recently).
I will ping the bug...

James

[1] 
https://anonscm.debian.org/cgit/collab-maint/dh-make.git/commit/?id=8bc8e0fab2f8293f8946e51768802532a6470d7f
[2] 
https://anonscm.debian.org/cgit/collab-maint/dh-make.git/commit/?id=b5a2903efa716e898c141397a6e471ec6fd9febb




Re: [PATCH] LwIP translator

2017-12-18 Thread Samuel Thibault
James Clarke, on lun. 18 déc. 2017 17:06:28 +, wrote:
> On 18 Dec 2017, at 16:28, Samuel Thibault  wrote:
> > Joan Lledó, on lun. 18 déc. 2017 17:10:42 +0100, wrote:
> >> 2017-12-18 14:46 GMT+01:00 Samuel Thibault :
> >>> We need to know what is not yet in upstream, what will
> >>> eventually get to upstream, and what may not get to
> >>> upstream.
> >> 
> >> There're also some patches that are in upstream, I think it would be
> >> simpler for me to first upgrade liblwip to 2.0.3 and then take that
> >> version as start point to create the list of pending patches.
> > 
> > Ok.  In the meanwhile I have prepared an upload for lwip to Debian, I
> > have borrowed some code I could find in your tree and hacked a bit, see 
> > 
> > git clone https://anonscm.debian.org/collab-maint/lwip.git
> 
> You missed the initial /git/ there (and in Vcs-Git).

It looks like dh-make is bogus then, that's what set this URL.

> Also there's already src:lwipv6 in the archive which last saw an
> upload in 2012, so might be worth unifying them if possible

Sure.

Samuel



Re: [PATCH] LwIP translator

2017-12-18 Thread James Clarke
On 18 Dec 2017, at 16:28, Samuel Thibault  wrote:
> Joan Lledó, on lun. 18 déc. 2017 17:10:42 +0100, wrote:
>> 2017-12-18 14:46 GMT+01:00 Samuel Thibault :
>>> We need to know what is not yet in upstream, what will
>>> eventually get to upstream, and what may not get to
>>> upstream.
>> 
>> There're also some patches that are in upstream, I think it would be
>> simpler for me to first upgrade liblwip to 2.0.3 and then take that
>> version as start point to create the list of pending patches.
> 
> Ok.  In the meanwhile I have prepared an upload for lwip to Debian, I
> have borrowed some code I could find in your tree and hacked a bit, see 
> 
> git clone https://anonscm.debian.org/collab-maint/lwip.git

You missed the initial /git/ there (and in Vcs-Git). Also there's already
src:lwipv6 in the archive which last saw an upload in 2012, so might be worth
unifying them if possible (it seems to be a fork from a while ago[1], probably
before IPv6 was added upstream).

Regards,
James

[1] https://sourceforge.net/p/view-os/code/HEAD/tree/trunk/lwipv6/




Re: [PATCH] LwIP translator

2017-12-18 Thread Samuel Thibault
Joan Lledó, on lun. 18 déc. 2017 17:10:42 +0100, wrote:
> 2017-12-18 14:46 GMT+01:00 Samuel Thibault :
> > We need to know what is not yet in upstream, what will
> > eventually get to upstream, and what may not get to
> > upstream.
> 
> There're also some patches that are in upstream, I think it would be
> simpler for me to first upgrade liblwip to 2.0.3 and then take that
> version as start point to create the list of pending patches.

Ok.  In the meanwhile I have prepared an upload for lwip to Debian, I
have borrowed some code I could find in your tree and hacked a bit, see 

git clone https://anonscm.debian.org/collab-maint/lwip.git

BTW, your lwip code should probably be made BSD-licensed, just like the
rest of lwip.

Samuel



Re: [PATCH] LwIP translator

2017-12-18 Thread Joan Lledó
2017-12-18 14:46 GMT+01:00 Samuel Thibault :
> Ok, but I don't see that base in your repository, the first commit
> already has a lot of source code which is not in 2.0.1.

Oh, yes. That's because I first imported all lwip 2.0.1 code to my
lwip-hurd repository and made many changes there. Then I moved it to
liblwip-hurd and made more changes. It's a bit of a mess, I'm sorry.

> We need to know what is not yet in upstream, what will
> eventually get to upstream, and what may not get to
> upstream.

There're also some patches that are in upstream, I think it would be
simpler for me to first upgrade liblwip to 2.0.3 and then take that
version as start point to create the list of pending patches.



Re: [PATCH] LwIP translator

2017-12-18 Thread Samuel Thibault
Hello,

Joan Lledó, on lun. 18 déc. 2017 12:58:35 +0100, wrote:
> 2017-12-18 2:32 GMT+01:00 Samuel Thibault :
> > Or are you actually based on another lwip?
> 
> Yes, It's based in the version 2.0.1, as I started to work on this
> back in February.

Ok, but I don't see that base in your repository, the first commit
already has a lot of source code which is not in 2.0.1.  We need to know
what is not yet in upstream, what will eventually get to upstream, and
what may not get to upstream.

Samuel



Re: [PATCH] LwIP translator

2017-12-18 Thread Joan Lledó
Hello,

2017-12-18 2:32 GMT+01:00 Samuel Thibault :
> Or are you actually based on another lwip?

Yes, It's based in the version 2.0.1, as I started to work on this
back in February. I plan to upgrade liblwip to the last version in a
few months.



Re: [PATCH] LwIP translator

2017-12-17 Thread Samuel Thibault
Hello,

I'm however having a hard time matching your
g...@github.com:jlledom/liblwip-hurd.git repository with the upstream
https://git.savannah.nongnu.org/git/lwip.git repository. Since the plan
is to just pick up upstream as much as possible, we need to keep the
delta small.

Or are you actually based on another lwip?

Samuel



Re: [PATCH] LwIP translator

2017-12-17 Thread Samuel Thibault
Hello,

At last, found the time to commit this :)

Huge hanks!
Samuel



Re: [PATCH] LwIP translator

2017-11-12 Thread Samuel Thibault
Joan Lledó, on lun. 13 nov. 2017 08:31:45 +0100, wrote:
> After working on the perl tests fails, I can say they are due to bugs in 
> lwip, not in our server. I've already sent the bug reports.

Heh, nice :D

Samuel



[PATCH] LwIP translator

2017-11-12 Thread Joan Lledó
---
 Makefile |   4 +
 config.make.in   |   7 +
 configure.ac |   5 +
 lwip/Makefile|  52 +++
 lwip/config.h|   5 +
 lwip/iioctl-ops.c| 412 
 lwip/io-ops.c| 554 +++
 lwip/lwip-hurd.h | 102 +
 lwip/lwip-util.c | 343 +
 lwip/lwip-util.h |  41 ++
 lwip/main.c  | 272 +
 lwip/mig-decls.h |  68 
 lwip/mig-mutate.h|  44 +++
 lwip/options.c   | 342 +
 lwip/options.h   |  81 
 lwip/pfinet-ops.c| 113 ++
 lwip/port-objs.c | 144 +++
 lwip/port/include/netif/hurdethif.h  |  39 ++
 lwip/port/include/netif/hurdloopif.h |  36 ++
 lwip/port/include/netif/hurdtunif.h  |  65 
 lwip/port/include/netif/ifcommon.h   |  60 +++
 lwip/port/netif/hurdethif.c  | 573 
 lwip/port/netif/hurdloopif.c | 112 ++
 lwip/port/netif/hurdtunif.c  | 721 +++
 lwip/port/netif/ifcommon.c   | 121 ++
 lwip/socket-ops.c| 450 ++
 lwip/startup-ops.c   |  39 ++
 lwip/startup.c   |  69 
 lwip/startup.h   |  26 ++
 29 files changed, 4900 insertions(+)
 create mode 100644 lwip/Makefile
 create mode 100644 lwip/config.h
 create mode 100644 lwip/iioctl-ops.c
 create mode 100644 lwip/io-ops.c
 create mode 100644 lwip/lwip-hurd.h
 create mode 100644 lwip/lwip-util.c
 create mode 100644 lwip/lwip-util.h
 create mode 100644 lwip/main.c
 create mode 100644 lwip/mig-decls.h
 create mode 100644 lwip/mig-mutate.h
 create mode 100644 lwip/options.c
 create mode 100644 lwip/options.h
 create mode 100644 lwip/pfinet-ops.c
 create mode 100644 lwip/port-objs.c
 create mode 100644 lwip/port/include/netif/hurdethif.h
 create mode 100644 lwip/port/include/netif/hurdloopif.h
 create mode 100644 lwip/port/include/netif/hurdtunif.h
 create mode 100644 lwip/port/include/netif/ifcommon.h
 create mode 100644 lwip/port/netif/hurdethif.c
 create mode 100644 lwip/port/netif/hurdloopif.c
 create mode 100644 lwip/port/netif/hurdtunif.c
 create mode 100644 lwip/port/netif/ifcommon.c
 create mode 100644 lwip/socket-ops.c
 create mode 100644 lwip/startup-ops.c
 create mode 100644 lwip/startup.c
 create mode 100644 lwip/startup.h

diff --git a/Makefile b/Makefile
index 119f130b..2d9d3f80 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,10 @@ ifeq ($(HAVE_SUN_RPC),yes)
 prog-subdirs += nfs nfsd
 endif
 
+ifeq ($(HAVE_LIBLWIP),yes)
+prog-subdirs += lwip
+endif
+
 # Other directories
 other-subdirs = hurd doc config release include
 
diff --git a/config.make.in b/config.make.in
index dfbf0c10..7b62e851 100644
--- a/config.make.in
+++ b/config.make.in
@@ -99,6 +99,13 @@ HAVE_SUN_RPC = @HAVE_SUN_RPC@
 # Whether we found libgcrypt.
 HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
 
+# Whether we found liblwip.
+HAVE_LIBLWIP = @HAVE_LIBLWIP@
+
+# How to compile and link against liblwip.
+liblwip_CFLAGS = @liblwip_CFLAGS@
+liblwip_LIBS = @liblwip_LIBS@
+
 # Installation tools.
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/configure.ac b/configure.ac
index 54aa72b0..5abedf46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -344,6 +344,11 @@ AC_SUBST([libblkid_CFLAGS])
 AM_PATH_LIBGCRYPT("1:1.6.0",[HAVE_LIBGCRYPT=yes], [HAVE_LIBGCRYPT=no])
 AC_SUBST([HAVE_LIBGCRYPT])
 
+PKG_CHECK_MODULES([liblwip], [lwip], [HAVE_LIBLWIP=yes], [HAVE_LIBLWIP=no])
+AC_SUBST([HAVE_LIBLWIP])
+AC_SUBST([liblwip_CFLAGS])
+AC_SUBST([liblwip_LIBS])
+
 AC_CONFIG_FILES([config.make ${makefiles}])
 AC_OUTPUT
 
diff --git a/lwip/Makefile b/lwip/Makefile
new file mode 100644
index ..c9c4d888
--- /dev/null
+++ b/lwip/Makefile
@@ -0,0 +1,52 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+#   This file is part of the GNU Hurd.
+#
+#   The GNU Hurd is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2, or (at
+#   your option) any later version.
+#
+#   The GNU Hurd is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#   General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the GNU Hurd.  If not, see .
+
+dir= lwip
+makemode   = server
+
+PORTDIR = $(srcdir)/port
+
+SRCS   = main.c io-ops.c socket-ops.c pfinet-ops.c iioctl-ops.c 
port-objs.c \
+ 

[PATCH] LwIP translator

2017-11-12 Thread Joan Lledó

After working on the perl tests fails, I can say they are due to bugs in lwip, 
not in our server. I've already sent the bug reports.

The attached patch includes all required changes in previous emails.



Re: [PATCH] LwIP translator

2017-10-29 Thread Samuel Thibault
Joan Lledó, on dim. 29 oct. 2017 11:46:20 +0100, wrote:
> the perl testsuite indeed found some bugs. So I'll send the new patch
> when I have them fixed.

Heh :)

Thanks!
Samuel



Re: [PATCH] LwIP translator

2017-10-29 Thread Joan Lledó
2017-10-22 17:25 GMT+02:00 Samuel Thibault :
>>
>> Unfortunately, lwip doesn't provide a lwip_ppoll() function.
>
> Ah, I saw it in lwipv6, I thought it was generally available.
>
> That being said, it'd be better to make the code already use struct
> timespec, converting to coarser resolution only where is has to be done
> (the lwip_poll call).

That's already done. In lwip_io_select_common() the timeout is rounded
just before calling lwip_poll().

It shouldn't be difficult to write a lwip_ppoll() function, I'll try
it some day.

>>
>> 1.- Why inhibit pfinet_{cntl,protid}_portclasses[0] and not
>> pfinet_{cntl,protid}_portclasses[1]. Wouldn't that lead to stop RPCs
>> to /servers/socket/2 but still allow RPCs to /servers/socket/26?
>
> That's probably just a bug, yes.

OK

>> 2.- Why inhibit socketport_class and not addrpot_class?
>
> I guess that's because it's not "too bad" for the addrport RPCs to
> break, and they are usually used very transiently while a socket is
> still active.  But for safety it is probably better to inhibit it.
> I guess the cases where there wouldn't be any socket left but some
> addrport left is rare enough that we don't care.

OK

>> 3.- Why use ports_inhibit_class_rpcs() for inhibiting all classes, but
>> then use ports_enable_class() just for socketport_class and
>> ports_resume_class_rpcs() for all other classes?
>
> I have to say I don't know :)
> I don't know if that was really tested actually. From reading the source
> it seems it should really be replaced by ports_resume_class_rpcs.

OK

>> I have kind of the same question about S_startup_dosync()[2]. Why
>> destroy only socketport_class ports and not addrport_class ones?
>
> I guess it's the same answer as above: we can as well destroy them too
> for nicer handling.

OK Again.

I think I've done all your requested changes, but the perl testsuite
indeed found some bugs. So I'll send the new patch when I have them
fixed.

Regards.



Re: [PATCH] LwIP translator

2017-10-22 Thread Samuel Thibault
Hello,

Joan Lledó, on mer. 18 oct. 2017 09:24:22 +0200, wrote:
> >> +static error_t
> >> +lwip_io_select_common (struct sock_user *user,
> >> +mach_port_t reply,
> >> +mach_msg_type_name_t reply_type,
> >> +struct timeval *tv, int *select_type)
> >> +{
> > ...
> >> +  timeout = tv ? tv->tv_sec * 1000 + tv->tv_usec / 1000 : -1;
> >> +  ret = lwip_poll (, nfds, timeout);
> >
> > Better use lwip_ppoll to have better timeout resolution, and use struct
> > timespec instead of struct timeval.
> 
> Unfortunately, lwip doesn't provide a lwip_ppoll() function.

Ah, I saw it in lwipv6, I thought it was generally available.

That being said, it'd be better to make the code already use struct
timespec, converting to coarser resolution only where is has to be done
(the lwip_poll call).

> >> +  if (addr6_prefix_len)
> >> + for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
> >> +   *(addr6_prefix_len + i) = 64;
> >
> > Does lwip support only /64 IPv6 networks?
> 
> Yes.

Ok :/

> >> +error_t
> >> +trivfs_goaway (struct trivfs_control *fsys, int flags)
> >> +{
> >> +  exit (0);
> >> +}
> >
> > The linuxish pfinet returns EBUSY if there are still sockets, it is a
> > useful thing to check.
> 
> There are a few things I don't understand in pfinet's trivfs_goaway()[1].
> 
> 1.- Why inhibit pfinet_{cntl,protid}_portclasses[0] and not
> pfinet_{cntl,protid}_portclasses[1]. Wouldn't that lead to stop RPCs
> to /servers/socket/2 but still allow RPCs to /servers/socket/26?

That's probably just a bug, yes.

> 2.- Why inhibit socketport_class and not addrpot_class?

I guess that's because it's not "too bad" for the addrport RPCs to
break, and they are usually used very transiently while a socket is
still active.  But for safety it is probably better to inhibit it.
I guess the cases where there wouldn't be any socket left but some
addrport left is rare enough that we don't care.

> 3.- Why use ports_inhibit_class_rpcs() for inhibiting all classes, but
> then use ports_enable_class() just for socketport_class and
> ports_resume_class_rpcs() for all other classes?

I have to say I don't know :)
I don't know if that was really tested actually. From reading the source
it seems it should really be replaced by ports_resume_class_rpcs.

> >> +  if (pi)
> >> +{
> >> +  ports_port_deref (pi);
> >> +
> >> +  mig_routine_t routine;
> >> +  if ((routine = lwip_io_server_routine (inp)) ||
> >> +   (routine = lwip_socket_server_routine (inp)) ||
> >> +   (routine = lwip_pfinet_server_routine (inp)) ||
> >> +   (routine = lwip_iioctl_server_routine (inp)) ||
> >> +   (routine = NULL, trivfs_demuxer (inp, outp)))
> >
> > In the linuxish pfinet, the startup protocol is also used, to nicely
> > close net channels before exiting, that's a useful thing to do.
> 
> I have kind of the same question about S_startup_dosync()[2]. Why
> destroy only socketport_class ports and not addrport_class ones?

I guess it's the same answer as above: we can as well destroy them too
for nicer handling.

Samuel



Re: [PATCH] LwIP translator

2017-10-18 Thread Samuel Thibault
Joan Lledó, on mer. 18 oct. 2017 09:24:22 +0200, wrote:
> > Last but not least, did you try to run the glibc testsuite while running
> > this TCP/IP stack?  It would probably find potential bugs.  Also, the
> > perl testsuite is probably a nice thing to run.
> 
> I need help here. I've been googling but haven't found any good
> reference to know what should I do exactly. Do you have any
> references?

apt-get build-dep glibc
apt-get source glibc
cd glibc-*
dpkg-buildpackage -B

Same for perl :)

Samuel



Re: [PATCH] LwIP translator

2017-10-18 Thread Joan Lledó
Hello Samuel,

Thanks for taking your time reviewing my code.

2017-09-27 0:44 GMT+02:00 Samuel Thibault :
>> +error_t
>> +lwip_S_io_write (struct sock_user * user,
>> +  char *data,
>> +  size_t datalen,
>> +  off_t offset, mach_msg_type_number_t * amount)
>> +{
> ...
>> +  if (sockflags & O_NONBLOCK)
>> +m.msg_flags |= MSG_DONTWAIT;
>> +  sent = lwip_sendmsg (user->sock->sockno, , 0);
>
> I'm wondering about thread-safety: I guess you enabled the unix arch to
> get pthread mutex locks?

Yes, lwip provides its own locking system that uses libpthread in Unix
platforms.

>> +static error_t
>> +lwip_io_select_common (struct sock_user *user,
>> +mach_port_t reply,
>> +mach_msg_type_name_t reply_type,
>> +struct timeval *tv, int *select_type)
>> +{
> ...
>> +  timeout = tv ? tv->tv_sec * 1000 + tv->tv_usec / 1000 : -1;
>> +  ret = lwip_poll (, nfds, timeout);
>
> Better use lwip_ppoll to have better timeout resolution, and use struct
> timespec instead of struct timeval.

Unfortunately, lwip doesn't provide a lwip_ppoll() function.

>> +  if (addr6_prefix_len)
>> + for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
>> +   *(addr6_prefix_len + i) = 64;
>
> Does lwip support only /64 IPv6 networks?

Yes.

>> +error_t
>> +trivfs_goaway (struct trivfs_control *fsys, int flags)
>> +{
>> +  exit (0);
>> +}
>
> The linuxish pfinet returns EBUSY if there are still sockets, it is a
> useful thing to check.

There are a few things I don't understand in pfinet's trivfs_goaway()[1].

1.- Why inhibit pfinet_{cntl,protid}_portclasses[0] and not
pfinet_{cntl,protid}_portclasses[1]. Wouldn't that lead to stop RPCs
to /servers/socket/2 but still allow RPCs to /servers/socket/26?

2.- Why inhibit socketport_class and not addrpot_class?

3.- Why use ports_inhibit_class_rpcs() for inhibiting all classes, but
then use ports_enable_class() just for socketport_class and
ports_resume_class_rpcs() for all other classes?

>> +  if (pi)
>> +{
>> +  ports_port_deref (pi);
>> +
>> +  mig_routine_t routine;
>> +  if ((routine = lwip_io_server_routine (inp)) ||
>> +   (routine = lwip_socket_server_routine (inp)) ||
>> +   (routine = lwip_pfinet_server_routine (inp)) ||
>> +   (routine = lwip_iioctl_server_routine (inp)) ||
>> +   (routine = NULL, trivfs_demuxer (inp, outp)))
>
> In the linuxish pfinet, the startup protocol is also used, to nicely
> close net channels before exiting, that's a useful thing to do.

I have kind of the same question about S_startup_dosync()[2]. Why
destroy only socketport_class ports and not addrport_class ones?

>> +case 'A':
>> +  /* IPv6 address */
>> +  if (arg)
>> + {
>
>> +
>> +   for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
>> + {
>> +   address6 = (ip6_addr_t *) & h->curint->addr6[i];
>> +
>> +   /* Is the slot free? */
>> +   if (!ip6_addr_isany (address6))
>> + continue;
>> +
>> +   /* Use the slot */
>> +   if (ip6addr_aton (arg, address6) <= 0)
>> + PERR (EINVAL, "Malformed address");
>> +
>> +   break;
>> + }
>
> There should be some error thrown if we couldn't find a free slot.

It was at [3] but didn't print the particular address. I changed it to do it.

> Last but not least, did you try to run the glibc testsuite while running
> this TCP/IP stack?  It would probably find potential bugs.  Also, the
> perl testsuite is probably a nice thing to run.

I need help here. I've been googling but haven't found any good
reference to know what should I do exactly. Do you have any
references?

Everything else is done in my Github, I'll provide a patch when I
finish all issues.

-
[1] http://git.savannah.gnu.org/cgit/hurd/hurd.git/tree/pfinet/main.c#n477
[2] http://git.savannah.gnu.org/cgit/hurd/hurd.git/tree/pfinet/main.c#n137
[3] https://github.com/jlledom/lwip-hurd/blob/master/lwip-util.c#L216



Re: [PATCH] LwIP translator

2017-09-26 Thread Samuel Thibault
Samuel Thibault, on mer. 27 sept. 2017 00:44:15 +0200, wrote:
> Last but not least, did you try to run the glibc testsuite while running
> this TCP/IP stack?  It would probably find potential bugs.  Also, the
> perl testsuite is probably a nice thing to run.

(I'm not saying I won't commit this work without running those, but if
running them makes you easily fix some bugs, that'll be useful :) )

Samuel



Re: [PATCH] LwIP translator

2017-09-26 Thread Samuel Thibault
Hello,

Joan Lledó, on mer. 06 sept. 2017 10:09:36 +0200, wrote:
> --- /dev/null
> +++ b/lwip/iioctl-ops.c

> +/* Get the interface from its name */
> +static struct netif *
> +get_if (char *name)
...
> +
> +  netif = netif_list;
> +  while (netif != 0)
> +{
> +  if (strcmp (netif_get_state (netif)->devname, ifname) == 0)
> + break;
> +
> +  netif = netif->next;
> +}

Rather use a for loop:

  for (netif = netif_list; netif != 0; netif = netif->next)

that's much more trustable :)

> +/* Get some sockaddr type of info.  */
> +static kern_return_t
> +siocgifXaddr (struct sock_user *user,
> +   ifname_t ifnam, sockaddr_t * addr, enum siocgif_type type)
> +{
> +  error_t err = 0;
> +  struct sockaddr_in *sin = (struct sockaddr_in *) addr;
> +  struct netif *netif;

> +  size_t buflen = sizeof (struct sockaddr);
> +  uint32_t addrs[4];

> +  err = lwip_getsockname (user->sock->sockno, addr, (socklen_t *) & buflen);

Here, perhaps comment that we are only interested in checking the
address family, thus only sizeof (struct sockaddr)

> +/* 100 SIOCGIFINDEX -- Get index number of a network interface.  */
> +error_t
> +lwip_S_iioctl_siocgifindex (struct sock_user * user,
> + ifname_t ifnam,
> + int *index)
> +{
> +  error_t err = 0;
> +  struct netif *netif;
> +  int i;
> +
> +  if (!user)
> +return EOPNOTSUPP;
> +
> +  i = 1; /* The first index must be 1 */
> +  netif = netif_list;
> +  while (netif != 0)
> +{
> +  if (strcmp (netif_get_state (netif)->devname, ifnam) == 0)
> + {
> +   *index = i;
> +   break;
> + }
> +
> +  netif = netif->next;
> +  i++;

Similarly, it makes the reader more confident to read a for loop here.

> +/* 101 SIOCGIFNAME -- Get name of a network interface from index number.  */
> +error_t
> +lwip_S_iioctl_siocgifname (struct sock_user * user,
> +ifname_t ifnam,
> +int *index)
> +{

And there again :)

> diff --git a/lwip/io-ops.c b/lwip/io-ops.c
> new file mode 100644
> index ..2553ca33
> --- /dev/null
> +++ b/lwip/io-ops.c

> +error_t
> +lwip_S_io_write (struct sock_user * user,
> +  char *data,
> +  size_t datalen,
> +  off_t offset, mach_msg_type_number_t * amount)
> +{
...
> +  if (sockflags & O_NONBLOCK)
> +m.msg_flags |= MSG_DONTWAIT;
> +  sent = lwip_sendmsg (user->sock->sockno, , 0);

I'm wondering about thread-safety: I guess you enabled the unix arch to
get pthread mutex locks?

Also, why using lwip_sendmsg instead of just lwip_send? That'd avoid the
construction of m etc.
In the linuxish pfinet case, it's just because there is no recv method
:)

> +static error_t
> +lwip_io_select_common (struct sock_user *user,
> +mach_port_t reply,
> +mach_msg_type_name_t reply_type,
> +struct timeval *tv, int *select_type)
> +{
...
> +  timeout = tv ? tv->tv_sec * 1000 + tv->tv_usec / 1000 : -1;
> +  ret = lwip_poll (, nfds, timeout);

Better use lwip_ppoll to have better timeout resolution, and use struct
timespec instead of struct timeval.

> diff --git a/lwip/lwip-util.c b/lwip/lwip-util.c
> new file mode 100644
> index ..2996632e
> --- /dev/null
> +++ b/lwip/lwip-util.c

> +  /* Freed in the module terminate callback */
> +  ifc->devname = malloc (strlen (name) + 1);
> +  if (ifc->devname)
> +{
> +  memset (ifc->devname, 0, strlen (name) + 1);
> +  strncpy (ifc->devname, name, strlen (name));
> +}

Err, rather just use strdup (name)? :)


> +  if (addr6_prefix_len)
> + for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++)
> +   *(addr6_prefix_len + i) = 64;

Does lwip support only /64 IPv6 networks?

> --- /dev/null
> +++ b/lwip/main.c

> +#ifndef _GNU_SOURCE
> +#define _GNU_SOURCE
> +#endif

_GNU_SOURCE has to be defined *before* including headers. And we always
define _GNU_SOURCE while building hurd translators, this it *is* the GNU
system, so we use the GNU standard :)

> +error_t
> +trivfs_goaway (struct trivfs_control *fsys, int flags)
> +{
> +  exit (0);
> +}

The linuxish pfinet returns EBUSY if there are still sockets, it is a
useful thing to check.

> +  if (pi)
> +{
> +  ports_port_deref (pi);
> +
> +  mig_routine_t routine;
> +  if ((routine = lwip_io_server_routine (inp)) ||
> +   (routine = lwip_socket_server_routine (inp)) ||
> +   (routine = lwip_pfinet_server_routine (inp)) ||
> +   (routine = lwip_iioctl_server_routine (inp)) ||
> +   (routine = NULL, trivfs_demuxer (inp, outp)))

In the linuxish pfinet, the startup protocol is also used, to nicely
close net channels before exiting, that's a useful thing to do.

> diff --git a/lwip/options.c b/lwip/options.c
> new file mode 100644
> index ..b7b34fd8
> --- /dev/null
> +++ b/lwip/options.c
> @@ -0,0 +1,346 @@

> +case 'A':
> +  /* IPv6 address */
> +  if 

[PATCH] LwIP translator

2017-09-06 Thread Joan Lledó
---
 Makefile |   4 +
 config.make.in   |   7 +
 configure.ac |   5 +
 lwip/Makefile|  51 +++
 lwip/config.h|   5 +
 lwip/iioctl-ops.c| 418 
 lwip/io-ops.c| 560 +++
 lwip/lwip-hurd.h | 100 +
 lwip/lwip-util.c | 347 +
 lwip/lwip-util.h |  41 ++
 lwip/main.c  | 234 
 lwip/mig-decls.h |  68 
 lwip/mig-mutate.h|  44 +++
 lwip/options.c   | 346 +
 lwip/options.h   |  81 
 lwip/pfinet-ops.c| 119 ++
 lwip/port-objs.c | 143 +++
 lwip/port/include/netif/hurdethif.h  |  39 ++
 lwip/port/include/netif/hurdloopif.h |  36 ++
 lwip/port/include/netif/hurdtunif.h  |  65 
 lwip/port/include/netif/ifcommon.h   |  60 +++
 lwip/port/netif/hurdethif.c  | 574 
 lwip/port/netif/hurdloopif.c | 113 ++
 lwip/port/netif/hurdtunif.c  | 722 +++
 lwip/port/netif/ifcommon.c   | 121 ++
 lwip/socket-ops.c| 458 ++
 26 files changed, 4761 insertions(+)
 create mode 100644 lwip/Makefile
 create mode 100644 lwip/config.h
 create mode 100644 lwip/iioctl-ops.c
 create mode 100644 lwip/io-ops.c
 create mode 100644 lwip/lwip-hurd.h
 create mode 100644 lwip/lwip-util.c
 create mode 100644 lwip/lwip-util.h
 create mode 100644 lwip/main.c
 create mode 100644 lwip/mig-decls.h
 create mode 100644 lwip/mig-mutate.h
 create mode 100644 lwip/options.c
 create mode 100644 lwip/options.h
 create mode 100644 lwip/pfinet-ops.c
 create mode 100644 lwip/port-objs.c
 create mode 100644 lwip/port/include/netif/hurdethif.h
 create mode 100644 lwip/port/include/netif/hurdloopif.h
 create mode 100644 lwip/port/include/netif/hurdtunif.h
 create mode 100644 lwip/port/include/netif/ifcommon.h
 create mode 100644 lwip/port/netif/hurdethif.c
 create mode 100644 lwip/port/netif/hurdloopif.c
 create mode 100644 lwip/port/netif/hurdtunif.c
 create mode 100644 lwip/port/netif/ifcommon.c
 create mode 100644 lwip/socket-ops.c

diff --git a/Makefile b/Makefile
index 119f130b..2d9d3f80 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,10 @@ ifeq ($(HAVE_SUN_RPC),yes)
 prog-subdirs += nfs nfsd
 endif
 
+ifeq ($(HAVE_LIBLWIP),yes)
+prog-subdirs += lwip
+endif
+
 # Other directories
 other-subdirs = hurd doc config release include
 
diff --git a/config.make.in b/config.make.in
index dfbf0c10..7b62e851 100644
--- a/config.make.in
+++ b/config.make.in
@@ -99,6 +99,13 @@ HAVE_SUN_RPC = @HAVE_SUN_RPC@
 # Whether we found libgcrypt.
 HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
 
+# Whether we found liblwip.
+HAVE_LIBLWIP = @HAVE_LIBLWIP@
+
+# How to compile and link against liblwip.
+liblwip_CFLAGS = @liblwip_CFLAGS@
+liblwip_LIBS = @liblwip_LIBS@
+
 # Installation tools.
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/configure.ac b/configure.ac
index 54aa72b0..5abedf46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -344,6 +344,11 @@ AC_SUBST([libblkid_CFLAGS])
 AM_PATH_LIBGCRYPT("1:1.6.0",[HAVE_LIBGCRYPT=yes], [HAVE_LIBGCRYPT=no])
 AC_SUBST([HAVE_LIBGCRYPT])
 
+PKG_CHECK_MODULES([liblwip], [lwip], [HAVE_LIBLWIP=yes], [HAVE_LIBLWIP=no])
+AC_SUBST([HAVE_LIBLWIP])
+AC_SUBST([liblwip_CFLAGS])
+AC_SUBST([liblwip_LIBS])
+
 AC_CONFIG_FILES([config.make ${makefiles}])
 AC_OUTPUT
 
diff --git a/lwip/Makefile b/lwip/Makefile
new file mode 100644
index ..b4212500
--- /dev/null
+++ b/lwip/Makefile
@@ -0,0 +1,51 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+#   This file is part of the GNU Hurd.
+#
+#   The GNU Hurd is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2, or (at
+#   your option) any later version.
+#
+#   The GNU Hurd is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#   General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the GNU Hurd.  If not, see .
+
+dir= lwip
+makemode   = server
+
+PORTDIR = $(srcdir)/port
+
+SRCS   = main.c io-ops.c socket-ops.c pfinet-ops.c iioctl-ops.c 
port-objs.c \
+   options.c lwip-util.c
+IFSRCS = ifcommon.c hurdethif.c hurdloopif.c hurdtunif.c
+MIGSRCS= ioServer.c socketServer.c pfinetServer.c 
iioctlServer.c
+OBJS   = $(patsubst 

[PATCH] LwIP translator

2017-09-06 Thread Joan Lledó
This patch includes some refactoring in the device modules to remove
borrowed code from lwip.



[PATCH] LwIP translator

2017-08-30 Thread joanlluislledo
From: Joan Lledó 

---
 Makefile |   4 +
 config.make.in   |   7 +
 configure.ac |   5 +
 lwip/Makefile|  51 +++
 lwip/config.h|   5 +
 lwip/iioctl-ops.c| 418 
 lwip/io-ops.c| 560 ++
 lwip/lwip-hurd.h | 100 +
 lwip/lwip-util.c | 348 +
 lwip/lwip-util.h |  41 ++
 lwip/main.c  | 234 +++
 lwip/mig-decls.h |  68 
 lwip/mig-mutate.h|  44 +++
 lwip/options.c   | 346 +
 lwip/options.h   |  81 
 lwip/pfinet-ops.c| 119 ++
 lwip/port-objs.c | 143 +++
 lwip/port/include/netif/hurdethif.h  |  39 ++
 lwip/port/include/netif/hurdloopif.h |  36 ++
 lwip/port/include/netif/hurdtunif.h  |  65 
 lwip/port/include/netif/ifcommon.h   |  60 +++
 lwip/port/netif/hurdethif.c  | 688 
 lwip/port/netif/hurdloopif.c | 112 ++
 lwip/port/netif/hurdtunif.c  | 734 +++
 lwip/port/netif/ifcommon.c   | 121 ++
 lwip/socket-ops.c| 458 ++
 26 files changed, 4887 insertions(+)
 create mode 100644 lwip/Makefile
 create mode 100644 lwip/config.h
 create mode 100644 lwip/iioctl-ops.c
 create mode 100644 lwip/io-ops.c
 create mode 100644 lwip/lwip-hurd.h
 create mode 100644 lwip/lwip-util.c
 create mode 100644 lwip/lwip-util.h
 create mode 100644 lwip/main.c
 create mode 100644 lwip/mig-decls.h
 create mode 100644 lwip/mig-mutate.h
 create mode 100644 lwip/options.c
 create mode 100644 lwip/options.h
 create mode 100644 lwip/pfinet-ops.c
 create mode 100644 lwip/port-objs.c
 create mode 100644 lwip/port/include/netif/hurdethif.h
 create mode 100644 lwip/port/include/netif/hurdloopif.h
 create mode 100644 lwip/port/include/netif/hurdtunif.h
 create mode 100644 lwip/port/include/netif/ifcommon.h
 create mode 100644 lwip/port/netif/hurdethif.c
 create mode 100644 lwip/port/netif/hurdloopif.c
 create mode 100644 lwip/port/netif/hurdtunif.c
 create mode 100644 lwip/port/netif/ifcommon.c
 create mode 100644 lwip/socket-ops.c

diff --git a/Makefile b/Makefile
index 119f130b..2d9d3f80 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,10 @@ ifeq ($(HAVE_SUN_RPC),yes)
 prog-subdirs += nfs nfsd
 endif
 
+ifeq ($(HAVE_LIBLWIP),yes)
+prog-subdirs += lwip
+endif
+
 # Other directories
 other-subdirs = hurd doc config release include
 
diff --git a/config.make.in b/config.make.in
index dfbf0c10..7b62e851 100644
--- a/config.make.in
+++ b/config.make.in
@@ -99,6 +99,13 @@ HAVE_SUN_RPC = @HAVE_SUN_RPC@
 # Whether we found libgcrypt.
 HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
 
+# Whether we found liblwip.
+HAVE_LIBLWIP = @HAVE_LIBLWIP@
+
+# How to compile and link against liblwip.
+liblwip_CFLAGS = @liblwip_CFLAGS@
+liblwip_LIBS = @liblwip_LIBS@
+
 # Installation tools.
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/configure.ac b/configure.ac
index 54aa72b0..5abedf46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -344,6 +344,11 @@ AC_SUBST([libblkid_CFLAGS])
 AM_PATH_LIBGCRYPT("1:1.6.0",[HAVE_LIBGCRYPT=yes], [HAVE_LIBGCRYPT=no])
 AC_SUBST([HAVE_LIBGCRYPT])
 
+PKG_CHECK_MODULES([liblwip], [lwip], [HAVE_LIBLWIP=yes], [HAVE_LIBLWIP=no])
+AC_SUBST([HAVE_LIBLWIP])
+AC_SUBST([liblwip_CFLAGS])
+AC_SUBST([liblwip_LIBS])
+
 AC_CONFIG_FILES([config.make ${makefiles}])
 AC_OUTPUT
 
diff --git a/lwip/Makefile b/lwip/Makefile
new file mode 100644
index ..b4212500
--- /dev/null
+++ b/lwip/Makefile
@@ -0,0 +1,51 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+#   This file is part of the GNU Hurd.
+#
+#   The GNU Hurd is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2, or (at
+#   your option) any later version.
+#
+#   The GNU Hurd is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#   General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the GNU Hurd.  If not, see .
+
+dir= lwip
+makemode   = server
+
+PORTDIR = $(srcdir)/port
+
+SRCS   = main.c io-ops.c socket-ops.c pfinet-ops.c iioctl-ops.c 
port-objs.c \
+   options.c lwip-util.c
+IFSRCS = ifcommon.c hurdethif.c hurdloopif.c hurdtunif.c
+MIGSRCS= ioServer.c socketServer.c pfinetServer.c 

[PATCH] LwIP translator

2017-08-30 Thread joanlluislledo
This patch incorporates Justus changes in the lwip Makefile



Re: [PATCH] LwIP translator

2017-08-25 Thread Joan Lledó
>> # Whether we found libgcrypt.
>> HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
>>
>> +# Whether we found libgcrypt.
>
> Copy-paste error :)
>

Ops!, yes... you've got a sharp eye!



Re: [PATCH] LwIP translator

2017-08-24 Thread James Clarke
Hi Joan,

On 24 Aug 2017, at 18:49, Joan Lledó  wrote:
> ...
> diff --git a/config.make.in b/config.make.in
> index dfbf0c1..f74220e 100644
> --- a/config.make.in
> +++ b/config.make.in
> @@ -99,6 +99,13 @@ HAVE_SUN_RPC = @HAVE_SUN_RPC@
> # Whether we found libgcrypt.
> HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
> 
> +# Whether we found libgcrypt.

Copy-paste error :)

James




[PATCH] LwIP translator

2017-08-24 Thread Joan Lledó
---
 Makefile |   4 +
 config.make.in   |   7 +
 configure.ac |   5 +
 lwip/Makefile|  51 +++
 lwip/config.h|   5 +
 lwip/iioctl-ops.c| 418 
 lwip/io-ops.c| 560 ++
 lwip/lwip-hurd.h | 100 +
 lwip/lwip-util.c | 348 +
 lwip/lwip-util.h |  41 ++
 lwip/main.c  | 234 +++
 lwip/mig-decls.h |  68 
 lwip/mig-mutate.h|  44 +++
 lwip/options.c   | 346 +
 lwip/options.h   |  81 
 lwip/pfinet-ops.c| 119 ++
 lwip/port-objs.c | 143 +++
 lwip/port/include/netif/hurdethif.h  |  39 ++
 lwip/port/include/netif/hurdloopif.h |  36 ++
 lwip/port/include/netif/hurdtunif.h  |  65 
 lwip/port/include/netif/ifcommon.h   |  60 +++
 lwip/port/netif/hurdethif.c  | 688 
 lwip/port/netif/hurdloopif.c | 112 ++
 lwip/port/netif/hurdtunif.c  | 734 +++
 lwip/port/netif/ifcommon.c   | 121 ++
 lwip/socket-ops.c| 458 ++
 26 files changed, 4887 insertions(+)
 create mode 100644 lwip/Makefile
 create mode 100644 lwip/config.h
 create mode 100644 lwip/iioctl-ops.c
 create mode 100644 lwip/io-ops.c
 create mode 100644 lwip/lwip-hurd.h
 create mode 100644 lwip/lwip-util.c
 create mode 100644 lwip/lwip-util.h
 create mode 100644 lwip/main.c
 create mode 100644 lwip/mig-decls.h
 create mode 100644 lwip/mig-mutate.h
 create mode 100644 lwip/options.c
 create mode 100644 lwip/options.h
 create mode 100644 lwip/pfinet-ops.c
 create mode 100644 lwip/port-objs.c
 create mode 100644 lwip/port/include/netif/hurdethif.h
 create mode 100644 lwip/port/include/netif/hurdloopif.h
 create mode 100644 lwip/port/include/netif/hurdtunif.h
 create mode 100644 lwip/port/include/netif/ifcommon.h
 create mode 100644 lwip/port/netif/hurdethif.c
 create mode 100644 lwip/port/netif/hurdloopif.c
 create mode 100644 lwip/port/netif/hurdtunif.c
 create mode 100644 lwip/port/netif/ifcommon.c
 create mode 100644 lwip/socket-ops.c

diff --git a/Makefile b/Makefile
index 119f130..2d9d3f8 100644
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,10 @@ ifeq ($(HAVE_SUN_RPC),yes)
 prog-subdirs += nfs nfsd
 endif
 
+ifeq ($(HAVE_LIBLWIP),yes)
+prog-subdirs += lwip
+endif
+
 # Other directories
 other-subdirs = hurd doc config release include
 
diff --git a/config.make.in b/config.make.in
index dfbf0c1..f74220e 100644
--- a/config.make.in
+++ b/config.make.in
@@ -99,6 +99,13 @@ HAVE_SUN_RPC = @HAVE_SUN_RPC@
 # Whether we found libgcrypt.
 HAVE_LIBGCRYPT = @HAVE_LIBGCRYPT@
 
+# Whether we found libgcrypt.
+HAVE_LIBLWIP = @HAVE_LIBLWIP@
+
+# How to compile and link against liblwip.
+liblwip_CFLAGS = @liblwip_CFLAGS@
+liblwip_LIBS = @liblwip_LIBS@
+
 # Installation tools.
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/configure.ac b/configure.ac
index 54aa72b..5abedf4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -344,6 +344,11 @@ AC_SUBST([libblkid_CFLAGS])
 AM_PATH_LIBGCRYPT("1:1.6.0",[HAVE_LIBGCRYPT=yes], [HAVE_LIBGCRYPT=no])
 AC_SUBST([HAVE_LIBGCRYPT])
 
+PKG_CHECK_MODULES([liblwip], [lwip], [HAVE_LIBLWIP=yes], [HAVE_LIBLWIP=no])
+AC_SUBST([HAVE_LIBLWIP])
+AC_SUBST([liblwip_CFLAGS])
+AC_SUBST([liblwip_LIBS])
+
 AC_CONFIG_FILES([config.make ${makefiles}])
 AC_OUTPUT
 
diff --git a/lwip/Makefile b/lwip/Makefile
new file mode 100644
index 000..e9289b5
--- /dev/null
+++ b/lwip/Makefile
@@ -0,0 +1,51 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+#   This file is part of the GNU Hurd.
+#
+#   The GNU Hurd is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2, or (at
+#   your option) any later version.
+#
+#   The GNU Hurd is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#   General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the GNU Hurd.  If not, see .
+
+dir= lwip
+makemode   = server
+
+PORTDIR = $(srcdir)/port
+
+SRCS   = main.c io-ops.c socket-ops.c pfinet-ops.c iioctl-ops.c 
port-objs.c \
+   options.c lwip-util.c
+IFSRCS = ifcommon.c hurdethif.c hurdloopif.c hurdtunif.c
+MIGSRCS= ioServer.c socketServer.c pfinetServer.c 
iioctlServer.c
+OBJS   = $(patsubst %.S,%.o,$(patsubst 

[PATCH] LwIP translator

2017-08-24 Thread Joan Lledó
I made some changes to conditionally build the lwip translator depending on
whether liblwip is installed.



[PATCH] LwIP translator

2017-08-23 Thread Joan Lledó
---
 Makefile |   1 +
 lwip/Makefile|  51 +++
 lwip/config.h|   5 +
 lwip/iioctl-ops.c| 418 
 lwip/io-ops.c| 560 ++
 lwip/lwip-hurd.h | 100 +
 lwip/lwip-util.c | 348 +
 lwip/lwip-util.h |  41 ++
 lwip/main.c  | 234 +++
 lwip/mig-decls.h |  68 
 lwip/mig-mutate.h|  44 +++
 lwip/options.c   | 346 +
 lwip/options.h   |  81 
 lwip/pfinet-ops.c| 119 ++
 lwip/port-objs.c | 143 +++
 lwip/port/include/netif/hurdethif.h  |  39 ++
 lwip/port/include/netif/hurdloopif.h |  36 ++
 lwip/port/include/netif/hurdtunif.h  |  65 
 lwip/port/include/netif/ifcommon.h   |  60 +++
 lwip/port/netif/hurdethif.c  | 688 
 lwip/port/netif/hurdloopif.c | 112 ++
 lwip/port/netif/hurdtunif.c  | 734 +++
 lwip/port/netif/ifcommon.c   | 121 ++
 lwip/socket-ops.c| 458 ++
 24 files changed, 4872 insertions(+)
 create mode 100644 lwip/Makefile
 create mode 100644 lwip/config.h
 create mode 100644 lwip/iioctl-ops.c
 create mode 100644 lwip/io-ops.c
 create mode 100644 lwip/lwip-hurd.h
 create mode 100644 lwip/lwip-util.c
 create mode 100644 lwip/lwip-util.h
 create mode 100644 lwip/main.c
 create mode 100644 lwip/mig-decls.h
 create mode 100644 lwip/mig-mutate.h
 create mode 100644 lwip/options.c
 create mode 100644 lwip/options.h
 create mode 100644 lwip/pfinet-ops.c
 create mode 100644 lwip/port-objs.c
 create mode 100644 lwip/port/include/netif/hurdethif.h
 create mode 100644 lwip/port/include/netif/hurdloopif.h
 create mode 100644 lwip/port/include/netif/hurdtunif.h
 create mode 100644 lwip/port/include/netif/ifcommon.h
 create mode 100644 lwip/port/netif/hurdethif.c
 create mode 100644 lwip/port/netif/hurdloopif.c
 create mode 100644 lwip/port/netif/hurdtunif.c
 create mode 100644 lwip/port/netif/ifcommon.c
 create mode 100644 lwip/socket-ops.c

diff --git a/Makefile b/Makefile
index 119f130..b2ab209 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,7 @@ prog-subdirs = auth proc exec term \
   init \
   devnode \
   eth-multiplexer \
+  lwip \
 
 ifeq ($(HAVE_SUN_RPC),yes)
 prog-subdirs += nfs nfsd
diff --git a/lwip/Makefile b/lwip/Makefile
new file mode 100644
index 000..e9289b5
--- /dev/null
+++ b/lwip/Makefile
@@ -0,0 +1,51 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+#
+#   This file is part of the GNU Hurd.
+#
+#   The GNU Hurd is free software; you can redistribute it and/or
+#   modify it under the terms of the GNU General Public License as
+#   published by the Free Software Foundation; either version 2, or (at
+#   your option) any later version.
+#
+#   The GNU Hurd is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#   General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with the GNU Hurd.  If not, see .
+
+dir= lwip
+makemode   = server
+
+PORTDIR = $(srcdir)/port
+
+SRCS   = main.c io-ops.c socket-ops.c pfinet-ops.c iioctl-ops.c 
port-objs.c \
+   options.c lwip-util.c
+IFSRCS = ifcommon.c hurdethif.c hurdloopif.c hurdtunif.c
+MIGSRCS= ioServer.c socketServer.c pfinetServer.c 
iioctlServer.c
+OBJS   = $(patsubst %.S,%.o,$(patsubst %.c,%.o,\
+   $(SRCS) $(IFSRCS) $(MIGSRCS)))
+
+HURDLIBS= trivfs fshelp ports ihash shouldbeinlibc iohelp
+LDLIBS = -lpthread -llwip
+
+target = lwip
+
+include ../Makeconf
+
+vpath %.c $(PORTDIR) \
+   $(PORTDIR)/netif
+
+CFLAGS += -I$(PORTDIR)/include -I$(includedir)/lwip
+
+CPPFLAGS += -imacros $(srcdir)/config.h
+MIGCOMSFLAGS += -prefix lwip_
+mig-sheader-prefix = lwip_
+io-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
+socket-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
+iioctl-MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
+
+# cpp doesn't automatically make dependencies for -imacros dependencies. argh.
+lwip_io_S.h ioServer.c lwip_socket_S.h socketServer.c: mig-mutate.h
+$(OBJS): config.h
diff --git a/lwip/config.h b/lwip/config.h
new file mode 100644
index 000..b0d5196
--- /dev/null
+++ b/lwip/config.h
@@ -0,0 +1,5 @@
+#define __KERNEL__ 1
+#undef __SMP__
+
+#define _HURD_ 1
+
diff --git a/lwip/iioctl-ops.c b/lwip/iioctl-ops.c
new file mode 100644
index 000..c7b641f
--- /dev/null
+++ 

[PATCH] LwIP translator

2017-08-23 Thread Joan Lledó
Hello,

This is the LwIP translator I wrote during my GSoC. The translator uses LwIP
as a regular library and therefore the stack sources are not included in the
patch.

The lwip external libary may be downloaded from [1] or cloned from [2].

Regards,

Joan

--
[1] http://darnassus.sceen.net/~jlledom/download/liblwip-2.0.1.tar.gz
[2] https://github.com/jlledom/liblwip-hurd.git