message_xdr.go 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  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. | Length of Name |
  742. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  743. / /
  744. \ Name (variable length) \
  745. / /
  746. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  747. | Number of Addresses |
  748. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  749. | Length of Addresses |
  750. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  751. / /
  752. \ Addresses (variable length) \
  753. / /
  754. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  755. | Compression |
  756. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  757. | Length of Cert Name |
  758. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  759. / /
  760. \ Cert Name (variable length) \
  761. / /
  762. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  763. | |
  764. + Max Local Version (64 bits) +
  765. | |
  766. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  767. | Flags |
  768. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  769. | Number of Options |
  770. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  771. / /
  772. \ Zero or more Option Structures \
  773. / /
  774. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  775. struct Device {
  776. opaque ID<32>;
  777. string Name<64>;
  778. string Addresses<64>;
  779. unsigned int Compression;
  780. string CertName<64>;
  781. hyper MaxLocalVersion;
  782. unsigned int Flags;
  783. Option Options<64>;
  784. }
  785. */
  786. func (o Device) EncodeXDR(w io.Writer) (int, error) {
  787. var xw = xdr.NewWriter(w)
  788. return o.EncodeXDRInto(xw)
  789. }
  790. func (o Device) MarshalXDR() ([]byte, error) {
  791. return o.AppendXDR(make([]byte, 0, 128))
  792. }
  793. func (o Device) MustMarshalXDR() []byte {
  794. bs, err := o.MarshalXDR()
  795. if err != nil {
  796. panic(err)
  797. }
  798. return bs
  799. }
  800. func (o Device) AppendXDR(bs []byte) ([]byte, error) {
  801. var aw = xdr.AppendWriter(bs)
  802. var xw = xdr.NewWriter(&aw)
  803. _, err := o.EncodeXDRInto(xw)
  804. return []byte(aw), err
  805. }
  806. func (o Device) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  807. if l := len(o.ID); l > 32 {
  808. return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 32)
  809. }
  810. xw.WriteBytes(o.ID)
  811. if l := len(o.Name); l > 64 {
  812. return xw.Tot(), xdr.ElementSizeExceeded("Name", l, 64)
  813. }
  814. xw.WriteString(o.Name)
  815. if l := len(o.Addresses); l > 64 {
  816. return xw.Tot(), xdr.ElementSizeExceeded("Addresses", l, 64)
  817. }
  818. xw.WriteUint32(uint32(len(o.Addresses)))
  819. for i := range o.Addresses {
  820. xw.WriteString(o.Addresses[i])
  821. }
  822. xw.WriteUint32(o.Compression)
  823. if l := len(o.CertName); l > 64 {
  824. return xw.Tot(), xdr.ElementSizeExceeded("CertName", l, 64)
  825. }
  826. xw.WriteString(o.CertName)
  827. xw.WriteUint64(uint64(o.MaxLocalVersion))
  828. xw.WriteUint32(o.Flags)
  829. if l := len(o.Options); l > 64 {
  830. return xw.Tot(), xdr.ElementSizeExceeded("Options", l, 64)
  831. }
  832. xw.WriteUint32(uint32(len(o.Options)))
  833. for i := range o.Options {
  834. _, err := o.Options[i].EncodeXDRInto(xw)
  835. if err != nil {
  836. return xw.Tot(), err
  837. }
  838. }
  839. return xw.Tot(), xw.Error()
  840. }
  841. func (o *Device) DecodeXDR(r io.Reader) error {
  842. xr := xdr.NewReader(r)
  843. return o.DecodeXDRFrom(xr)
  844. }
  845. func (o *Device) UnmarshalXDR(bs []byte) error {
  846. var br = bytes.NewReader(bs)
  847. var xr = xdr.NewReader(br)
  848. return o.DecodeXDRFrom(xr)
  849. }
  850. func (o *Device) DecodeXDRFrom(xr *xdr.Reader) error {
  851. o.ID = xr.ReadBytesMax(32)
  852. o.Name = xr.ReadStringMax(64)
  853. _AddressesSize := int(xr.ReadUint32())
  854. if _AddressesSize < 0 {
  855. return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 64)
  856. }
  857. if _AddressesSize > 64 {
  858. return xdr.ElementSizeExceeded("Addresses", _AddressesSize, 64)
  859. }
  860. o.Addresses = make([]string, _AddressesSize)
  861. for i := range o.Addresses {
  862. o.Addresses[i] = xr.ReadStringMax(2083)
  863. }
  864. o.Compression = xr.ReadUint32()
  865. o.CertName = xr.ReadStringMax(64)
  866. o.MaxLocalVersion = int64(xr.ReadUint64())
  867. o.Flags = xr.ReadUint32()
  868. _OptionsSize := int(xr.ReadUint32())
  869. if _OptionsSize < 0 {
  870. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  871. }
  872. if _OptionsSize > 64 {
  873. return xdr.ElementSizeExceeded("Options", _OptionsSize, 64)
  874. }
  875. o.Options = make([]Option, _OptionsSize)
  876. for i := range o.Options {
  877. (&o.Options[i]).DecodeXDRFrom(xr)
  878. }
  879. return xr.Error()
  880. }
  881. /*
  882. Option Structure:
  883. 0 1 2 3
  884. 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
  885. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  886. | Length of Key |
  887. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  888. / /
  889. \ Key (variable length) \
  890. / /
  891. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  892. | Length of Value |
  893. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  894. / /
  895. \ Value (variable length) \
  896. / /
  897. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  898. struct Option {
  899. string Key<64>;
  900. string Value<1024>;
  901. }
  902. */
  903. func (o Option) EncodeXDR(w io.Writer) (int, error) {
  904. var xw = xdr.NewWriter(w)
  905. return o.EncodeXDRInto(xw)
  906. }
  907. func (o Option) MarshalXDR() ([]byte, error) {
  908. return o.AppendXDR(make([]byte, 0, 128))
  909. }
  910. func (o Option) MustMarshalXDR() []byte {
  911. bs, err := o.MarshalXDR()
  912. if err != nil {
  913. panic(err)
  914. }
  915. return bs
  916. }
  917. func (o Option) AppendXDR(bs []byte) ([]byte, error) {
  918. var aw = xdr.AppendWriter(bs)
  919. var xw = xdr.NewWriter(&aw)
  920. _, err := o.EncodeXDRInto(xw)
  921. return []byte(aw), err
  922. }
  923. func (o Option) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  924. if l := len(o.Key); l > 64 {
  925. return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 64)
  926. }
  927. xw.WriteString(o.Key)
  928. if l := len(o.Value); l > 1024 {
  929. return xw.Tot(), xdr.ElementSizeExceeded("Value", l, 1024)
  930. }
  931. xw.WriteString(o.Value)
  932. return xw.Tot(), xw.Error()
  933. }
  934. func (o *Option) DecodeXDR(r io.Reader) error {
  935. xr := xdr.NewReader(r)
  936. return o.DecodeXDRFrom(xr)
  937. }
  938. func (o *Option) UnmarshalXDR(bs []byte) error {
  939. var br = bytes.NewReader(bs)
  940. var xr = xdr.NewReader(br)
  941. return o.DecodeXDRFrom(xr)
  942. }
  943. func (o *Option) DecodeXDRFrom(xr *xdr.Reader) error {
  944. o.Key = xr.ReadStringMax(64)
  945. o.Value = xr.ReadStringMax(1024)
  946. return xr.Error()
  947. }
  948. /*
  949. CloseMessage Structure:
  950. 0 1 2 3
  951. 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
  952. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  953. | Length of Reason |
  954. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  955. / /
  956. \ Reason (variable length) \
  957. / /
  958. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  959. | Code |
  960. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  961. struct CloseMessage {
  962. string Reason<1024>;
  963. int Code;
  964. }
  965. */
  966. func (o CloseMessage) EncodeXDR(w io.Writer) (int, error) {
  967. var xw = xdr.NewWriter(w)
  968. return o.EncodeXDRInto(xw)
  969. }
  970. func (o CloseMessage) MarshalXDR() ([]byte, error) {
  971. return o.AppendXDR(make([]byte, 0, 128))
  972. }
  973. func (o CloseMessage) MustMarshalXDR() []byte {
  974. bs, err := o.MarshalXDR()
  975. if err != nil {
  976. panic(err)
  977. }
  978. return bs
  979. }
  980. func (o CloseMessage) AppendXDR(bs []byte) ([]byte, error) {
  981. var aw = xdr.AppendWriter(bs)
  982. var xw = xdr.NewWriter(&aw)
  983. _, err := o.EncodeXDRInto(xw)
  984. return []byte(aw), err
  985. }
  986. func (o CloseMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  987. if l := len(o.Reason); l > 1024 {
  988. return xw.Tot(), xdr.ElementSizeExceeded("Reason", l, 1024)
  989. }
  990. xw.WriteString(o.Reason)
  991. xw.WriteUint32(uint32(o.Code))
  992. return xw.Tot(), xw.Error()
  993. }
  994. func (o *CloseMessage) DecodeXDR(r io.Reader) error {
  995. xr := xdr.NewReader(r)
  996. return o.DecodeXDRFrom(xr)
  997. }
  998. func (o *CloseMessage) UnmarshalXDR(bs []byte) error {
  999. var br = bytes.NewReader(bs)
  1000. var xr = xdr.NewReader(br)
  1001. return o.DecodeXDRFrom(xr)
  1002. }
  1003. func (o *CloseMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  1004. o.Reason = xr.ReadStringMax(1024)
  1005. o.Code = int32(xr.ReadUint32())
  1006. return xr.Error()
  1007. }
  1008. /*
  1009. EmptyMessage Structure:
  1010. (contains no fields)
  1011. struct EmptyMessage {
  1012. }
  1013. */
  1014. func (o EmptyMessage) EncodeXDR(w io.Writer) (int, error) {
  1015. return 0, nil
  1016. }
  1017. func (o EmptyMessage) MarshalXDR() ([]byte, error) {
  1018. return nil, nil
  1019. }
  1020. func (o EmptyMessage) MustMarshalXDR() []byte {
  1021. return nil
  1022. }
  1023. func (o EmptyMessage) AppendXDR(bs []byte) ([]byte, error) {
  1024. return bs, nil
  1025. }
  1026. func (o EmptyMessage) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  1027. return xw.Tot(), xw.Error()
  1028. }
  1029. func (o *EmptyMessage) DecodeXDR(r io.Reader) error {
  1030. return nil
  1031. }
  1032. func (o *EmptyMessage) UnmarshalXDR(bs []byte) error {
  1033. return nil
  1034. }
  1035. func (o *EmptyMessage) DecodeXDRFrom(xr *xdr.Reader) error {
  1036. return xr.Error()
  1037. }