Operating System - HP-UX
1837260 Members
2453 Online
110115 Solutions
New Discussion

Re: peer ip address not set after accept call in 64 bit mode

 
Rajesh R_2
Frequent Advisor

peer ip address not set after accept call in 64 bit mode

We have an application that validates client ip address. This works well when compiled in 32 bit mode. When compiled in 64 bit mode, inet_ntoa() is not giving correct ip address of the client. We have tried this on PA as well as itanium. Both behaves similar. Is there any problem with the code.. or is there any patch to be applied?
14 REPLIES 14
Steven E. Protter
Exalted Contributor

Re: peer ip address not set after accept call in 64 bit mode

Please post a code snippet.

Also post a few examples of the problem and tell us what compiler you used to compile the program.

It could be any number of factors, OS, compiler, etc.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

what cc :

$Revision: 92453-07 linker linker crt0.o B.11.16.01 030316 $
LINT B.11.11.08 CXREF B.11.11.08
HP92453-01 B.11.11.08 HP C Compiler
$ PATCH/11.00:PHCO_27774 Oct 3 2002 09:45:59 $

sample.c is attached.
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

What does len contain after the accept call?
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

len (after accept)is 16 on both 32 bit as well as 64 bit.
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

Can you print out cliAddr->sin_addr, cliAddr->sin_family and cliAddr->sin_port as hexadecimal numbers after the accept call. You might also try memset on cliAddr before first usage, to ensure that it is empty.
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

I tried to print sin_family, sin_addr and sin_port. all are coming as ZEROES.
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

Do they come out as zeroes in both 32-bit and 64-bit modes?
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

No. it is ZERO for 64 bit only.
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

What does ldd of your 32-bit and 64-bit binaries give you?
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

### 64 bit
hpdev:/tmp()>ldd a.out
libc.2 => /usr/lib/pa20_64/libc.2
libdl.1 => /usr/lib/pa20_64/libdl.1

### 32 bit
hpdev:/tmp()>ldd a.out
/usr/lib/libc.2 => /usr/lib/libc.2
/usr/lib/libdld.2 => /usr/lib/libdld.2
/usr/lib/libc.2 => /usr/lib/libc.2
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

What happens if you change

socklen_t len;

to

size_t len;

Just as a matter of interest ...
Rajesh R_2
Frequent Advisor

Re: peer ip address not set after accept call in 64 bit mode

Even size_t is resulting in the same.

I am getting the following warning while using compile option +M2

cc: "/usr/include/sys/_fd_macros.h", line 61: LP64 migration warning 753: * converts 32 bit integer to long
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

What are the lines around line 61 in /usr/include/sys/_fd_macros.h,
my version of the header file is different. Say 10 lines either side. I suspect it has to do with the definition of __fd_mask
Stephen Keane
Honored Contributor

Re: peer ip address not set after accept call in 64 bit mode

A shot in the dark, but try including in your code, probably after socket.h