lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] How to get the ip address of the remote host in a conne


From: Jonathan Larmour
Subject: Re: [lwip-users] How to get the ip address of the remote host in a connection
Date: Mon, 25 Aug 2008 23:48:59 +0100
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Antonio de Angelis wrote:
> In data 25 agosto 2008 alle ore 22:57:43, Jonathan Larmour
> <address@hidden> ha scritto:
> 
>> Antonio de Angelis wrote:
>>> Hi all,
>>> I've built a simple server application for the Win32 port. But now I
>>> want to implement a simple mechanism to refuse incoming connections
>>> from certain ip addresses... how can I get the ip address of a remote
>>> host that has just connected to the server? Thanks
>>
>> Which API are you using? Sockets, netconn (also known as sequential
>> API) or raw?
> 
> raw api.

First of all, just to be clear, lwIP is not able to refuse incoming
connections with anything like a "connection refused" ICMP message. It's
deliberately simple in that respect, in line with its general ethos, so it
doesn't have packet filtering capabilities. What you can do easily instead
is simply close the connection immediately after it is established. So when
your accept function is called, you can check the remote IP then.

The remote IP is simply available inside the PCB, e.g. assuming struct
tcp_pcb *pcb :

pcb->ip->remote_ip

Less officially, you would probably not find it hard to hack in a callback
in tcp_listen_input in src/core/tcp_in.c.

Hope this helps,

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]