packets_xdr.go 13 KB

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