X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/51075d051580863ca073aa91883357410b358e40..803cf6668d9e89c244e5fbc7f996a460470338dd:/binipstuff.pas diff --git a/binipstuff.pas b/binipstuff.pas index 227c6f4..9f84721 100644 --- a/binipstuff.pas +++ b/binipstuff.pas @@ -78,8 +78,8 @@ type Adding "4" to non IPv6 record names improves code clarity } {$ifndef mswindows} - {zipplet 20170204: Do we still need to support ver1_0? Perhaps a cleanup is in order. - For now keep supporting it for compatibility. } + //zipplet 20170204: Do we still need to support ver1_0? Perhaps a cleanup is in order. + //For now keep supporting it for compatibility. {$ifdef ver1_0} cuint16 = word; cuint32 = dword; @@ -88,15 +88,25 @@ type {$endif} TLInetSockAddr4 = packed Record + {$ifdef bsd} + len:byte; + family:byte; + {$else} family:Word; + {$endif} port :Word; addr :uint32; - pad :array [0..7] of byte; {zipplet 20170204 - originally this was 1..8 for some reason} + pad :array [0..7] of byte; //zipplet 20170204 - originally this was 1..8 for some reason end; {$ifdef ipv6} TLInetSockAddr6 = packed record + {$ifdef bsd} + sin6_len:byte; + sin6_family:byte; + {$else} sin6_family: word; + {$endif} sin6_port: word; sin6_flowinfo: uint32; sin6_addr: tin6_addr; @@ -104,7 +114,7 @@ type end; {$endif} - {zipplet 20170204: I did not rename the unioned record. We might want to rename this to TLinetSockAddrv } + //zipplet 20170204: I did not rename the unioned record. We might want to rename this to TLinetSockAddrv TinetSockAddrv = packed record case integer of 0: (InAddr:TLInetSockAddr4); @@ -206,6 +216,9 @@ begin fillchar(inaddr,sizeof(inaddr),0); //writeln('converted address '+addr+' to binip '+ipbintostr(biniptemp)); if addr.family = AF_INET then begin + {$ifdef bsd} + inAddr.InAddr.Len := sizeof(tlinetsockaddr4); + {$endif} inAddr.InAddr.family:=AF_INET; inAddr.InAddr.port:=htons(strtointdef(port,0)); inAddr.InAddr.addr:=addr.ip; @@ -213,6 +226,9 @@ begin end else {$ifdef ipv6} if addr.family = AF_INET6 then begin + {$ifdef bsd} + inAddr.InAddr6.sin6_len := sizeof(tlinetsockaddr6); + {$endif} inAddr.InAddr6.sin6_family:=AF_INET6; inAddr.InAddr6.sin6_port:=htons(strtointdef(port,0)); inAddr.InAddr6.sin6_addr:=addr.ip6; @@ -300,7 +316,10 @@ begin {$endif} {try v4} - binip.ip := htonl(longip(s)); + // zipplet: htonl() expects a uint32 but longip() spits out longint. + // Because longip() is deprecated, we do not fix it but typecast. + //binip.ip := htonl(longip(s)); + binip.ip := htonl(uint32(longip(s))); if (binip.ip <> 0) or (s = '0.0.0.0') then begin result := true; binip.family := AF_INET;