Forráskód Böngészése

Merged revisions 4625,4646,4650 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/trunk

........
r4625 | Almindor | 2006-09-16 12:40:32 +0200 (za, 16 sep 2006) | 2 lines

* sockets cleanup from Aison
........
r4646 | Almindor | 2006-09-18 22:56:13 +0200 (ma, 18 sep 2006) | 2 lines

* moves MSG_* constants from socketsh.inc to platform specific unxsockh.inc and fixes them for freebsd/darwin and solaris (linux ones were used before, not right)
........
r4650 | Almindor | 2006-09-19 12:22:13 +0200 (di, 19 sep 2006) | 2 lines

* fixes MSG_* for darwin
........

git-svn-id: branches/fixes_2_0@4677 -

micha 19 éve
szülő
commit
0bf55c8015
4 módosított fájl, 137 hozzáadás és 59 törlés
  1. 24 0
      rtl/darwin/unxsockh.inc
  2. 20 0
      rtl/freebsd/unxsockh.inc
  3. 68 59
      rtl/inc/socketsh.inc
  4. 25 0
      rtl/linux/unxsockh.inc

+ 24 - 0
rtl/darwin/unxsockh.inc

@@ -37,6 +37,10 @@ Const
 
   PF_MAX          = AF_MAX;
 
+
+{ Maximum queue length specifiable by listen.  }
+  SOMAXCONN     = 128;
+
         SOL_SOCKET = $FFFF;
         SO_DEBUG         =$0001;        { turn on debugging info recording }
         SO_ACCEPTCONN    =$0002;        { socket has had listen() }
@@ -218,3 +222,23 @@ Const
       	IP_MULTICAST_LOOP	= 11;   { u_char; set/get IP multicast loopback }
       	IP_ADD_MEMBERSHIP	= 12;   { ip_mreq; add an IP group membership }
       	IP_DROP_MEMBERSHIP	= 13;   { ip_mreq; drop an IP group membership }
+
+  { Flags for send, recv etc. }
+  MSG_OOB        = $0001;              { Process out-of-band data}
+  MSG_PEEK       = $0002;              { Peek at incoming messages }
+  MSG_DONTROUTE  = $0004;              { Don't use local routing }
+  MSG_EOR        = $0008;              { End of record }
+  MSG_TRUNC      = $0010;
+  MSG_CTRUNC     = $0020;              { Control data lost before delivery }
+  MSG_WAITALL    = $0040;              { Wait for a full request }
+  MSG_DONTWAIT   = $0080;              { Non-blocking I/O }
+  MSG_EOF        = $0100;
+  MSG_WAITSTREAM = $0200;	             { wait up to full request.. may return partial }
+  MSG_FLUSH 	   = $0400;              { Start of 'hold' seq; dump so_temp }
+  MSG_HOLD       = $0800;              { Hold frag in so_temp }
+  MSG_SEND       = $1000;              { Send the packet in so_temp }
+  MSG_HAVEMORE   = $2000;              { Data ready to be read }
+  MSG_RCVMORE    = $4000;              { Data remains in current pkt }
+  MSG_COMPAT     = $8000;              { used in sendit() }
+  MSG_NEEDSA     = $10000;             { Fail receive if socket address cannot be allocated }
+

+ 20 - 0
rtl/freebsd/unxsockh.inc

@@ -37,6 +37,10 @@ Const
 
   PF_MAX          = AF_MAX;
 
+
+{ Maximum queue length specifiable by listen.  }
+  SOMAXCONN     = 128;
+
         SOL_SOCKET 	 = $FFFF;
         SO_DEBUG         = $0001;        { turn on debugging info recording }
         SO_ACCEPTCONN    = $0002;        { socket has had listen() }
@@ -251,3 +255,19 @@ Const
  	IPV6_DSTOPTS            = 50; { ip6_dest; send dst option befor rthdr }
  	IPV6_RTHDR              = 51; { ip6_rthdr; send routing header }
  	IPV6_PKTOPTIONS         = 52; { buf/cmsghdr; set/get IPv6 options }
+  
+  { Flags for send, recv etc. }
+  MSG_OOB       = $0001;              { Process out-of-band data}
+  MSG_PEEK      = $0002;              { Peek at incoming messages }
+  MSG_DONTROUTE = $0004;              { Don't use local routing }
+  MSG_EOR       = $0008;              { End of record }
+  MSG_TRUNC     = $0010;
+  MSG_CTRUNC    = $0020;              { Control data lost before delivery }
+  MSG_WAITALL   = $0040;              { Wait for a full request }
+  MSG_DONTWAIT  = $0080;              { Non-blocking I/O }
+  MSG_EOF       = $0100;
+  MSG_NBIO      = $4000;
+  MSG_COMPAT    = $8000;
+  MSG_SOCALLBCK = $10000;
+  MSG_NOSIGNAL  = $20000;              { Do not generate SIGPIPE }
+

+ 68 - 59
rtl/inc/socketsh.inc

@@ -13,20 +13,28 @@
 
 {$INLINE ON}
 
-Type
+type
 {$ifdef SOCK_HAS_SINLEN}
-    sa_family_t=cuchar;
+  sa_family_t = cuchar;
 {$else}
-    sa_family_t=cushort;
+  sa_family_t = cushort;
 {$endif}
 
-Const
+const
   { Socket types }
+{$ifdef sunos}
+  SOCK_STREAM     = 2;               { stream socket }
+  SOCK_DGRAM      = 1;               { datagram socket }
+  SOCK_RAW        = 4;               { raw-protocol interface }
+  SOCK_RDM        = 5;               { reliably-delivered message }
+  SOCK_SEQPACKET  = 6;               { sequenced packet stream }
+{$else}
   SOCK_STREAM     = 1;               { stream (connection) socket   }
   SOCK_DGRAM      = 2;               { datagram (conn.less) socket  }
   SOCK_RAW        = 3;               { raw socket                   }
   SOCK_RDM        = 4;               { reliably-delivered message   }
   SOCK_SEQPACKET  = 5;               { sequential packet socket     }
+{$endif}
 
   { Protocol families }
   PF_UNSPEC    = 0;                  { Unspecified }
@@ -35,6 +43,7 @@ Const
   PF_FILE      = PF_LOCAL;           { Another non-standard name for PF_LOCAL }
   PF_INET      = 2;                  { IP protocol family }
 
+
   { Address families }
   AF_UNSPEC    = PF_UNSPEC;
   AF_LOCAL     = PF_LOCAL;
@@ -42,25 +51,6 @@ Const
   AF_FILE      = PF_FILE;
   AF_INET      = PF_INET;
 
-  { Flags for send, recv etc. }
-  MSG_OOB      = $0001;              { Process out-of-band data}
-  MSG_PEEK     = $0002;              { Peek at incoming messages }
-  MSG_DONTROUTE= $0004;              { Don't use local routing }
-  MSG_TRYHARD  = MSG_DONTROUTE;
-  MSG_CTRUNC   = $0008;              { Control data lost before delivery }
-  MSG_PROXY    = $0010;              { Supply or ask second address }
-  MSG_TRUNC    = $0020;
-  MSG_DONTWAIT = $0040;              { Non-blocking I/O }
-  MSG_EOR      = $0080;              { End of record }
-  MSG_WAITALL  = $0100;              { Wait for a full request }
-  MSG_FIN      = $0200;
-  MSG_SYN      = $0400;
-  MSG_CONFIRM  = $0800;              { Confirm path validity }
-  MSG_RST      = $1000;
-  MSG_ERRQUERE = $2000;              { Fetch message from error queue }
-  MSG_NOSIGNAL = $4000;              { Do not generate SIGPIPE }
-  MSG_MORE     = $8000;              { Sender will send more }
-
   INADDR_ANY   = CARDINAL(0);
   INADDR_NONE  = CARDINAL($FFFFFFFF);
 
@@ -69,36 +59,24 @@ const
   S_IN = 0;
   S_OUT = 1;
 
-Type
+type
+  pin_addr = ^in_addr;
   in_addr = packed record
-             case boolean of   		
-             true: (s_addr  : cuint32);         // inaddr_t=cuint32
-	     false: (s_bytes : packed array[1..4] of byte);
-            end;
+    case boolean of
+       true: (s_addr  : cuint32);         // inaddr_t=cuint32
+       false: (s_bytes : packed array[1..4] of byte);
+  end;
 
   TIn_addr = in_addr;
-  pin_addr = ^in_addr;
-  TInAddr       =  in_addr;
-
-  in_addrbytes = packed array [1..4] of byte;
 
-  TSockAddr = packed Record // if sa_len is defined, sa_family_t is smaller
-  {$ifdef SOCK_HAS_SINLEN}
-     sa_len     : cuchar;
-  {$endif}
-    case integer of
-      0: (sa_family: sa_family_t;
-          sa_data: packed array[0..13] of Byte);
-      1: (sin_family: sa_family_t;
-          sin_port: cushort;
-          sin_addr: in_addr;
-          sin_zero: packed array[0..7] of Byte);
-      end;
+  TInAddr = in_addr;
+  PInAddr = pin_addr;
 
-  PSockAddr = ^TSockAddr;
-  Sockaddr  = TSockAddr;                // Kylix compat
+  {pin_addrbytes = ^in_addrbytes;
+  in_addrbytes = packed array [1..4] of byte;}
 
-  TInetSockAddr = packed Record
+  psockaddr_in = ^sockaddr_in;
+  sockaddr_in = packed record
     case boolean of
      false : (
   {$ifdef SOCK_HAS_SINLEN}
@@ -118,10 +96,37 @@ Type
      addr    : cardinal;
      pad         : array [0..7] of char; { to get to the size of sockaddr... }
       );
-    end;
-  pInetSockAddr = ^TInetSockAddr;
+  end;
+
+  TInetSockAddr = sockaddr_in;
+  PInetSockAddr = psockaddr_in;
 
-  Tin6_addr = packed record
+  psockaddr = ^sockaddr;
+  sockaddr = packed record // if sa_len is defined, sa_family_t is smaller
+  {$ifdef SOCK_HAS_SINLEN}
+     sa_len     : cuchar;
+  {$endif}
+    case integer of
+      0: (sa_family: sa_family_t;
+          sa_data: packed array[0..13] of cuint8);
+      1: (sin_family: sa_family_t;
+          sin_port: cushort;
+          sin_addr: in_addr;
+          sin_zero: packed array[0..7] of cuint8);
+  end;
+
+  TSockAddr = sockaddr;
+
+  plinger = ^linger;
+  linger = packed record
+    l_onoff  : cint;	(* Linger active		*)
+    l_linger : cint;	(* How long to linger for	*)
+  end;
+
+  TLinger = linger;
+
+  pin6_addr = ^in6_addr;
+  in6_addr = packed record
   case byte of
     0: (u6_addr8  : array[0..15] of byte);
     1: (u6_addr16 : array[0..7] of Word);
@@ -131,22 +136,26 @@ Type
     5: (s6_addr16 : array[0..7] of smallint);
     6: (s6_addr32 : array[0..3] of LongInt);
   end;
-  pIn6_Addr=^TIn6_addr;
 
-  TInetSockAddr6 = packed Record
+  Tin6_addr = in6_addr;
+
+  TIn6Addr = in6_addr;
+  PIn6Addr = pin6_addr;
+
+  psockaddr_in6 = ^sockaddr_in6;
+  sockaddr_in6 = packed Record
     {$ifdef SOCK_HAS_SINLEN}  // as per RFC 2553
-      sin6_len    : byte;
+      sin6_len    : cuint8;
     {$endif}
     sin6_family   : sa_family_t;
     sin6_port     : cuint16;
     sin6_flowinfo : cuint32;
-    sin6_addr     : Tin6_addr;
+    sin6_addr     : in6_addr;
     sin6_scope_id : cuint32;
   end;
 
-  sockaddr_in6 = TInetSockAddr6;
-
-  psockaddr_in6 = ^sockaddr_in6;
+  TInetSockAddr6 = sockaddr_in6;
+  PInetSockAddr6 = psockaddr_in6;
 
   TSockPairArray = Array[0..1] of Longint;
   TSockArray     = Array[1..2] of Longint;              //legacy
@@ -230,6 +239,6 @@ function StrToNetAddr6 (IP   : AnsiString) : TIn6_Addr;
 CONST
 	NoAddress : in_addr  = (s_addr:0);
 	NoNet     : in_addr  = (s_addr:0);
- 	NoAddress6: Tin6_addr = (u6_addr16:(0,0,0,0,0,0,0,0));
-  	NoNet6    : Tin6_addr = (u6_addr16:(0,0,0,0,0,0,0,0));
+ 	NoAddress6: in6_addr = (u6_addr16:(0,0,0,0,0,0,0,0));
+  	NoNet6    : in6_addr = (u6_addr16:(0,0,0,0,0,0,0,0));
 

+ 25 - 0
rtl/linux/unxsockh.inc

@@ -88,6 +88,10 @@ Const
   PF_NETGRAPH     =AF_NETGRAPH;
   PF_MAX          =AF_MAX;
 
+
+{ Maximum queue length specifiable by listen.  }
+  SOMAXCONN     = 128;
+
 { For setsockoptions(2) }
          SOL_SOCKET  =   1;
          SO_DEBUG    =   1;
@@ -282,3 +286,24 @@ Const
         IPV6_RTHDR_STRICT     = 1;    { Hop must be a neighbour.  }
 
         IPV6_RTHDR_TYPE_0        = 0;    { IPv6 Routing header type 0.  }
+        
+  { Flags for send, recv etc. }
+  MSG_OOB      = $0001;              { Process out-of-band data}
+  MSG_PEEK     = $0002;              { Peek at incoming messages }
+  MSG_DONTROUTE= $0004;              { Don't use local routing }
+  MSG_TRYHARD  = MSG_DONTROUTE;
+  MSG_CTRUNC   = $0008;              { Control data lost before delivery }
+  MSG_PROXY    = $0010;              { Supply or ask second address }
+  MSG_TRUNC    = $0020;
+  MSG_DONTWAIT = $0040;              { Non-blocking I/O }
+  MSG_EOR      = $0080;              { End of record }
+  MSG_WAITALL  = $0100;              { Wait for a full request }
+  MSG_FIN      = $0200;
+  MSG_SYN      = $0400;
+  MSG_CONFIRM  = $0800;              { Confirm path validity }
+  MSG_RST      = $1000;
+  MSG_ERRQUERE = $2000;              { Fetch message from error queue }
+  MSG_NOSIGNAL = $4000;              { Do not generate SIGPIPE }
+  MSG_MORE     = $8000;              { Sender will send more }
+  MSG_EOF      = MSG_FIN;
+