message_xdr.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. // ************************************************************
  2. // This file is automatically generated by genxdr. Do not edit.
  3. // ************************************************************
  4. package protocol
  5. import (
  6. "bytes"
  7. "io"
  8. "github.com/calmh/xdr"
  9. )
  10. /*
  11. IndexMessage Structure:
  12. 0 1 2 3
  13. 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
  14. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  15. | Length of Folder |
  16. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  17. / /
  18. \ Folder (variable length) \
  19. / /
  20. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  21. | Number of Files |
  22. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  23. / /
  24. \ Zero or more FileInfo Structures \
  25. / /
  26. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  27. | Flags |
  28. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  29. | Number of Options |
  30. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  31. / /
  32. \ Zero or more Option Structures \
  33. / /
  34. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  35. struct IndexMessage {
  36. string Folder<256>;
  37. FileInfo Files<1000000>;
  38. unsigned int Flags;
  39. Option Options<64>;
  40. }
  41. */
  42. func (o IndexMessage) EncodeXDR(w io.Writer) (int, error) {
  43. var xw = xdr.NewWriter(w)
  44. return o.EncodeXDRInto(xw)
  45. }
  46. func (o IndexMessage) MarshalXDR() ([]byte, error) {
  47. return o.AppendXDR(make([]byte, 0, 128))
  48. }
  49. func (o IndexMessage) MustMarshalXDR() []byte {
  50. bs, err := o.MarshalXDR()
  51. if err != nil {
  52. panic(err)
  53. }
  54. return bs
  55. }
  56. func (o IndexMessage) AppendXDR(bs []byte) ([]byte, error) {
  57. var aw = xdr.AppendWriter(bs)
  58. var xw = xdr.NewWriter(&aw)
  59. _, err := o.EncodeXDRInto(xw)
  60. return []byte(aw), err
  61. }
  62. func (o IndexMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  63. if l := len(o.Folder); l > 256 {
  64. return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 256)
  65. }
  66. xw.WriteString(o.Folder)
  67. if l := len(o.Files); l > 1000000 {
  68. return xw.Tot(), xdr.ElementSizeExceeded("Files", l, 1000000)
  69. }
  70. xw.WriteUint32(uint32(len(o.Files)))
  71. for i := range o.Files {
  72. _, err := o.Files[i].EncodeXDRInto(xw)
  73. if err != nil {
  74. return xw.Tot(), err
  75. }
  76. }
  77. xw.WriteUint32(o.Flags)
  78. if l := len(o.Options); l > 64 {
  79. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  80. }
  81. xw.WriteUint32(uint32(len(o.Options)))
  82. for i := range o.Options {
  83. _, err := o.Options[i].EncodeXDRInto(xw)
  84. if err != nil {
  85. return xw.Tot(), err
  86. }
  87. }
  88. return xw.Tot(), xw.Error()
  89. }
  90. func (o *IndexMessage) DecodeXDR(r io.Reader) error {
  91. xr := xdr.NewReader(r)
  92. return o.DecodeXDRFrom(xr)
  93. }
  94. func (o *IndexMessage) UnmarshalXDR(bs []byte) error {
  95. var br = bytes.NewReader(bs)
  96. var xr = xdr.NewReader(br)
  97. return o.DecodeXDRFrom(xr)
  98. }
  99. func (o *IndexMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  100. o.Folder = xr.ReadStringMax(256)
  101. _FilesSize := int(xr.ReadUint32())
  102. if _FilesSize < 0 {
  103. return xdr.ElementSizeExceeded("Files", _FilesSize, 1000000)
  104. }
  105. if _FilesSize > 1000000 {
  106. return xdr.ElementSizeExceeded("Files", _FilesSize, 1000000)
  107. }
  108. o.Files = make([]FileInfo, _FilesSize)
  109. for i := range o.Files {
  110. (&o.Files[i]).DecodeXDRFrom(xr)
  111. }
  112. o.Flags = xr.ReadUint32()
  113. _OptionsSize := int(xr.ReadUint32())
  114. if _OptionsSize < 0 {
  115. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  116. }
  117. if _OptionsSize > 64 {
  118. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  119. }
  120. o.Options = make([]Option, _OptionsSize)
  121. for i := range o.Options {
  122. (&o.Options[i]).DecodeXDRFrom(xr)
  123. }
  124. return xr.Error()
  125. }
  126. /*
  127. FileInfo Structure:
  128. 0 1 2 3
  129. 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
  130. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  131. | Length of Name |
  132. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  133. / /
  134. \ Name (variable length) \
  135. / /
  136. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  137. | Flags |
  138. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  139. | |
  140. + Modified (64 bits) +
  141. | |
  142. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  143. / /
  144. \ Vector Structure \
  145. / /
  146. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  147. | |
  148. + Local Version (64 bits) +
  149. | |
  150. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  151. | Number of Blocks |
  152. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  153. / /
  154. \ Zero or more BlockInfo Structures \
  155. / /
  156. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  157. struct FileInfo {
  158. string Name<8192>;
  159. unsigned int Flags;
  160. hyper Modified;
  161. Vector Version;
  162. hyper LocalVersion;
  163. BlockInfo Blocks<1000000>;
  164. }
  165. */
  166. func (o FileInfo) EncodeXDR(w io.Writer) (int, error) {
  167. var xw = xdr.NewWriter(w)
  168. return o.EncodeXDRInto(xw)
  169. }
  170. func (o FileInfo) MarshalXDR() ([]byte, error) {
  171. return o.AppendXDR(make([]byte, 0, 128))
  172. }
  173. func (o FileInfo) MustMarshalXDR() []byte {
  174. bs, err := o.MarshalXDR()
  175. if err != nil {
  176. panic(err)
  177. }
  178. return bs
  179. }
  180. func (o FileInfo) AppendXDR(bs []byte) ([]byte, error) {
  181. var aw = xdr.AppendWriter(bs)
  182. var xw = xdr.NewWriter(&aw)
  183. _, err := o.EncodeXDRInto(xw)
  184. return []byte(aw), err
  185. }
  186. func (o FileInfo) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  187. if l := len(o.Name); l > 8192 {
  188. return xw.Tot(), xdr.ElementSizeExceeded("Name", l, 8192)
  189. }
  190. xw.WriteString(o.Name)
  191. xw.WriteUint32(o.Flags)
  192. xw.WriteUint64(uint64(o.Modified))
  193. _, err := o.Version.EncodeXDRInto(xw)
  194. if err != nil {
  195. return xw.Tot(), err
  196. }
  197. xw.WriteUint64(uint64(o.LocalVersion))
  198. if l := len(o.Blocks); l > 1000000 {
  199. return xw.Tot(), xdr.ElementSizeExceeded("Blocks", l, 1000000)
  200. }
  201. xw.WriteUint32(uint32(len(o.Blocks)))
  202. for i := range o.Blocks {
  203. _, err := o.Blocks[i].EncodeXDRInto(xw)
  204. if err != nil {
  205. return xw.Tot(), err
  206. }
  207. }
  208. return xw.Tot(), xw.Error()
  209. }
  210. func (o *FileInfo) DecodeXDR(r io.Reader) error {
  211. xr := xdr.NewReader(r)
  212. return o.DecodeXDRFrom(xr)
  213. }
  214. func (o *FileInfo) UnmarshalXDR(bs []byte) error {
  215. var br = bytes.NewReader(bs)
  216. var xr = xdr.NewReader(br)
  217. return o.DecodeXDRFrom(xr)
  218. }
  219. func (o *FileInfo) DecodeXDRFrom(xr *xdr.Reader) error {
  220. o.Name = xr.ReadStringMax(8192)
  221. o.Flags = xr.ReadUint32()
  222. o.Modified = int64(xr.ReadUint64())
  223. (&o.Version).DecodeXDRFrom(xr)
  224. o.LocalVersion = int64(xr.ReadUint64())
  225. _BlocksSize := int(xr.ReadUint32())
  226. if _BlocksSize < 0 {
  227. return xdr.ElementSizeExceeded("Blocks", _BlocksSize, 1000000)
  228. }
  229. if _BlocksSize > 1000000 {
  230. return xdr.ElementSizeExceeded("Blocks", _BlocksSize, 1000000)
  231. }
  232. o.Blocks = make([]BlockInfo, _BlocksSize)
  233. for i := range o.Blocks {
  234. (&o.Blocks[i]).DecodeXDRFrom(xr)
  235. }
  236. return xr.Error()
  237. }
  238. /*
  239. BlockInfo Structure:
  240. 0 1 2 3
  241. 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
  242. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  243. | Size |
  244. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  245. | Length of Hash |
  246. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  247. / /
  248. \ Hash (variable length) \
  249. / /
  250. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  251. struct BlockInfo {
  252. int Size;
  253. opaque Hash<64>;
  254. }
  255. */
  256. func (o BlockInfo) EncodeXDR(w io.Writer) (int, error) {
  257. var xw = xdr.NewWriter(w)
  258. return o.EncodeXDRInto(xw)
  259. }
  260. func (o BlockInfo) MarshalXDR() ([]byte, error) {
  261. return o.AppendXDR(make([]byte, 0, 128))
  262. }
  263. func (o BlockInfo) MustMarshalXDR() []byte {
  264. bs, err := o.MarshalXDR()
  265. if err != nil {
  266. panic(err)
  267. }
  268. return bs
  269. }
  270. func (o BlockInfo) AppendXDR(bs []byte) ([]byte, error) {
  271. var aw = xdr.AppendWriter(bs)
  272. var xw = xdr.NewWriter(&aw)
  273. _, err := o.EncodeXDRInto(xw)
  274. return []byte(aw), err
  275. }
  276. func (o BlockInfo) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  277. xw.WriteUint32(uint32(o.Size))
  278. if l := len(o.Hash); l > 64 {
  279. return xw.Tot(), xdr.ElementSizeExceeded("Hash", l, 64)
  280. }
  281. xw.WriteBytes(o.Hash)
  282. return xw.Tot(), xw.Error()
  283. }
  284. func (o *BlockInfo) DecodeXDR(r io.Reader) error {
  285. xr := xdr.NewReader(r)
  286. return o.DecodeXDRFrom(xr)
  287. }
  288. func (o *BlockInfo) UnmarshalXDR(bs []byte) error {
  289. var br = bytes.NewReader(bs)
  290. var xr = xdr.NewReader(br)
  291. return o.DecodeXDRFrom(xr)
  292. }
  293. func (o *BlockInfo) DecodeXDRFrom(xr *xdr.Reader) error {
  294. o.Size = int32(xr.ReadUint32())
  295. o.Hash = xr.ReadBytesMax(64)
  296. return xr.Error()
  297. }
  298. /*
  299. RequestMessage Structure:
  300. 0 1 2 3
  301. 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
  302. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  303. | Length of Folder |
  304. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  305. / /
  306. \ Folder (variable length) \
  307. / /
  308. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  309. | Length of Name |
  310. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  311. / /
  312. \ Name (variable length) \
  313. / /
  314. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  315. | |
  316. + Offset (64 bits) +
  317. | |
  318. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  319. | Size |
  320. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  321. | Length of Hash |
  322. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  323. / /
  324. \ Hash (variable length) \
  325. / /
  326. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  327. | Flags |
  328. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  329. | Number of Options |
  330. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  331. / /
  332. \ Zero or more Option Structures \
  333. / /
  334. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  335. struct RequestMessage {
  336. string Folder<256>;
  337. string Name<8192>;
  338. hyper Offset;
  339. int Size;
  340. opaque Hash<64>;
  341. unsigned int Flags;
  342. Option Options<64>;
  343. }
  344. */
  345. func (o RequestMessage) EncodeXDR(w io.Writer) (int, error) {
  346. var xw = xdr.NewWriter(w)
  347. return o.EncodeXDRInto(xw)
  348. }
  349. func (o RequestMessage) MarshalXDR() ([]byte, error) {
  350. return o.AppendXDR(make([]byte, 0, 128))
  351. }
  352. func (o RequestMessage) MustMarshalXDR() []byte {
  353. bs, err := o.MarshalXDR()
  354. if err != nil {
  355. panic(err)
  356. }
  357. return bs
  358. }
  359. func (o RequestMessage) AppendXDR(bs []byte) ([]byte, error) {
  360. var aw = xdr.AppendWriter(bs)
  361. var xw = xdr.NewWriter(&aw)
  362. _, err := o.EncodeXDRInto(xw)
  363. return []byte(aw), err
  364. }
  365. func (o RequestMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  366. if l := len(o.Folder); l > 256 {
  367. return xw.Tot(), xdr.ElementSizeExceeded("Folder", l, 256)
  368. }
  369. xw.WriteString(o.Folder)
  370. if l := len(o.Name); l > 8192 {
  371. return xw.Tot(), xdr.ElementSizeExceeded("Name", l, 8192)
  372. }
  373. xw.WriteString(o.Name)
  374. xw.WriteUint64(uint64(o.Offset))
  375. xw.WriteUint32(uint32(o.Size))
  376. if l := len(o.Hash); l > 64 {
  377. return xw.Tot(), xdr.ElementSizeExceeded("Hash", l, 64)
  378. }
  379. xw.WriteBytes(o.Hash)
  380. xw.WriteUint32(o.Flags)
  381. if l := len(o.Options); l > 64 {
  382. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  383. }
  384. xw.WriteUint32(uint32(len(o.Options)))
  385. for i := range o.Options {
  386. _, err := o.Options[i].EncodeXDRInto(xw)
  387. if err != nil {
  388. return xw.Tot(), err
  389. }
  390. }
  391. return xw.Tot(), xw.Error()
  392. }
  393. func (o *RequestMessage) DecodeXDR(r io.Reader) error {
  394. xr := xdr.NewReader(r)
  395. return o.DecodeXDRFrom(xr)
  396. }
  397. func (o *RequestMessage) UnmarshalXDR(bs []byte) error {
  398. var br = bytes.NewReader(bs)
  399. var xr = xdr.NewReader(br)
  400. return o.DecodeXDRFrom(xr)
  401. }
  402. func (o *RequestMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  403. o.Folder = xr.ReadStringMax(256)
  404. o.Name = xr.ReadStringMax(8192)
  405. o.Offset = int64(xr.ReadUint64())
  406. o.Size = int32(xr.ReadUint32())
  407. o.Hash = xr.ReadBytesMax(64)
  408. o.Flags = xr.ReadUint32()
  409. _OptionsSize := int(xr.ReadUint32())
  410. if _OptionsSize < 0 {
  411. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  412. }
  413. if _OptionsSize > 64 {
  414. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  415. }
  416. o.Options = make([]Option, _OptionsSize)
  417. for i := range o.Options {
  418. (&o.Options[i]).DecodeXDRFrom(xr)
  419. }
  420. return xr.Error()
  421. }
  422. /*
  423. ResponseMessage Structure:
  424. 0 1 2 3
  425. 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
  426. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  427. | Length of Data |
  428. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  429. / /
  430. \ Data (variable length) \
  431. / /
  432. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  433. | Code |
  434. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  435. struct ResponseMessage {
  436. opaque Data<>;
  437. int Code;
  438. }
  439. */
  440. func (o ResponseMessage) EncodeXDR(w io.Writer) (int, error) {
  441. var xw = xdr.NewWriter(w)
  442. return o.EncodeXDRInto(xw)
  443. }
  444. func (o ResponseMessage) MarshalXDR() ([]byte, error) {
  445. return o.AppendXDR(make([]byte, 0, 128))
  446. }
  447. func (o ResponseMessage) MustMarshalXDR() []byte {
  448. bs, err := o.MarshalXDR()
  449. if err != nil {
  450. panic(err)
  451. }
  452. return bs
  453. }
  454. func (o ResponseMessage) AppendXDR(bs []byte) ([]byte, error) {
  455. var aw = xdr.AppendWriter(bs)
  456. var xw = xdr.NewWriter(&aw)
  457. _, err := o.EncodeXDRInto(xw)
  458. return []byte(aw), err
  459. }
  460. func (o ResponseMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  461. xw.WriteBytes(o.Data)
  462. xw.WriteUint32(uint32(o.Code))
  463. return xw.Tot(), xw.Error()
  464. }
  465. func (o *ResponseMessage) DecodeXDR(r io.Reader) error {
  466. xr := xdr.NewReader(r)
  467. return o.DecodeXDRFrom(xr)
  468. }
  469. func (o *ResponseMessage) UnmarshalXDR(bs []byte) error {
  470. var br = bytes.NewReader(bs)
  471. var xr = xdr.NewReader(br)
  472. return o.DecodeXDRFrom(xr)
  473. }
  474. func (o *ResponseMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  475. o.Data = xr.ReadBytes()
  476. o.Code = int32(xr.ReadUint32())
  477. return xr.Error()
  478. }
  479. /*
  480. ClusterConfigMessage Structure:
  481. 0 1 2 3
  482. 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
  483. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  484. | Length of Device Name |
  485. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  486. / /
  487. \ Device Name (variable length) \
  488. / /
  489. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  490. | Length of Client Name |
  491. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  492. / /
  493. \ Client Name (variable length) \
  494. / /
  495. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  496. | Length of Client Version |
  497. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  498. / /
  499. \ Client Version (variable length) \
  500. / /
  501. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  502. | Number of Folders |
  503. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  504. / /
  505. \ Zero or more Folder Structures \
  506. / /
  507. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  508. | Number of Options |
  509. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  510. / /
  511. \ Zero or more Option Structures \
  512. / /
  513. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  514. struct ClusterConfigMessage {
  515. string DeviceName<64>;
  516. string ClientName<64>;
  517. string ClientVersion<64>;
  518. Folder Folders<1000000>;
  519. Option Options<64>;
  520. }
  521. */
  522. func (o ClusterConfigMessage) EncodeXDR(w io.Writer) (int, error) {
  523. var xw = xdr.NewWriter(w)
  524. return o.EncodeXDRInto(xw)
  525. }
  526. func (o ClusterConfigMessage) MarshalXDR() ([]byte, error) {
  527. return o.AppendXDR(make([]byte, 0, 128))
  528. }
  529. func (o ClusterConfigMessage) MustMarshalXDR() []byte {
  530. bs, err := o.MarshalXDR()
  531. if err != nil {
  532. panic(err)
  533. }
  534. return bs
  535. }
  536. func (o ClusterConfigMessage) AppendXDR(bs []byte) ([]byte, error) {
  537. var aw = xdr.AppendWriter(bs)
  538. var xw = xdr.NewWriter(&aw)
  539. _, err := o.EncodeXDRInto(xw)
  540. return []byte(aw), err
  541. }
  542. func (o ClusterConfigMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  543. if l := len(o.DeviceName); l > 64 {
  544. return xw.Tot(), xdr.ElementSizeExceeded("DeviceName", l, 64)
  545. }
  546. xw.WriteString(o.DeviceName)
  547. if l := len(o.ClientName); l > 64 {
  548. return xw.Tot(), xdr.ElementSizeExceeded("ClientName", l, 64)
  549. }
  550. xw.WriteString(o.ClientName)
  551. if l := len(o.ClientVersion); l > 64 {
  552. return xw.Tot(), xdr.ElementSizeExceeded("ClientVersion", l, 64)
  553. }
  554. xw.WriteString(o.ClientVersion)
  555. if l := len(o.Folders); l > 1000000 {
  556. return xw.Tot(), xdr.ElementSizeExceeded("Folders", l, 1000000)
  557. }
  558. xw.WriteUint32(uint32(len(o.Folders)))
  559. for i := range o.Folders {
  560. _, err := o.Folders[i].EncodeXDRInto(xw)
  561. if err != nil {
  562. return xw.Tot(), err
  563. }
  564. }
  565. if l := len(o.Options); l > 64 {
  566. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  567. }
  568. xw.WriteUint32(uint32(len(o.Options)))
  569. for i := range o.Options {
  570. _, err := o.Options[i].EncodeXDRInto(xw)
  571. if err != nil {
  572. return xw.Tot(), err
  573. }
  574. }
  575. return xw.Tot(), xw.Error()
  576. }
  577. func (o *ClusterConfigMessage) DecodeXDR(r io.Reader) error {
  578. xr := xdr.NewReader(r)
  579. return o.DecodeXDRFrom(xr)
  580. }
  581. func (o *ClusterConfigMessage) UnmarshalXDR(bs []byte) error {
  582. var br = bytes.NewReader(bs)
  583. var xr = xdr.NewReader(br)
  584. return o.DecodeXDRFrom(xr)
  585. }
  586. func (o *ClusterConfigMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  587. o.DeviceName = xr.ReadStringMax(64)
  588. o.ClientName = xr.ReadStringMax(64)
  589. o.ClientVersion = xr.ReadStringMax(64)
  590. _FoldersSize := int(xr.ReadUint32())
  591. if _FoldersSize < 0 {
  592. return xdr.ElementSizeExceeded("Folders", _FoldersSize, 1000000)
  593. }
  594. if _FoldersSize > 1000000 {
  595. return xdr.ElementSizeExceeded("Folders", _FoldersSize, 1000000)
  596. }
  597. o.Folders = make([]Folder, _FoldersSize)
  598. for i := range o.Folders {
  599. (&o.Folders[i]).DecodeXDRFrom(xr)
  600. }
  601. _OptionsSize := int(xr.ReadUint32())
  602. if _OptionsSize < 0 {
  603. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  604. }
  605. if _OptionsSize > 64 {
  606. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  607. }
  608. o.Options = make([]Option, _OptionsSize)
  609. for i := range o.Options {
  610. (&o.Options[i]).DecodeXDRFrom(xr)
  611. }
  612. return xr.Error()
  613. }
  614. /*
  615. Folder Structure:
  616. 0 1 2 3
  617. 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
  618. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  619. | Length of ID |
  620. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  621. / /
  622. \ ID (variable length) \
  623. / /
  624. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  625. | Number of Devices |
  626. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  627. / /
  628. \ Zero or more Device Structures \
  629. / /
  630. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  631. | Flags |
  632. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  633. | Number of Options |
  634. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  635. / /
  636. \ Zero or more Option Structures \
  637. / /
  638. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  639. struct Folder {
  640. string ID<256>;
  641. Device Devices<1000000>;
  642. unsigned int Flags;
  643. Option Options<64>;
  644. }
  645. */
  646. func (o Folder) EncodeXDR(w io.Writer) (int, error) {
  647. var xw = xdr.NewWriter(w)
  648. return o.EncodeXDRInto(xw)
  649. }
  650. func (o Folder) MarshalXDR() ([]byte, error) {
  651. return o.AppendXDR(make([]byte, 0, 128))
  652. }
  653. func (o Folder) MustMarshalXDR() []byte {
  654. bs, err := o.MarshalXDR()
  655. if err != nil {
  656. panic(err)
  657. }
  658. return bs
  659. }
  660. func (o Folder) AppendXDR(bs []byte) ([]byte, error) {
  661. var aw = xdr.AppendWriter(bs)
  662. var xw = xdr.NewWriter(&aw)
  663. _, err := o.EncodeXDRInto(xw)
  664. return []byte(aw), err
  665. }
  666. func (o Folder) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  667. if l := len(o.ID); l > 256 {
  668. return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 256)
  669. }
  670. xw.WriteString(o.ID)
  671. if l := len(o.Devices); l > 1000000 {
  672. return xw.Tot(), xdr.ElementSizeExceeded("Devices", l, 1000000)
  673. }
  674. xw.WriteUint32(uint32(len(o.Devices)))
  675. for i := range o.Devices {
  676. _, err := o.Devices[i].EncodeXDRInto(xw)
  677. if err != nil {
  678. return xw.Tot(), err
  679. }
  680. }
  681. xw.WriteUint32(o.Flags)
  682. if l := len(o.Options); l > 64 {
  683. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  684. }
  685. xw.WriteUint32(uint32(len(o.Options)))
  686. for i := range o.Options {
  687. _, err := o.Options[i].EncodeXDRInto(xw)
  688. if err != nil {
  689. return xw.Tot(), err
  690. }
  691. }
  692. return xw.Tot(), xw.Error()
  693. }
  694. func (o *Folder) DecodeXDR(r io.Reader) error {
  695. xr := xdr.NewReader(r)
  696. return o.DecodeXDRFrom(xr)
  697. }
  698. func (o *Folder) UnmarshalXDR(bs []byte) error {
  699. var br = bytes.NewReader(bs)
  700. var xr = xdr.NewReader(br)
  701. return o.DecodeXDRFrom(xr)
  702. }
  703. func (o *Folder) DecodeXDRFrom(xr *xdr.Reader) error {
  704. o.ID = xr.ReadStringMax(256)
  705. _DevicesSize := int(xr.ReadUint32())
  706. if _DevicesSize < 0 {
  707. return xdr.ElementSizeExceeded("Devices", _DevicesSize, 1000000)
  708. }
  709. if _DevicesSize > 1000000 {
  710. return xdr.ElementSizeExceeded("Devices", _DevicesSize, 1000000)
  711. }
  712. o.Devices = make([]Device, _DevicesSize)
  713. for i := range o.Devices {
  714. (&o.Devices[i]).DecodeXDRFrom(xr)
  715. }
  716. o.Flags = xr.ReadUint32()
  717. _OptionsSize := int(xr.ReadUint32())
  718. if _OptionsSize < 0 {
  719. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  720. }
  721. if _OptionsSize > 64 {
  722. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  723. }
  724. o.Options = make([]Option, _OptionsSize)
  725. for i := range o.Options {
  726. (&o.Options[i]).DecodeXDRFrom(xr)
  727. }
  728. return xr.Error()
  729. }
  730. /*
  731. Device Structure:
  732. 0 1 2 3
  733. 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
  734. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  735. | Length of ID |
  736. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  737. / /
  738. \ ID (variable length) \
  739. / /
  740. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  741. | |
  742. + Max Local Version (64 bits) +
  743. | |
  744. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  745. | Flags |
  746. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  747. | Number of Options |
  748. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  749. / /
  750. \ Zero or more Option Structures \
  751. / /
  752. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  753. struct Device {
  754. opaque ID<32>;
  755. hyper MaxLocalVersion;
  756. unsigned int Flags;
  757. Option Options<64>;
  758. }
  759. */
  760. func (o Device) EncodeXDR(w io.Writer) (int, error) {
  761. var xw = xdr.NewWriter(w)
  762. return o.EncodeXDRInto(xw)
  763. }
  764. func (o Device) MarshalXDR() ([]byte, error) {
  765. return o.AppendXDR(make([]byte, 0, 128))
  766. }
  767. func (o Device) MustMarshalXDR() []byte {
  768. bs, err := o.MarshalXDR()
  769. if err != nil {
  770. panic(err)
  771. }
  772. return bs
  773. }
  774. func (o Device) AppendXDR(bs []byte) ([]byte, error) {
  775. var aw = xdr.AppendWriter(bs)
  776. var xw = xdr.NewWriter(&aw)
  777. _, err := o.EncodeXDRInto(xw)
  778. return []byte(aw), err
  779. }
  780. func (o Device) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  781. if l := len(o.ID); l > 32 {
  782. return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 32)
  783. }
  784. xw.WriteBytes(o.ID)
  785. xw.WriteUint64(uint64(o.MaxLocalVersion))
  786. xw.WriteUint32(o.Flags)
  787. if l := len(o.Options); l > 64 {
  788. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  789. }
  790. xw.WriteUint32(uint32(len(o.Options)))
  791. for i := range o.Options {
  792. _, err := o.Options[i].EncodeXDRInto(xw)
  793. if err != nil {
  794. return xw.Tot(), err
  795. }
  796. }
  797. return xw.Tot(), xw.Error()
  798. }
  799. func (o *Device) DecodeXDR(r io.Reader) error {
  800. xr := xdr.NewReader(r)
  801. return o.DecodeXDRFrom(xr)
  802. }
  803. func (o *Device) UnmarshalXDR(bs []byte) error {
  804. var br = bytes.NewReader(bs)
  805. var xr = xdr.NewReader(br)
  806. return o.DecodeXDRFrom(xr)
  807. }
  808. func (o *Device) DecodeXDRFrom(xr *xdr.Reader) error {
  809. o.ID = xr.ReadBytesMax(32)
  810. o.MaxLocalVersion = int64(xr.ReadUint64())
  811. o.Flags = xr.ReadUint32()
  812. _OptionsSize := int(xr.ReadUint32())
  813. if _OptionsSize < 0 {
  814. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  815. }
  816. if _OptionsSize > 64 {
  817. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  818. }
  819. o.Options = make([]Option, _OptionsSize)
  820. for i := range o.Options {
  821. (&o.Options[i]).DecodeXDRFrom(xr)
  822. }
  823. return xr.Error()
  824. }
  825. /*
  826. Option Structure:
  827. 0 1 2 3
  828. 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
  829. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  830. | Length of Key |
  831. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  832. / /
  833. \ Key (variable length) \
  834. / /
  835. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  836. | Length of Value |
  837. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  838. / /
  839. \ Value (variable length) \
  840. / /
  841. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  842. struct Option {
  843. string Key<64>;
  844. string Value<1024>;
  845. }
  846. */
  847. func (o Option) EncodeXDR(w io.Writer) (int, error) {
  848. var xw = xdr.NewWriter(w)
  849. return o.EncodeXDRInto(xw)
  850. }
  851. func (o Option) MarshalXDR() ([]byte, error) {
  852. return o.AppendXDR(make([]byte, 0, 128))
  853. }
  854. func (o Option) MustMarshalXDR() []byte {
  855. bs, err := o.MarshalXDR()
  856. if err != nil {
  857. panic(err)
  858. }
  859. return bs
  860. }
  861. func (o Option) AppendXDR(bs []byte) ([]byte, error) {
  862. var aw = xdr.AppendWriter(bs)
  863. var xw = xdr.NewWriter(&aw)
  864. _, err := o.EncodeXDRInto(xw)
  865. return []byte(aw), err
  866. }
  867. func (o Option) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  868. if l := len(o.Key); l > 64 {
  869. return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 64)
  870. }
  871. xw.WriteString(o.Key)
  872. if l := len(o.Value); l > 1024 {
  873. return xw.Tot(), xdr.ElementSizeExceeded("Value", l, 1024)
  874. }
  875. xw.WriteString(o.Value)
  876. return xw.Tot(), xw.Error()
  877. }
  878. func (o *Option) DecodeXDR(r io.Reader) error {
  879. xr := xdr.NewReader(r)
  880. return o.DecodeXDRFrom(xr)
  881. }
  882. func (o *Option) UnmarshalXDR(bs []byte) error {
  883. var br = bytes.NewReader(bs)
  884. var xr = xdr.NewReader(br)
  885. return o.DecodeXDRFrom(xr)
  886. }
  887. func (o *Option) DecodeXDRFrom(xr *xdr.Reader) error {
  888. o.Key = xr.ReadStringMax(64)
  889. o.Value = xr.ReadStringMax(1024)
  890. return xr.Error()
  891. }
  892. /*
  893. CloseMessage Structure:
  894. 0 1 2 3
  895. 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
  896. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  897. | Length of Reason |
  898. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  899. / /
  900. \ Reason (variable length) \
  901. / /
  902. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  903. | Code |
  904. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  905. struct CloseMessage {
  906. string Reason<1024>;
  907. int Code;
  908. }
  909. */
  910. func (o CloseMessage) EncodeXDR(w io.Writer) (int, error) {
  911. var xw = xdr.NewWriter(w)
  912. return o.EncodeXDRInto(xw)
  913. }
  914. func (o CloseMessage) MarshalXDR() ([]byte, error) {
  915. return o.AppendXDR(make([]byte, 0, 128))
  916. }
  917. func (o CloseMessage) MustMarshalXDR() []byte {
  918. bs, err := o.MarshalXDR()
  919. if err != nil {
  920. panic(err)
  921. }
  922. return bs
  923. }
  924. func (o CloseMessage) AppendXDR(bs []byte) ([]byte, error) {
  925. var aw = xdr.AppendWriter(bs)
  926. var xw = xdr.NewWriter(&aw)
  927. _, err := o.EncodeXDRInto(xw)
  928. return []byte(aw), err
  929. }
  930. func (o CloseMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  931. if l := len(o.Reason); l > 1024 {
  932. return xw.Tot(), xdr.ElementSizeExceeded("Reason", l, 1024)
  933. }
  934. xw.WriteString(o.Reason)
  935. xw.WriteUint32(uint32(o.Code))
  936. return xw.Tot(), xw.Error()
  937. }
  938. func (o *CloseMessage) DecodeXDR(r io.Reader) error {
  939. xr := xdr.NewReader(r)
  940. return o.DecodeXDRFrom(xr)
  941. }
  942. func (o *CloseMessage) UnmarshalXDR(bs []byte) error {
  943. var br = bytes.NewReader(bs)
  944. var xr = xdr.NewReader(br)
  945. return o.DecodeXDRFrom(xr)
  946. }
  947. func (o *CloseMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  948. o.Reason = xr.ReadStringMax(1024)
  949. o.Code = int32(xr.ReadUint32())
  950. return xr.Error()
  951. }
  952. /*
  953. EmptyMessage Structure:
  954. 0 1 2 3
  955. 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
  956. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  957. struct EmptyMessage {
  958. }
  959. */
  960. func (o EmptyMessage) EncodeXDR(w io.Writer) (int, error) {
  961. var xw = xdr.NewWriter(w)
  962. return o.EncodeXDRInto(xw)
  963. }
  964. func (o EmptyMessage) MarshalXDR() ([]byte, error) {
  965. return o.AppendXDR(make([]byte, 0, 128))
  966. }
  967. func (o EmptyMessage) MustMarshalXDR() []byte {
  968. bs, err := o.MarshalXDR()
  969. if err != nil {
  970. panic(err)
  971. }
  972. return bs
  973. }
  974. func (o EmptyMessage) AppendXDR(bs []byte) ([]byte, error) {
  975. var aw = xdr.AppendWriter(bs)
  976. var xw = xdr.NewWriter(&aw)
  977. _, err := o.EncodeXDRInto(xw)
  978. return []byte(aw), err
  979. }
  980. func (o EmptyMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  981. return xw.Tot(), xw.Error()
  982. }
  983. func (o *EmptyMessage) DecodeXDR(r io.Reader) error {
  984. xr := xdr.NewReader(r)
  985. return o.DecodeXDRFrom(xr)
  986. }
  987. func (o *EmptyMessage) UnmarshalXDR(bs []byte) error {
  988. var br = bytes.NewReader(bs)
  989. var xr = xdr.NewReader(br)
  990. return o.DecodeXDRFrom(xr)
  991. }
  992. func (o *EmptyMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  993. return xr.Error()
  994. }