localpackets_xdr.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. // ************************************************************
  2. // This file is automatically generated by genxdr. Do not edit.
  3. // ************************************************************
  4. package discover
  5. import (
  6. "github.com/calmh/xdr"
  7. )
  8. /*
  9. Announce Structure:
  10. 0 1 2 3
  11. 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
  12. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  13. | Magic |
  14. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  15. / /
  16. \ Device Structure \
  17. / /
  18. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  19. | Number of Extra |
  20. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  21. / /
  22. \ Zero or more Device Structures \
  23. / /
  24. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  25. struct Announce {
  26. unsigned int Magic;
  27. Device This;
  28. Device Extra<16>;
  29. }
  30. */
  31. func (o Announce) XDRSize() int {
  32. return 4 +
  33. o.This.XDRSize() +
  34. 4 + xdr.SizeOfSlice(o.Extra)
  35. }
  36. func (o Announce) MarshalXDR() ([]byte, error) {
  37. buf := make([]byte, o.XDRSize())
  38. m := &xdr.Marshaller{Data: buf}
  39. return buf, o.MarshalXDRInto(m)
  40. }
  41. func (o Announce) MustMarshalXDR() []byte {
  42. bs, err := o.MarshalXDR()
  43. if err != nil {
  44. panic(err)
  45. }
  46. return bs
  47. }
  48. func (o Announce) MarshalXDRInto(m *xdr.Marshaller) error {
  49. m.MarshalUint32(o.Magic)
  50. if err := o.This.MarshalXDRInto(m); err != nil {
  51. return err
  52. }
  53. if l := len(o.Extra); l > 16 {
  54. return xdr.ElementSizeExceeded("Extra", l, 16)
  55. }
  56. m.MarshalUint32(uint32(len(o.Extra)))
  57. for i := range o.Extra {
  58. if err := o.Extra[i].MarshalXDRInto(m); err != nil {
  59. return err
  60. }
  61. }
  62. return m.Error
  63. }
  64. func (o *Announce) UnmarshalXDR(bs []byte) error {
  65. u := &xdr.Unmarshaller{Data: bs}
  66. return o.UnmarshalXDRFrom(u)
  67. }
  68. func (o *Announce) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  69. o.Magic = u.UnmarshalUint32()
  70. (&o.This).UnmarshalXDRFrom(u)
  71. _ExtraSize := int(u.UnmarshalUint32())
  72. if _ExtraSize < 0 {
  73. return xdr.ElementSizeExceeded("Extra", _ExtraSize, 16)
  74. } else if _ExtraSize == 0 {
  75. o.Extra = nil
  76. } else {
  77. if _ExtraSize > 16 {
  78. return xdr.ElementSizeExceeded("Extra", _ExtraSize, 16)
  79. }
  80. if _ExtraSize <= len(o.Extra) {
  81. o.Extra = o.Extra[:_ExtraSize]
  82. } else {
  83. o.Extra = make([]Device, _ExtraSize)
  84. }
  85. for i := range o.Extra {
  86. (&o.Extra[i]).UnmarshalXDRFrom(u)
  87. }
  88. }
  89. return u.Error
  90. }
  91. /*
  92. Device Structure:
  93. 0 1 2 3
  94. 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
  95. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  96. / /
  97. \ ID (length + padded data) \
  98. / /
  99. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  100. | Number of Addresses |
  101. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  102. / /
  103. \ Zero or more Address Structures \
  104. / /
  105. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  106. | Number of Relays |
  107. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  108. / /
  109. \ Zero or more Relay Structures \
  110. / /
  111. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  112. struct Device {
  113. opaque ID<32>;
  114. Address Addresses<16>;
  115. Relay Relays<16>;
  116. }
  117. */
  118. func (o Device) XDRSize() int {
  119. return 4 + len(o.ID) + xdr.Padding(len(o.ID)) +
  120. 4 + xdr.SizeOfSlice(o.Addresses) +
  121. 4 + xdr.SizeOfSlice(o.Relays)
  122. }
  123. func (o Device) MarshalXDR() ([]byte, error) {
  124. buf := make([]byte, o.XDRSize())
  125. m := &xdr.Marshaller{Data: buf}
  126. return buf, o.MarshalXDRInto(m)
  127. }
  128. func (o Device) MustMarshalXDR() []byte {
  129. bs, err := o.MarshalXDR()
  130. if err != nil {
  131. panic(err)
  132. }
  133. return bs
  134. }
  135. func (o Device) MarshalXDRInto(m *xdr.Marshaller) error {
  136. if l := len(o.ID); l > 32 {
  137. return xdr.ElementSizeExceeded("ID", l, 32)
  138. }
  139. m.MarshalBytes(o.ID)
  140. if l := len(o.Addresses); l > 16 {
  141. return xdr.ElementSizeExceeded("Addresses", l, 16)
  142. }
  143. m.MarshalUint32(uint32(len(o.Addresses)))
  144. for i := range o.Addresses {
  145. if err := o.Addresses[i].MarshalXDRInto(m); err != nil {
  146. return err
  147. }
  148. }
  149. if l := len(o.Relays); l > 16 {
  150. return xdr.ElementSizeExceeded("Relays", l, 16)
  151. }
  152. m.MarshalUint32(uint32(len(o.Relays)))
  153. for i := range o.Relays {
  154. if err := o.Relays[i].MarshalXDRInto(m); err != nil {
  155. return err
  156. }
  157. }
  158. return m.Error
  159. }
  160. func (o *Device) UnmarshalXDR(bs []byte) error {
  161. u := &xdr.Unmarshaller{Data: bs}
  162. return o.UnmarshalXDRFrom(u)
  163. }
  164. func (o *Device) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  165. o.ID = u.UnmarshalBytesMax(32)
  166. _AddressesSize := int(u.UnmarshalUint32())
  167. if _AddressesSize < 0 {
  168. return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 16)
  169. } else if _AddressesSize == 0 {
  170. o.Addresses = nil
  171. } else {
  172. if _AddressesSize > 16 {
  173. return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 16)
  174. }
  175. if _AddressesSize <= len(o.Addresses) {
  176. o.Addresses = o.Addresses[:_AddressesSize]
  177. } else {
  178. o.Addresses = make([]Address, _AddressesSize)
  179. }
  180. for i := range o.Addresses {
  181. (&o.Addresses[i]).UnmarshalXDRFrom(u)
  182. }
  183. }
  184. _RelaysSize := int(u.UnmarshalUint32())
  185. if _RelaysSize < 0 {
  186. return xdr.ElementSizeExceeded("Relays", _RelaysSize, 16)
  187. } else if _RelaysSize == 0 {
  188. o.Relays = nil
  189. } else {
  190. if _RelaysSize > 16 {
  191. return xdr.ElementSizeExceeded("Relays", _RelaysSize, 16)
  192. }
  193. if _RelaysSize <= len(o.Relays) {
  194. o.Relays = o.Relays[:_RelaysSize]
  195. } else {
  196. o.Relays = make([]Relay, _RelaysSize)
  197. }
  198. for i := range o.Relays {
  199. (&o.Relays[i]).UnmarshalXDRFrom(u)
  200. }
  201. }
  202. return u.Error
  203. }
  204. /*
  205. Address Structure:
  206. 0 1 2 3
  207. 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
  208. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  209. / /
  210. \ URL (length + padded data) \
  211. / /
  212. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  213. struct Address {
  214. string URL<2083>;
  215. }
  216. */
  217. func (o Address) XDRSize() int {
  218. return 4 + len(o.URL) + xdr.Padding(len(o.URL))
  219. }
  220. func (o Address) MarshalXDR() ([]byte, error) {
  221. buf := make([]byte, o.XDRSize())
  222. m := &xdr.Marshaller{Data: buf}
  223. return buf, o.MarshalXDRInto(m)
  224. }
  225. func (o Address) MustMarshalXDR() []byte {
  226. bs, err := o.MarshalXDR()
  227. if err != nil {
  228. panic(err)
  229. }
  230. return bs
  231. }
  232. func (o Address) MarshalXDRInto(m *xdr.Marshaller) error {
  233. if l := len(o.URL); l > 2083 {
  234. return xdr.ElementSizeExceeded("URL", l, 2083)
  235. }
  236. m.MarshalString(o.URL)
  237. return m.Error
  238. }
  239. func (o *Address) UnmarshalXDR(bs []byte) error {
  240. u := &xdr.Unmarshaller{Data: bs}
  241. return o.UnmarshalXDRFrom(u)
  242. }
  243. func (o *Address) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  244. o.URL = u.UnmarshalStringMax(2083)
  245. return u.Error
  246. }
  247. /*
  248. Relay Structure:
  249. 0 1 2 3
  250. 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
  251. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  252. / /
  253. \ URL (length + padded data) \
  254. / /
  255. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  256. | Latency |
  257. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  258. struct Relay {
  259. string URL<2083>;
  260. int Latency;
  261. }
  262. */
  263. func (o Relay) XDRSize() int {
  264. return 4 + len(o.URL) + xdr.Padding(len(o.URL)) + 4
  265. }
  266. func (o Relay) MarshalXDR() ([]byte, error) {
  267. buf := make([]byte, o.XDRSize())
  268. m := &xdr.Marshaller{Data: buf}
  269. return buf, o.MarshalXDRInto(m)
  270. }
  271. func (o Relay) MustMarshalXDR() []byte {
  272. bs, err := o.MarshalXDR()
  273. if err != nil {
  274. panic(err)
  275. }
  276. return bs
  277. }
  278. func (o Relay) MarshalXDRInto(m *xdr.Marshaller) error {
  279. if l := len(o.URL); l > 2083 {
  280. return xdr.ElementSizeExceeded("URL", l, 2083)
  281. }
  282. m.MarshalString(o.URL)
  283. m.MarshalUint32(uint32(o.Latency))
  284. return m.Error
  285. }
  286. func (o *Relay) UnmarshalXDR(bs []byte) error {
  287. u := &xdr.Unmarshaller{Data: bs}
  288. return o.UnmarshalXDRFrom(u)
  289. }
  290. func (o *Relay) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  291. o.URL = u.UnmarshalStringMax(2083)
  292. o.Latency = int32(u.UnmarshalUint32())
  293. return u.Error
  294. }