syncthing/lib/discover/localpackets_xdr.go

247 lines
6.5 KiB
Go
Raw Normal View History

2014-07-13 07:24:25 +00:00
// ************************************************************
// This file is automatically generated by genxdr. Do not edit.
// ************************************************************
2014-02-20 16:40:15 +00:00
package discover
import (
2014-08-01 11:12:54 +00:00
"github.com/calmh/xdr"
2014-02-20 16:40:15 +00:00
)
2014-07-13 07:24:25 +00:00
/*
Announce Structure:
2014-07-13 07:24:25 +00:00
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Magic |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2015-03-25 21:37:35 +00:00
/ /
\ Device Structure \
/ /
2014-07-13 07:24:25 +00:00
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Number of Extra |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
\ Zero or more Device Structures \
2014-07-13 07:24:25 +00:00
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
struct Announce {
2014-07-13 07:24:25 +00:00
unsigned int Magic;
Device This;
Device Extra<16>;
2014-07-13 07:24:25 +00:00
}
*/
2016-02-02 11:44:33 +00:00
func (o Announce) XDRSize() int {
return 4 +
o.This.XDRSize() +
4 + xdr.SizeOfSlice(o.Extra)
2014-02-20 16:40:15 +00:00
}
2014-10-21 06:40:05 +00:00
func (o Announce) MarshalXDR() ([]byte, error) {
2016-02-02 11:44:33 +00:00
buf := make([]byte, o.XDRSize())
m := &xdr.Marshaller{Data: buf}
return buf, o.MarshalXDRInto(m)
}
2014-10-21 06:40:05 +00:00
func (o Announce) MustMarshalXDR() []byte {
bs, err := o.MarshalXDR()
if err != nil {
panic(err)
}
return bs
}
2016-02-02 11:44:33 +00:00
func (o Announce) MarshalXDRInto(m *xdr.Marshaller) error {
m.MarshalUint32(o.Magic)
if err := o.This.MarshalXDRInto(m); err != nil {
return err
}
2014-10-21 06:40:05 +00:00
if l := len(o.Extra); l > 16 {
2016-02-02 11:44:33 +00:00
return xdr.ElementSizeExceeded("Extra", l, 16)
2014-02-20 16:40:15 +00:00
}
2016-02-02 11:44:33 +00:00
m.MarshalUint32(uint32(len(o.Extra)))
2014-05-11 22:55:43 +00:00
for i := range o.Extra {
2016-02-02 11:44:33 +00:00
if err := o.Extra[i].MarshalXDRInto(m); err != nil {
return err
}
2014-05-11 22:55:43 +00:00
}
2016-02-02 11:44:33 +00:00
return m.Error
2014-05-11 22:55:43 +00:00
}
func (o *Announce) UnmarshalXDR(bs []byte) error {
2016-02-02 11:44:33 +00:00
u := &xdr.Unmarshaller{Data: bs}
return o.UnmarshalXDRFrom(u)
2014-05-11 22:55:43 +00:00
}
2016-02-02 11:44:33 +00:00
func (o *Announce) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
o.Magic = u.UnmarshalUint32()
(&o.This).UnmarshalXDRFrom(u)
_ExtraSize := int(u.UnmarshalUint32())
2015-04-08 12:44:47 +00:00
if _ExtraSize < 0 {
return xdr.ElementSizeExceeded("Extra", _ExtraSize, 16)
2016-02-02 11:44:33 +00:00
} else if _ExtraSize == 0 {
o.Extra = nil
} else {
if _ExtraSize > 16 {
return xdr.ElementSizeExceeded("Extra", _ExtraSize, 16)
}
if _ExtraSize <= len(o.Extra) {
o.Extra = o.Extra[:_ExtraSize]
} else {
o.Extra = make([]Device, _ExtraSize)
}
for i := range o.Extra {
(&o.Extra[i]).UnmarshalXDRFrom(u)
}
2015-04-08 12:44:47 +00:00
}
2016-02-02 11:44:33 +00:00
return u.Error
2014-05-11 22:55:43 +00:00
}
2014-07-13 07:24:25 +00:00
/*
Device Structure:
2014-07-13 07:24:25 +00:00
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
2016-02-02 11:44:33 +00:00
\ ID (length + padded data) \
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Number of Addresses |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2014-07-13 07:24:25 +00:00
/ /
\ Zero or more Address Structures \
2014-07-13 07:24:25 +00:00
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
struct Device {
opaque ID<32>;
Address Addresses<16>;
2014-07-13 07:24:25 +00:00
}
*/
2016-02-02 11:44:33 +00:00
func (o Device) XDRSize() int {
return 4 + len(o.ID) + xdr.Padding(len(o.ID)) +
4 + xdr.SizeOfSlice(o.Addresses)
2014-02-20 16:40:15 +00:00
}
func (o Device) MarshalXDR() ([]byte, error) {
2016-02-02 11:44:33 +00:00
buf := make([]byte, o.XDRSize())
m := &xdr.Marshaller{Data: buf}
return buf, o.MarshalXDRInto(m)
}
func (o Device) MustMarshalXDR() []byte {
2014-10-21 06:40:05 +00:00
bs, err := o.MarshalXDR()
if err != nil {
panic(err)
}
return bs
}
2016-02-02 11:44:33 +00:00
func (o Device) MarshalXDRInto(m *xdr.Marshaller) error {
if l := len(o.ID); l > 32 {
2016-02-02 11:44:33 +00:00
return xdr.ElementSizeExceeded("ID", l, 32)
}
2016-02-02 11:44:33 +00:00
m.MarshalBytes(o.ID)
if l := len(o.Addresses); l > 16 {
2016-02-02 11:44:33 +00:00
return xdr.ElementSizeExceeded("Addresses", l, 16)
}
2016-02-02 11:44:33 +00:00
m.MarshalUint32(uint32(len(o.Addresses)))
for i := range o.Addresses {
2016-02-02 11:44:33 +00:00
if err := o.Addresses[i].MarshalXDRInto(m); err != nil {
return err
}
}
2016-02-02 11:44:33 +00:00
return m.Error
2014-02-20 16:40:15 +00:00
}
func (o *Device) UnmarshalXDR(bs []byte) error {
2016-02-02 11:44:33 +00:00
u := &xdr.Unmarshaller{Data: bs}
return o.UnmarshalXDRFrom(u)
2014-02-20 16:40:15 +00:00
}
2016-02-02 11:44:33 +00:00
func (o *Device) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
o.ID = u.UnmarshalBytesMax(32)
_AddressesSize := int(u.UnmarshalUint32())
if _AddressesSize < 0 {
return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 16)
2016-02-02 11:44:33 +00:00
} else if _AddressesSize == 0 {
o.Addresses = nil
} else {
if _AddressesSize > 16 {
return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 16)
}
if _AddressesSize <= len(o.Addresses) {
o.Addresses = o.Addresses[:_AddressesSize]
} else {
o.Addresses = make([]Address, _AddressesSize)
}
for i := range o.Addresses {
(&o.Addresses[i]).UnmarshalXDRFrom(u)
}
}
2016-02-02 11:44:33 +00:00
return u.Error
2014-02-20 16:40:15 +00:00
}
/*
Address Structure:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/ /
2016-02-02 11:44:33 +00:00
\ URL (length + padded data) \
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
struct Address {
string URL<2083>;
}
*/
2016-02-02 11:44:33 +00:00
func (o Address) XDRSize() int {
return 4 + len(o.URL) + xdr.Padding(len(o.URL))
}
func (o Address) MarshalXDR() ([]byte, error) {
2016-02-02 11:44:33 +00:00
buf := make([]byte, o.XDRSize())
m := &xdr.Marshaller{Data: buf}
return buf, o.MarshalXDRInto(m)
}
func (o Address) MustMarshalXDR() []byte {
bs, err := o.MarshalXDR()
if err != nil {
panic(err)
}
return bs
}
2016-02-02 11:44:33 +00:00
func (o Address) MarshalXDRInto(m *xdr.Marshaller) error {
if l := len(o.URL); l > 2083 {
2016-02-02 11:44:33 +00:00
return xdr.ElementSizeExceeded("URL", l, 2083)
}
2016-02-02 11:44:33 +00:00
m.MarshalString(o.URL)
return m.Error
}
func (o *Address) UnmarshalXDR(bs []byte) error {
2016-02-02 11:44:33 +00:00
u := &xdr.Unmarshaller{Data: bs}
return o.UnmarshalXDRFrom(u)
}
2016-02-02 11:44:33 +00:00
func (o *Address) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
o.URL = u.UnmarshalStringMax(2083)
return u.Error
}