packets_xdr.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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. header 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. | magic |
  16. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  17. | message Type |
  18. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  19. | message Length |
  20. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  21. struct header {
  22. unsigned int magic;
  23. int messageType;
  24. int messageLength;
  25. }
  26. */
  27. func (o header) EncodeXDR(w io.Writer) (int, error) {
  28. var xw = xdr.NewWriter(w)
  29. return o.EncodeXDRInto(xw)
  30. }
  31. func (o header) MarshalXDR() ([]byte, error) {
  32. return o.AppendXDR(make([]byte, 0, 128))
  33. }
  34. func (o header) MustMarshalXDR() []byte {
  35. bs, err := o.MarshalXDR()
  36. if err != nil {
  37. panic(err)
  38. }
  39. return bs
  40. }
  41. func (o header) AppendXDR(bs []byte) ([]byte, error) {
  42. var aw = xdr.AppendWriter(bs)
  43. var xw = xdr.NewWriter(&aw)
  44. _, err := o.EncodeXDRInto(xw)
  45. return []byte(aw), err
  46. }
  47. func (o header) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  48. xw.WriteUint32(o.magic)
  49. xw.WriteUint32(uint32(o.messageType))
  50. xw.WriteUint32(uint32(o.messageLength))
  51. return xw.Tot(), xw.Error()
  52. }
  53. func (o *header) DecodeXDR(r io.Reader) error {
  54. xr := xdr.NewReader(r)
  55. return o.DecodeXDRFrom(xr)
  56. }
  57. func (o *header) UnmarshalXDR(bs []byte) error {
  58. var br = bytes.NewReader(bs)
  59. var xr = xdr.NewReader(br)
  60. return o.DecodeXDRFrom(xr)
  61. }
  62. func (o *header) DecodeXDRFrom(xr *xdr.Reader) error {
  63. o.magic = xr.ReadUint32()
  64. o.messageType = int32(xr.ReadUint32())
  65. o.messageLength = int32(xr.ReadUint32())
  66. return xr.Error()
  67. }
  68. /*
  69. Ping Structure:
  70. 0 1 2 3
  71. 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
  72. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  73. struct Ping {
  74. }
  75. */
  76. func (o Ping) EncodeXDR(w io.Writer) (int, error) {
  77. var xw = xdr.NewWriter(w)
  78. return o.EncodeXDRInto(xw)
  79. }
  80. func (o Ping) MarshalXDR() ([]byte, error) {
  81. return o.AppendXDR(make([]byte, 0, 128))
  82. }
  83. func (o Ping) MustMarshalXDR() []byte {
  84. bs, err := o.MarshalXDR()
  85. if err != nil {
  86. panic(err)
  87. }
  88. return bs
  89. }
  90. func (o Ping) AppendXDR(bs []byte) ([]byte, error) {
  91. var aw = xdr.AppendWriter(bs)
  92. var xw = xdr.NewWriter(&aw)
  93. _, err := o.EncodeXDRInto(xw)
  94. return []byte(aw), err
  95. }
  96. func (o Ping) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  97. return xw.Tot(), xw.Error()
  98. }
  99. func (o *Ping) DecodeXDR(r io.Reader) error {
  100. xr := xdr.NewReader(r)
  101. return o.DecodeXDRFrom(xr)
  102. }
  103. func (o *Ping) UnmarshalXDR(bs []byte) error {
  104. var br = bytes.NewReader(bs)
  105. var xr = xdr.NewReader(br)
  106. return o.DecodeXDRFrom(xr)
  107. }
  108. func (o *Ping) DecodeXDRFrom(xr *xdr.Reader) error {
  109. return xr.Error()
  110. }
  111. /*
  112. Pong Structure:
  113. 0 1 2 3
  114. 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
  115. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  116. struct Pong {
  117. }
  118. */
  119. func (o Pong) EncodeXDR(w io.Writer) (int, error) {
  120. var xw = xdr.NewWriter(w)
  121. return o.EncodeXDRInto(xw)
  122. }
  123. func (o Pong) MarshalXDR() ([]byte, error) {
  124. return o.AppendXDR(make([]byte, 0, 128))
  125. }
  126. func (o Pong) MustMarshalXDR() []byte {
  127. bs, err := o.MarshalXDR()
  128. if err != nil {
  129. panic(err)
  130. }
  131. return bs
  132. }
  133. func (o Pong) AppendXDR(bs []byte) ([]byte, error) {
  134. var aw = xdr.AppendWriter(bs)
  135. var xw = xdr.NewWriter(&aw)
  136. _, err := o.EncodeXDRInto(xw)
  137. return []byte(aw), err
  138. }
  139. func (o Pong) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  140. return xw.Tot(), xw.Error()
  141. }
  142. func (o *Pong) DecodeXDR(r io.Reader) error {
  143. xr := xdr.NewReader(r)
  144. return o.DecodeXDRFrom(xr)
  145. }
  146. func (o *Pong) UnmarshalXDR(bs []byte) error {
  147. var br = bytes.NewReader(bs)
  148. var xr = xdr.NewReader(br)
  149. return o.DecodeXDRFrom(xr)
  150. }
  151. func (o *Pong) DecodeXDRFrom(xr *xdr.Reader) error {
  152. return xr.Error()
  153. }
  154. /*
  155. JoinRelayRequest Structure:
  156. 0 1 2 3
  157. 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
  158. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  159. struct JoinRelayRequest {
  160. }
  161. */
  162. func (o JoinRelayRequest) EncodeXDR(w io.Writer) (int, error) {
  163. var xw = xdr.NewWriter(w)
  164. return o.EncodeXDRInto(xw)
  165. }
  166. func (o JoinRelayRequest) MarshalXDR() ([]byte, error) {
  167. return o.AppendXDR(make([]byte, 0, 128))
  168. }
  169. func (o JoinRelayRequest) MustMarshalXDR() []byte {
  170. bs, err := o.MarshalXDR()
  171. if err != nil {
  172. panic(err)
  173. }
  174. return bs
  175. }
  176. func (o JoinRelayRequest) AppendXDR(bs []byte) ([]byte, error) {
  177. var aw = xdr.AppendWriter(bs)
  178. var xw = xdr.NewWriter(&aw)
  179. _, err := o.EncodeXDRInto(xw)
  180. return []byte(aw), err
  181. }
  182. func (o JoinRelayRequest) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  183. return xw.Tot(), xw.Error()
  184. }
  185. func (o *JoinRelayRequest) DecodeXDR(r io.Reader) error {
  186. xr := xdr.NewReader(r)
  187. return o.DecodeXDRFrom(xr)
  188. }
  189. func (o *JoinRelayRequest) UnmarshalXDR(bs []byte) error {
  190. var br = bytes.NewReader(bs)
  191. var xr = xdr.NewReader(br)
  192. return o.DecodeXDRFrom(xr)
  193. }
  194. func (o *JoinRelayRequest) DecodeXDRFrom(xr *xdr.Reader) error {
  195. return xr.Error()
  196. }
  197. /*
  198. JoinSessionRequest Structure:
  199. 0 1 2 3
  200. 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
  201. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  202. | Length of Key |
  203. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  204. / /
  205. \ Key (variable length) \
  206. / /
  207. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  208. struct JoinSessionRequest {
  209. opaque Key<32>;
  210. }
  211. */
  212. func (o JoinSessionRequest) EncodeXDR(w io.Writer) (int, error) {
  213. var xw = xdr.NewWriter(w)
  214. return o.EncodeXDRInto(xw)
  215. }
  216. func (o JoinSessionRequest) MarshalXDR() ([]byte, error) {
  217. return o.AppendXDR(make([]byte, 0, 128))
  218. }
  219. func (o JoinSessionRequest) MustMarshalXDR() []byte {
  220. bs, err := o.MarshalXDR()
  221. if err != nil {
  222. panic(err)
  223. }
  224. return bs
  225. }
  226. func (o JoinSessionRequest) AppendXDR(bs []byte) ([]byte, error) {
  227. var aw = xdr.AppendWriter(bs)
  228. var xw = xdr.NewWriter(&aw)
  229. _, err := o.EncodeXDRInto(xw)
  230. return []byte(aw), err
  231. }
  232. func (o JoinSessionRequest) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  233. if l := len(o.Key); l > 32 {
  234. return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 32)
  235. }
  236. xw.WriteBytes(o.Key)
  237. return xw.Tot(), xw.Error()
  238. }
  239. func (o *JoinSessionRequest) DecodeXDR(r io.Reader) error {
  240. xr := xdr.NewReader(r)
  241. return o.DecodeXDRFrom(xr)
  242. }
  243. func (o *JoinSessionRequest) UnmarshalXDR(bs []byte) error {
  244. var br = bytes.NewReader(bs)
  245. var xr = xdr.NewReader(br)
  246. return o.DecodeXDRFrom(xr)
  247. }
  248. func (o *JoinSessionRequest) DecodeXDRFrom(xr *xdr.Reader) error {
  249. o.Key = xr.ReadBytesMax(32)
  250. return xr.Error()
  251. }
  252. /*
  253. Response Structure:
  254. 0 1 2 3
  255. 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
  256. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  257. | Code |
  258. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  259. | Length of Message |
  260. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  261. / /
  262. \ Message (variable length) \
  263. / /
  264. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  265. struct Response {
  266. int Code;
  267. string Message<>;
  268. }
  269. */
  270. func (o Response) EncodeXDR(w io.Writer) (int, error) {
  271. var xw = xdr.NewWriter(w)
  272. return o.EncodeXDRInto(xw)
  273. }
  274. func (o Response) MarshalXDR() ([]byte, error) {
  275. return o.AppendXDR(make([]byte, 0, 128))
  276. }
  277. func (o Response) MustMarshalXDR() []byte {
  278. bs, err := o.MarshalXDR()
  279. if err != nil {
  280. panic(err)
  281. }
  282. return bs
  283. }
  284. func (o Response) AppendXDR(bs []byte) ([]byte, error) {
  285. var aw = xdr.AppendWriter(bs)
  286. var xw = xdr.NewWriter(&aw)
  287. _, err := o.EncodeXDRInto(xw)
  288. return []byte(aw), err
  289. }
  290. func (o Response) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  291. xw.WriteUint32(uint32(o.Code))
  292. xw.WriteString(o.Message)
  293. return xw.Tot(), xw.Error()
  294. }
  295. func (o *Response) DecodeXDR(r io.Reader) error {
  296. xr := xdr.NewReader(r)
  297. return o.DecodeXDRFrom(xr)
  298. }
  299. func (o *Response) UnmarshalXDR(bs []byte) error {
  300. var br = bytes.NewReader(bs)
  301. var xr = xdr.NewReader(br)
  302. return o.DecodeXDRFrom(xr)
  303. }
  304. func (o *Response) DecodeXDRFrom(xr *xdr.Reader) error {
  305. o.Code = int32(xr.ReadUint32())
  306. o.Message = xr.ReadString()
  307. return xr.Error()
  308. }
  309. /*
  310. ConnectRequest Structure:
  311. 0 1 2 3
  312. 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
  313. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  314. | Length of ID |
  315. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  316. / /
  317. \ ID (variable length) \
  318. / /
  319. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  320. struct ConnectRequest {
  321. opaque ID<32>;
  322. }
  323. */
  324. func (o ConnectRequest) EncodeXDR(w io.Writer) (int, error) {
  325. var xw = xdr.NewWriter(w)
  326. return o.EncodeXDRInto(xw)
  327. }
  328. func (o ConnectRequest) MarshalXDR() ([]byte, error) {
  329. return o.AppendXDR(make([]byte, 0, 128))
  330. }
  331. func (o ConnectRequest) MustMarshalXDR() []byte {
  332. bs, err := o.MarshalXDR()
  333. if err != nil {
  334. panic(err)
  335. }
  336. return bs
  337. }
  338. func (o ConnectRequest) AppendXDR(bs []byte) ([]byte, error) {
  339. var aw = xdr.AppendWriter(bs)
  340. var xw = xdr.NewWriter(&aw)
  341. _, err := o.EncodeXDRInto(xw)
  342. return []byte(aw), err
  343. }
  344. func (o ConnectRequest) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  345. if l := len(o.ID); l > 32 {
  346. return xw.Tot(), xdr.ElementSizeExceeded("ID", l, 32)
  347. }
  348. xw.WriteBytes(o.ID)
  349. return xw.Tot(), xw.Error()
  350. }
  351. func (o *ConnectRequest) DecodeXDR(r io.Reader) error {
  352. xr := xdr.NewReader(r)
  353. return o.DecodeXDRFrom(xr)
  354. }
  355. func (o *ConnectRequest) UnmarshalXDR(bs []byte) error {
  356. var br = bytes.NewReader(bs)
  357. var xr = xdr.NewReader(br)
  358. return o.DecodeXDRFrom(xr)
  359. }
  360. func (o *ConnectRequest) DecodeXDRFrom(xr *xdr.Reader) error {
  361. o.ID = xr.ReadBytesMax(32)
  362. return xr.Error()
  363. }
  364. /*
  365. SessionInvitation Structure:
  366. 0 1 2 3
  367. 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
  368. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  369. | Length of From |
  370. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  371. / /
  372. \ From (variable length) \
  373. / /
  374. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  375. | Length of Key |
  376. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  377. / /
  378. \ Key (variable length) \
  379. / /
  380. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  381. | Length of Address |
  382. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  383. / /
  384. \ Address (variable length) \
  385. / /
  386. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  387. | 0x0000 | Port |
  388. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  389. | Server Socket (V=0 or 1) |V|
  390. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  391. struct SessionInvitation {
  392. opaque From<32>;
  393. opaque Key<32>;
  394. opaque Address<32>;
  395. unsigned int Port;
  396. bool ServerSocket;
  397. }
  398. */
  399. func (o SessionInvitation) EncodeXDR(w io.Writer) (int, error) {
  400. var xw = xdr.NewWriter(w)
  401. return o.EncodeXDRInto(xw)
  402. }
  403. func (o SessionInvitation) MarshalXDR() ([]byte, error) {
  404. return o.AppendXDR(make([]byte, 0, 128))
  405. }
  406. func (o SessionInvitation) MustMarshalXDR() []byte {
  407. bs, err := o.MarshalXDR()
  408. if err != nil {
  409. panic(err)
  410. }
  411. return bs
  412. }
  413. func (o SessionInvitation) AppendXDR(bs []byte) ([]byte, error) {
  414. var aw = xdr.AppendWriter(bs)
  415. var xw = xdr.NewWriter(&aw)
  416. _, err := o.EncodeXDRInto(xw)
  417. return []byte(aw), err
  418. }
  419. func (o SessionInvitation) EncodeXDRInto(xw *xdr.Writer) (int, error) {
  420. if l := len(o.From); l > 32 {
  421. return xw.Tot(), xdr.ElementSizeExceeded("From", l, 32)
  422. }
  423. xw.WriteBytes(o.From)
  424. if l := len(o.Key); l > 32 {
  425. return xw.Tot(), xdr.ElementSizeExceeded("Key", l, 32)
  426. }
  427. xw.WriteBytes(o.Key)
  428. if l := len(o.Address); l > 32 {
  429. return xw.Tot(), xdr.ElementSizeExceeded("Address", l, 32)
  430. }
  431. xw.WriteBytes(o.Address)
  432. xw.WriteUint16(o.Port)
  433. xw.WriteBool(o.ServerSocket)
  434. return xw.Tot(), xw.Error()
  435. }
  436. func (o *SessionInvitation) DecodeXDR(r io.Reader) error {
  437. xr := xdr.NewReader(r)
  438. return o.DecodeXDRFrom(xr)
  439. }
  440. func (o *SessionInvitation) UnmarshalXDR(bs []byte) error {
  441. var br = bytes.NewReader(bs)
  442. var xr = xdr.NewReader(br)
  443. return o.DecodeXDRFrom(xr)
  444. }
  445. func (o *SessionInvitation) DecodeXDRFrom(xr *xdr.Reader) error {
  446. o.From = xr.ReadBytesMax(32)
  447. o.Key = xr.ReadBytesMax(32)
  448. o.Address = xr.ReadBytesMax(32)
  449. o.Port = xr.ReadUint16()
  450. o.ServerSocket = xr.ReadBool()
  451. return xr.Error()
  452. }