curl-library
Re: using libcurl for ipp
Date: Sat, 20 Sep 2008 01:05:46 +0200
On Fri, Sep 19, 2008 at 11:55 PM, benoy m <benoy6751_at_gmail.com> wrote:
>
>
> On Fri, Sep 19, 2008 at 3:56 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
>> On Fri, 19 Sep 2008, benoy m wrote:
>>
>
Hi Benoy,
>
>> So I have built the http request data for content type: application/ipp
>>> and
>>> store it as a byte array.
>>> vector<unsigned char> postdata;
>>>
>>> Then I make the following calls:
>>> curl_easy_setopt( handle, CURLOPT_POSTFIELDSIZE, postdata.size());
>>> curl_easy_setopt( handle, CURLOPT_POSTFIELDS , &postdata);
>>>
>>
>> CURLOPT_POSTFIELDS expects a plain C char *, so I hope your C++isms
>> convert it to such a one.
>>
>
I'm not exactly sure why you are using a vector here. And of how it gets
converted to a char *.
Perhaps you can use &postdata[0] as an alternative, which could work better.
Anyways, i'm not familiar with IPP, but I think you should really use a
standard C-style buffer here.
>
> I assume that after the necessary changes have been made, all the curl
> function calls are correct. So the reason I am getting this error might be
> with the data being send :
> curl_easy_setopt( handle, CURLOPT_POSTFIELDS , &postdata)
>
> is incorrect. Is there any way I can print out the raw data that is send? I
> see that some of the data i have send can be seen, ex: "zx:
> ipp-attribute-fidelity.4:"
>
>
Again, i don't know the IPP protocol. From what I understood, it uses some
binary parts and some text-only parts ? From what I could gather, a
sucessful request is contained in the two following packets (I get a HTTP
200 response). So I guess that either you are misconstructing the ipp
payload in your vector, either you are giving to cURL the adress of the
std::vector you are using and not the address of the content of this vector.
To print the raw data you can either use tcpdump like I did (-n -vvv -s 2000
-X -i <your_eth_interface> port 631 ) or recode your own hexdump function,
or even use a rogram like netcat as a server (nc -l -p 3333 | hexdump -C)
and give http://localhost:3333/ as the adress cURL should connect to.
00:56:40.869699 IP (tos 0x0, ttl 64, id 19564, offset 0, flags [DF], proto
TCP (6), length 189) 192.168.48.201.51757 > 192.168.48.1.631: P, cksum
0x9096 (correct), 1:138(137) ack 1 win 65535 <nop,nop,timestamp 385313351
2920337859>
0x0000: 4500 00bd 4c6c 4000 4006 0bb4 c0a8 30c9 E...Ll@.@.....0.
0x0010: c0a8 3001 ca2d 0277 0346 cad3 91b3 9792 ..0..-.w.F......
0x0020: 8018 ffff 9096 0000 0101 080a 16f7 6a47 ..............jG
0x0030: ae10 d1c3 504f 5354 202f 2048 5454 502f ....POST./.HTTP/
0x0040: 312e 310d 0a43 6f6e 7465 6e74 2d4c 656e 1.1..Content-Len
0x0050: 6774 683a 2032 3832 0d0a 436f 6e74 656e gth:.282..Conten
0x0060: 742d 5479 7065 3a20 6170 706c 6963 6174 t-Type:.applicat
0x0070: 696f 6e2f 6970 700d 0a48 6f73 743a 2031 ion/ipp..Host:.1
0x0080: 3932 2e31 3638 2e34 382e 310d 0a55 7365 92.168.48.1..Use
0x0090: 722d 4167 656e 743a 2043 5550 532f 312e r-Agent:.CUPS/1.
0x00a0: 332e 360d 0a45 7870 6563 743a 2031 3030 3.6..Expect:.100
0x00b0: 2d63 6f6e 7469 6e75 650d 0a0d 0a -continue....
00:56:40.869757 IP (tos 0x0, ttl 64, id 47733, offset 0, flags [DF], proto
TCP (6), length 334) 192.168.48.201.51757 > 192.168.48.1.631: P, cksum
0xafbd (correct), 138:420(282) ack 1 win 65535 <nop,nop,timestamp 385313351
2920337859>
0x0000: 4500 014e ba75 4000 4006 9d19 c0a8 30c9 E..N.u@.@.....0.
0x0010: c0a8 3001 ca2d 0277 0346 cb5c 91b3 9792 ..0..-.w.F.\....
0x0020: 8018 ffff afbd 0000 0101 080a 16f7 6a47 ..............jG
0x0030: ae10 d1c3 0101 000b 0000 0001 0147 0012 .............G..
0x0040: 6174 7472 6962 7574 6573 2d63 6861 7273 attributes-chars
0x0050: 6574 0005 7574 662d 3848 001b 6174 7472 et..utf-8H..attr
0x0060: 6962 7574 6573 2d6e 6174 7572 616c 2d6c ibutes-natural-l
0x0070: 616e 6775 6167 6500 0266 7245 000b 7072 anguage..frE..pr
0x0080: 696e 7465 722d 7572 6900 1769 7070 3a2f inter-uri..ipp:/
0x0090: 2f31 3932 2e31 3638 2e34 382e 313a 3633 /192.168.48.1:63
0x00a0: 312f 4400 1472 6571 7565 7374 6564 2d61 1/D..requested-a
0x00b0: 7474 7269 6275 7465 7300 1063 6f70 6965 ttributes..copie
0x00c0: 732d 7375 7070 6f72 7465 6444 0000 0019 s-supportedD....
0x00d0: 646f 6375 6d65 6e74 2d66 6f72 6d61 742d document-format-
0x00e0: 7375 7070 6f72 7465 6444 0000 0019 7072 supportedD....pr
0x00f0: 696e 7465 722d 6973 2d61 6363 6570 7469 inter-is-accepti
0x0100: 6e67 2d6a 6f62 7344 0000 000d 7072 696e ng-jobsD....prin
0x0110: 7465 722d 7374 6174 6544 0000 0015 7072 ter-stateD....pr
0x0120: 696e 7465 722d 7374 6174 652d 6d65 7373 inter-state-mess
0x0130: 6167 6544 0000 0015 7072 696e 7465 722d ageD....printer-
0x0140: 7374 6174 652d 7265 6173 6f6e 7303 state-reasons.
Ipp does not seem like a simple protocol, so good luck implementing it :)
-- Aurélien Guillaume "I love deadlines. I like the whooshing sound they make as they fly by."Received on 2008-09-20