lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] dns_gethostbyname


From: Sandra Gilge
Subject: [lwip-users] dns_gethostbyname
Date: Tue, 12 May 2015 13:46:48 +0200

Hallo Krzysztof,

sorry for mispelling your name the last time. And sorry for my stupid
question.
I didn't think of creating MY OWN function which then calls
dns_gethostbyname.

Now it works. Here's the way I implemented it:
typedef struct
{
    err_t               ret;
    const char*         hostname;
    ip_addr_t*          addr;
    dns_found_callback  found;
    void*               callback_arg;
}LWIP_GetHostByNameType;

void LWIP_HostByNameCallback(void* arg)
{
    LWIP_GetHostByNameType *parameter = arg;    
    parameter->ret = dns_gethostbyname(parameter->hostname, parameter->addr,
parameter->found, parameter->callback_arg);
}

/* With this function dns_gethostbyname is called in the tcpip thread
context */
err_t LWIP_GetHostByName(const char *hostname, ip_addr_t *addr,
dns_found_callback found, void *callback_arg)
{
    LWIP_GetHostByNameType parameter;
    parameter.hostname = hostname;
    parameter.addr = addr;
    parameter.found = found;
    parameter.callback_arg = callback_arg;
    tcpip_callback_with_block(LWIP_HostByNameCallback, (void*)&parameter,
1);
    return parameter.ret;
}

Best regards,
Sandra

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Im Auftrag von
address@hidden
Gesendet: Samstag, 9. Mai 2015 18:00
An: address@hidden
Betreff: lwip-users Digest, Vol 141, Issue 15

Send lwip-users mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.nongnu.org/mailman/listinfo/lwip-users
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
        address@hidden

When replying, please edit your Subject line so it is more specific than
"Re: Contents of lwip-users digest..."


Today's Topics:

   1. Re: Lwip with two ethernet ports (Eason)
   2. Re: Lwip with two ethernet ports (address@hidden)
   3. Re: dns_gethostbyname (Krzysztof Weso?owski)
   4. Re: Lwip with two ethernet ports (Eason)


----------------------------------------------------------------------

Message: 1
Date: Fri, 8 May 2015 08:54:40 -0700 (MST)
From: Eason <address@hidden>
To: address@hidden
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Hi Sergio, forgive my worst codes and poor lwip background, I study it for
only two weeks.

My boss assign me a strange project, he wants lwip doing a simple job as a
router, and this device have two ethernet ports, but it has only one network
interface card, the device maybe route for different network segment, eg:
192.168.1.2 send data to 172.16.0.101

As you say, lwip can not route?? But I find a ip_forward function that can
foward packet to other interface, it support routing service, isn't it?? 

Thank you for your lwip teaching.



--
View this message in context:
http://lwip.100.n7.nabble.com/Lwip-with-two-ethernet-ports-tp24405p24414.htm
l
Sent from the lwip-users mailing list archive at Nabble.com.



------------------------------

Message: 2
Date: Fri, 08 May 2015 20:43:14 +0200
From: "address@hidden" <address@hidden>
To: Mailing list for lwIP users <address@hidden>
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <address@hidden>
Content-Type: text/plain; charset=windows-1252; format=flowed

Eason wrote:
> My boss assign me a strange project, he wants lwip doing a simple job 
> as a router, and this device have two ethernet ports, but it has only 
> one network interface card, the device maybe route for different network
segment, eg:
> 192.168.1.2 send data to 172.16.0.101

I see what you're talking about. lwIP might do the job, but having only
1 hardware interface and 2 netifs, you have to program some extra
(custom) logic to ensure that packets are fed into the correct netif. 
You only have one RX ISR, so you might need to check the destination address
and decide for one of the two netifs before calling netif->input().

Simon



------------------------------

Message: 3
Date: Fri, 8 May 2015 23:18:21 +0200
From: Krzysztof Weso?owski <address@hidden>
To: Mailing list for lwIP users <address@hidden>
Subject: Re: [lwip-users] dns_gethostbyname
Message-ID:
        <address@hidden>
Content-Type: text/plain; charset="iso-8859-1"

On Tue, May 5, 2015 at 11:27 AM, Sandra Gilge <address@hidden> wrote:

> Hallo Christoph,
>
> I think the tcpip_callback_with_block is the right solution for me. 
> Many thanks for that hint.
>
> But I wonder how I can pass several parameters to dns_gethostbyname then.
> Is
> it done in a struct?
> Dns_gethostbyname has four parameters:
> dns_gethostbyname (const char *hostname, struct ip_addr *addr, 
> dns_found_callback  found,
>                 void *callback_arg)
>
> As far as I understand a message is sent to tcpip_thread with 
> functionpointer and pointer to parameter as payload of that message.
>

Hello,

Yes you can use struct to pass multiple arguments via void * argument.
struct can be global or dynamically allocated, or if you use blocking
version ( tcpip_callback_with_block (,,1)) you can place struct on stack in
calling thread.

Regards,
Krzysztof Wesolowski
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.nongnu.org/archive/html/lwip-users/attachments/20150508/2d0737
45/attachment.html>

------------------------------

Message: 4
Date: Fri, 8 May 2015 21:00:10 -0700 (MST)
From: Eason <address@hidden>
To: address@hidden
Subject: Re: [lwip-users] Lwip with two ethernet ports
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Hi Simon, I have some questions.

I add the second interface(struct netif* xnetif_1) by using
netif_add(xnetif_1, &ipaddr, &netmask, &gw, NULL, ethernetif_init,
tcpip_input);, and I don't set it to default interface, isn't it? No metter
what I add, I just set default interface on first interface(struct netif*
xnetif_0).

In ip_input(), it forwards packets to correct interface if the packets are
not for currently interface, so I shouldn't edit any other codes? Or designe
a routing table?



--
View this message in context:
http://lwip.100.n7.nabble.com/Lwip-with-two-ethernet-ports-tp24405p24420.htm
l
Sent from the lwip-users mailing list archive at Nabble.com.



------------------------------

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users

End of lwip-users Digest, Vol 141, Issue 15
*******************************************




reply via email to

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