bug-inetutils
[Top][All Lists]
Advanced

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

[bug-inetutils] [PATCH] src/tftp.c: Implementing IPv6 support.


From: Mats Erik Andersson
Subject: [bug-inetutils] [PATCH] src/tftp.c: Implementing IPv6 support.
Date: Fri, 17 Sep 2010 19:13:16 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hello all,

the present patch is a continuation of [1] and is also a completion
of the task to implement IPv6 support for the TFTP server and client
in GNU Inetutils.

Taken together, the present patch and the patch contained in [1]
obsolete the suggestions presented in [2]. The changes are fully
inspired by the efforts to resolve the very keen observations put
forward by Guillem Jover in [3].

The only dependency between [1] and the present patch is the
elementary change to use a representation "struct sockaddr_storage"
in "libinetutils/tftpsubs.c" (synchnet). No other additions
to "libinetutils" are necessary, in contrast to the code in [2].


As I have been forced into more substantial changes of the inner
functionality in "src/tftp.c", I should shed some light on the
reasons, since they are by no mean obvious.

The major obstacle is that the client must keep records of two ports:
the server listening port (usually tftp/udp, i.e., 69), and any random
TID port that the server care to allocate for actual payload.

In the old implementation this was achieved by a repeated need for
manipulating the port in a recorded "struct sockaddr_in peeraddr".
I blindly kept that mechanism in the first effort [2].

The rewritten code now reserves the recorded structure

   static struct sockaddr_storage peeraddr

for tracking the remote listening socket address. This address is then
copied at the beginning of every get/put to

   static struct sockaddr_storage from

in order to send the initial RRQ message. Since the response from
the server is detected in

   recvfrom( ..., &from, ...)

the correct TID port is made accessible without destroying "peeraddr".
It is important to have nak() respond at this TID, thus using "from".
This motivates the upgrading of the local variable "from" in recvfile()
and send_file() into now being static of file scope.

In the process some improved tracking of "peeraddrlen" and "fromlen"
copes with the need in BSD of exact sizes in select system calls.


The parsing of arguments of the form "host:file", demanding the possibility
to use numerical IPv6 addresses for the host part, made it necessary to
look for the rightmost ':' in such combined arguments, thus the migration
to strrchr(3) in two instances.

The remaining changes ought to be more or less obvious.


Best regards,
Mats E A
   

[1] http://lists.gnu.org/archive/html/bug-inetutils/2010-09/msg00026.html
[2] http://lists.gnu.org/archive/html/bug-inetutils/2010-08/msg00083.html
[3] http://lists.gnu.org/archive/html/bug-inetutils/2010-09/msg00006.html

Attachment: 0001-src-tftp.c-Migration-to-IPv6-supporting-code.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

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