cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_SCOPE

From: Pramod Sharma <pramodsharma08_at_gmail.com>
Date: Mon, 11 Aug 2008 18:06:20 +0530

On Mon, Aug 11, 2008 at 5:26 PM, Pramod Sharma <pramodsharma08_at_gmail.com> wrote:
>> Message: 1
>> Date: Mon, 11 Aug 2008 13:03:28 +0530
>> From: "Pramod Sharma" <pramodsharma08_at_gmail.com>
>> Subject: Re: CURLOPT_SCOPE
>> To: curl-library_at_cool.haxx.se
>> Message-ID:
>> <3c7161960808110033y7ee1f157mf4a73ab3a0909cbf_at_mail.gmail.com>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> On 8/11/08, Pramod Sharma <pramodsharma08_at_gmail.com> wrote:
>>> From: Daniel Stenberg <daniel_at_haxx.se>
>>> Date: Wed, 30 Jul 2008 23:53:36 +0200 (CEST)
>>>
>>> On Mon, 21 Jul 2008, Phil Blundell wrote:
>>>
>>>
>>> > Daniel, did you get a chance to look at this new patch?
>>>
>>>
>>> >Your patch has now been committed, with a few minor edits by me.
>>>
>>>
>>> >Thanks!
>>>
>>> Daniel ,
>>> I have two question regarding this CURLOPT_SCOPE/CURLOPT_ADDRESS_SCOPE.
>>> 1. Why it have to be only long ? Can't user give interface name and we
>>> change it internally to id , like eth0 can be changed to index id by
>>> some system api's or I am missing something here ?
>>> 2. What about the proxy address scope id ? We have to give it in url
>>> itself as there is no separate setopt for that ?
>>>
>>> Thanks,
>>> Pramod Sharma
>>>
>>
>> Okay regarding 2nd question , It's just my less knowledge about scope
>> id I guess. As it will be scope id of the local machine and why it
>> needs to be different.
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Mon, 11 Aug 2008 08:51:06 +0100
>> From: Phil Blundell <pb_at_reciva.com>
>> Subject: Re: CURLOPT_SCOPE
>> To: libcurl development <curl-library_at_cool.haxx.se>
>> Message-ID: <1218441066.25732.275.camel_at_lenovo.internal.reciva.com>
>> Content-Type: text/plain
>>
>> On Mon, 2008-08-11 at 11:41 +0530, Pramod Sharma wrote:
>>> Daniel ,
>>> I have two question regarding this CURLOPT_SCOPE/CURLOPT_ADDRESS_SCOPE.
>>> 1. Why it have to be only long ? Can't user give interface name and we
>>> change it internally to id , like eth0 can be changed to index id by
>>> some system api's or I am missing something here ?
>>
>> (I'm not Daniel, but...)
>>
>> A long is what's needed for the IPv6 socket APIs. If you have an
>> interface name and want to convert it to an integer then, as you say,
>> there are system APIs to do that. Using names for the libcurl API would
>> mean that curl always needed to perform this (fairly slow) conversion
>> internally; worse, any callers who think in terms of integers would need
>> to convert their ints to strings for libcurl, only to have it convert
>> them right back again.
>>
>> In particular, the specific use-case that CURLOPT_SCOPE is intended to
>> support is where you previously received a message (e.g. a SUBSCRIBE
>> request) from some other host and you now want to make a new outgoing
>> connection to the originator of that initial message to deliver the
>> corresponding NOTIFY. In this situation the value you want to pass as
>> CURLOPT_SCOPE is what you retrieved from the ip6_pktinfo structure on
>> the original request, and this is a numeric value not a string.
>>
>>> 2. What about the proxy address scope id ? We have to give it in url
>>> itself as there is no separate setopt for that ?
>>
>> Right. There didn't seem any benefit in having a separate setopt for
>> the proxy address. I guess you are welcome to make the argument for
>> having one if you think it is important.
>>
>> p.
>
> Ya your are right about passing the string . That doesn't make a more
> of sense .
> I am pretty much confused about the scope id actually. With link local
> address even if you don't metnion the scope id to connect call it
> passed on windows , whereas on *nix it doesn't. So you have to mention
> the scope id ( some says its the interface index and some argue that).
> As of now I am just converting the interface id to index to work.
>
> I merged the changes related to this bug in curl 7.18.1 version which
> we are using. In passing the URL it should work , but it's not .
> #include "curl/curl.h"
> #include <iostream>
> #include <net/if.h>
> #include <sys/types.h>
>
>
>
> int main(int argc , char *argv[])
> {
> CURL *curl = curl_easy_init();
> curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
> std::cout << "Interface index = " << if_nametoindex ("eth0")
> << std::endl ;
> curl_easy_setopt(curl,CURLOPT_ADDRESS_SCOPE,if_nametoindex ("eth0"));
> //Is this not supposed to work , Not able to do with even with
> curl command line ?
> curl_easy_setopt(curl,CURLOPT_URL ,
> "http://[fe80::212:3fff:fe55:8470%2]:80/SiteStat.xml");
> CURLcode response = curl_easy_perform(curl);
> std::cout << curl_easy_strerror(response) << std::endl;
>
> }
>
> Interface index = 2
> * getaddrinfo(3) failed for [fe80::212:3fff:fe55:8470%2]:80
> * Couldn't resolve host '[fe80::212:3fff:fe55:8470%2]'
> * Closing connection #0
> * Couldn't resolve host name
> Couldn't resolve host name
>
> Any clues on that ?
>

Infact it should not have gone to getaddrinfo inside the bracket[] .
it will always fail in that case.
Received on 2008-08-11