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

Bug#564232: Bug located in Set_Family function in g-sothco.ads



If I replace :
--Sin.Sin_Family := (Has_Sockaddr_Len => True, 
-- Length => Sin'Size / 8, 
-- Char_Family => System.OS_Constants.AF_INET); 
by
Thin_Common.Set_Family (Sin.Sin_Family, Family_Inet);
The new (bind_socket.adb + patch) code fail again.

A look to Set_Family show that since Has_Sockaddr_Len from s-oscons.ads = 0
the code goes in the second branch and is equivalent to
--Sin.Sin_Family := (Has_Sockaddr_Len => False,
-- Short_Family => System.OS_Constants.AF_INET);
And if Linux supports this it seems that the freebsd prefers to have the
length ?
a test with this version of code fails also :
Sin.Sin_Family := (Has_Sockaddr_Len => False,
		 Short_Family => System.OS_Constants.AF_INET);
But this code is OK :
Sin.Sin_Family := (Has_Sockaddr_Len => False,
		 Short_Family => Short_To_Network (System.OS_Constants.AF_INET));
Where the function Short_To_Network is the one taken from gnat.sockets
So the function Set_Family from :

 if Has_Sockaddr_Len then
 Length_And_Family.Length := Lengths (Family);
 Length_And_Family.Char_Family := C.unsigned_char (C_Family);
 else
 Length_And_Family.Short_Family := C.unsigned_short (C_Family);
 end if;

Should become at least on freebsd :

 if Has_Sockaddr_Len then
 Length_And_Family.Length := Lengths (Family);
 Length_And_Family.Char_Family := C.unsigned_char (C_Family);
 else
 Length_And_Family.Short_Family := Short_To_Network (C.unsigned_short
(C_Family));
 end if;


It seems that linux and freebsd have a different behavior regarding the
endianess of sin_family
Any freebsd/linux guru around to confirm or infirm this idea ?

To close this bug I propose to had a patch specific to freebsd in Set_Family
? Any other proposition ?





Reply to: