× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

I am trying to track an incoming request to a TCP/IP server, the reason is we are trying to figure out who is doing a port scan on the listening port we use so that we can identify the responsible party. I have researched the available API's and how to implement and come up with the above API, however when I get the data back from the API all I get is an IP address of 0.0.0.0?

There are plenty of non IBM i examples out there and looking through the IBM documentation the API should work in the same manner as other implementations, one of the caveats is that IBM suggests the use of a structure structaddr_storage for the collection which needs to be cast on the call to the API.

Here is a summary of the code that I am using, I have not added all of the code (there is a lot of other code running which is not relevant to this).

int listen_sd, accept_sd = 0; // socket ints
socklen_t addr_len; // address struct len
struct sockaddr_storage addr_in; // socket address structure

// set up the address in structure
memset(&addr_in, 0, sizeof(addr_in));
addr_len = sizeof(addr_in);

// we set up the socket in another program and pass in
// via spawn request
listen_sd = atoi(argv[1]);

// set up the accept, we pass in the address structure cast to correct type which should get filled in when the connection is made with the source IP address
accept_sd = accept(listen_sd,(struct sockaddr *)&addr_in, &addr_len);

// recv the data from the client, this is not relevant but this is where we notice the problem
rc = recv(accept_sd, recv_buf,_IP_BUF_SIZE, 0);

// extract the remote IP address using the inet_ntop API
inet_ntop(AF_INET,(struct sockaddr *)&addr_in._ss_align,ip_addr,16);
len = sprintf(msg_dta,"Recv address %.16s",ip_addr);

// we should see the IP address the connection request came from
// but all we see is 'Recv address 0.0.0.0'

Has anyone else used this API successfully? Can they see something glaringly obviously wrong?

Thanks in advance.

Chris...

[cid:image001.jpg@01D8FF23.7D6F1600]
Chris Hird
Director at Shield Advanced Solutions Ltd.

Phone: 519-940-1192
Mobile: 647-234-6539
Email: chrish@xxxxxxxxxxxxxxxxxx

75 First Street Suite 206
Orangeville, ON L9W 5B6

https://www.shieldadvanced.com<https://www.shieldadvanced.com/>






As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.