Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2003-11

ipv6 patch

4 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Johannes Berg

Hi,

Here's a patch to add some IPv6 definitions, I stole them from RFC 2553 :-)

Index: inc/socketsh.inc
=================================================================== RCS file: /FPC/CVS/fpc/rtl/inc/socketsh.inc,v
retrieving revision 1.9
diff -u -r1.9 socketsh.inc
--- inc/socketsh.inc 23 Mar 2003 17:47:15 -0000 1.9 +++ inc/socketsh.inc 9 Nov 2003 18:45:56 -0000
@@ -119,11 +119,37 @@

     end;
   TInetSockAddr = packed Record
-    family:Word;
+    {$ifdef BSD}  // as per RFC 2553
+      len   : byte;
+      family: byte;
+    {$ELSE}
+      family: word;
+    {$ENDIF}
     port  :Word;
     addr  :Cardinal;
     pad   :array [1..8] of byte; { to get to the size of sockaddr... }
-    end;
+  end;
+
+  Tin6_addr = packed record
+  case byte of
+    0: (u6_addr8  : array[0..15] of byte);
+    1: (u6_addr16 : array[0..7] of Word);
+    2: (u6_addr32 : array[0..3] of Cardinal);
+    3: (s6_addr8  : array[0..15] of shortint);
+    4: (s6_addr   : array[0..15] of shortint);
+    5: (s6_addr16 : array[0..7] of smallint);
+    6: (s6_addr32 : array[0..3] of LongInt);
+  end;
+
+  TInetSockAddr6 = packed Record
+    sin6_family   : Word;
+    sin6_port     : Word;
+    sin6_flowinfo : LongInt;
+    sin6_addr     : Tin6_addr;
+    sin6_scope_id : LongInt;
+  end;
+  sockaddr_in6 = TInetSockAddr6;
+  psockaddr_in6 = ^sockaddr_in6;
   TSockArray = Array[1..2] of Longint;

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Johannes Berg
to Johannes Berg
Johannes Berg wrote
Here's a patch to add some IPv6 definitions, I stole them from RFC 2553 :-)

Whoops, I messed with the wrong structure here trying to adapt for BSD, this looks better:

Index: inc/socketsh.inc
===================================================================
RCS file: /FPC/CVS/fpc/rtl/inc/socketsh.inc,v
retrieving revision 1.9
diff -u -r1.9 socketsh.inc
--- inc/socketsh.inc	23 Mar 2003 17:47:15 -0000	1.9
+++ inc/socketsh.inc	9 Nov 2003 18:53:25 -0000
@@ -123,7 +123,33 @@
     port  :Word;
     addr  :Cardinal;
     pad   :array [1..8] of byte; { to get to the size of sockaddr... }
-    end;
+  end;
+
+  Tin6_addr = packed record
+  case byte of
+    0: (u6_addr8  : array[0..15] of byte);
+    1: (u6_addr16 : array[0..7] of Word);
+    2: (u6_addr32 : array[0..3] of Cardinal);
+    3: (s6_addr8  : array[0..15] of shortint);
+    4: (s6_addr   : array[0..15] of shortint);
+    5: (s6_addr16 : array[0..7] of smallint);
+    6: (s6_addr32 : array[0..3] of LongInt);
+  end;
+
+  TInetSockAddr6 = packed Record
+    {$ifdef BSD}  // as per RFC 2553
+      sin6_len   : byte;
+      sin6_family: byte;
+    {$ELSE}
+      sin6_family: word;
+    {$ENDIF}
+    sin6_port     : Word;
+    sin6_flowinfo : LongInt;
+    sin6_addr     : Tin6_addr;
+    sin6_scope_id : LongInt;
+  end;
+  sockaddr_in6 = TInetSockAddr6;
+  psockaddr_in6 = ^sockaddr_in6;
   TSockArray = Array[1..2] of Longint;

I still have to test this, so take with big grains of salt ;)

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Johannes Berg
to Johannes Berg
Johannes Berg wrote 5 lines
On Sun, 2003-11-09 at 19:46, Johannes Berg wrote: > Here's a patch to add some IPv6 definitions, I stole them from RFC 2553 > :-) I still have to test this, so take with big grains of salt ;)

Works as far as I can determine from making a connection with my local ftp server running on ipv6 and sending/reading data.

Sock2Text doesn't seem to work though, not sure why. However, using API calls with my structures works -- would you consider to apply it (knocking another local patch off my list)? Or is anything wrong with it that I should fix first?

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email

Johannes Berg
to Johannes Berg
Johannes Berg wrote
Works as far as I can determine from making a connection with my local ftp server running on ipv6 and sending/reading data.

See attached test program, very crude and you need a ftp server running on a ipv6 capable machine at ::1.

Sock2Text doesn't seem to work though, not sure why. However, using API calls with my structures works -- would you consider to apply it (knocking another local patch off my list)? Or is anything wrong with it that I should fix first?

Fixed, please apply patch, see bug 2800.

johannes

http://www.sipsolutions.de/ GnuPG key: http://www.sipsolutions.de/keys/JohannesBerg.asc Key-ID: 9AB78CA5 Johannes Berg Fingerprint = AD02 0176 4E29 C137 1DF6 08D2 FC44 CF86 9AB7 8CA5

Reply by email