Re: creating stream

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

 



On 04/21/2017 01:36 PM, Vasiliy Tolstov wrote:
2017-04-21 14:14 GMT+03:00 Michal Privoznik <mprivozn@xxxxxxxxxx>:
That's how strings are encoded in RPC. the first four bytes say how long the
string is followed by N bytes (padded to 4 bytes boundary) of the actual
string.


I know, I'm use https://godoc.org/github.com/davecgh/go-xdr/xdr2 and
as i see EncodeString already to that. And all other functions what
operates on strings works fine. Fow example LookupDomainByName. Or
StoragePool functions

Bad payload from own prog:
        0x0000:  6001 2a87 006c 0640 2a04 ac00 0006 0001  `.*..l.@*.......
        0x0010:  0000 0000 0000 0001 2a04 ac00 0004 0010  ........*.......
        0x0020:  0ec4 7aff fe54 cb0a e8b2 407d e44c 1249  ..z..T....@}.L.I
        0x0030:  eafc 4a72 8018 00e1 ffba 0000 0101 080a  ..Jr............
        0x0040:  2ef0 9ea7 02ad afcb 0000 004c 2000 8086  ...........L....
        0x0050:  0000 0001 0000 00c9 0000 0000 0000 0009  ................
        0x0060:  0000 0000 0000 0006 3134 3331 3737 0000  ........143177..
        0x0070:  49bf 97e1 4bda 5749 ca89 0000 7db6 2f02  I...K.WI....}./.
        0x0080:  0000 0001 0000 0007 7365 7269 616c 3000  ........serial0.
        0x0090:  0000 0001                                ....

Good payload from virsh:
        0x0000:  6009 09de 0070 0640 2a04 ac00 0006 0001  `....p.@*.......
        0x0010:  0000 0000 0000 0001 2a04 ac00 0004 0010  ........*.......
        0x0020:  0ec4 7aff fe54 cb0a e8a8 407d e159 1a3e  ..z..T....@}.Y.>
        0x0030:  2e25 4a72 8018 00ea ffbe 0000 0101 080a  .%Jr............
        0x0040:  2eed 6e7c 02ac e3be 0000 0050 2000 8086  ..n|.......P....
        0x0050:  0000 0001 0000 00c9 0000 0000 0000 0009  ................
        0x0060:  0000 0000 0000 0006 3134 3331 3737 0000  ........143177..
        0x0070:  49bf 97e1 4bda 5749 ca89 0000 7db6 2f02  I...K.WI....}./.
        0x0080:  0000 0001 0000 0001 0000 0007 7365 7269  ............seri

So the extra "byte" (in fact 4 bytes) are at 0x0084-0x0087. So this is how strings are encoded. There are basically two types of strings when it comes to XDR. The first one is nonnull_string, which are encoded [length][string]. With just this it would be impossible to differentiate between NULL and an empty string "" as both would be encoded in the same way. Therefore, there is remote_string (libvirt terminology) or xdr_pointer (XDR terminology) which encodes a pointer as [bool][pointer] where bool is either 00 00 00 00 meaning the pointer is NULL or something else (e.g. 00 00 00 01) meaning the pointer has a non-NULL value. So long story short, what you can see here is:

00 00 00 01 00 00 00 07 73 65 72 69 61 6c 30

which is the same as (regroup)

[00 00 00 01] [00 00 00 07] [73 65 72 69 61 6c 30]

which means: the following pointer is a non-NULL pointer, and it is a string of the length 7 and the string is "serial0".

        0x0090:  616c 3000 0000 0000                      al0.....

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux