/lib/relay/protocol/packets_xdr.go

https://gitlab.com/shinvdu/syncthing · Go · 455 lines · 243 code · 56 blank · 156 comment · 15 complexity · 2185084494ae3328a9140d561fd1b135 MD5 · raw file

  1. // ************************************************************
  2. // This file is automatically generated by genxdr. Do not edit.
  3. // ************************************************************
  4. package protocol
  5. import (
  6. "github.com/calmh/xdr"
  7. )
  8. /*
  9. header Structure:
  10. 0 1 2 3
  11. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  12. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  13. | magic |
  14. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  15. | message Type |
  16. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  17. | message Length |
  18. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  19. struct header {
  20. unsigned int magic;
  21. int messageType;
  22. int messageLength;
  23. }
  24. */
  25. func (o header) XDRSize() int {
  26. return 4 + 4 + 4
  27. }
  28. func (o header) MarshalXDR() ([]byte, error) {
  29. buf := make([]byte, o.XDRSize())
  30. m := &xdr.Marshaller{Data: buf}
  31. return buf, o.MarshalXDRInto(m)
  32. }
  33. func (o header) MustMarshalXDR() []byte {
  34. bs, err := o.MarshalXDR()
  35. if err != nil {
  36. panic(err)
  37. }
  38. return bs
  39. }
  40. func (o header) MarshalXDRInto(m *xdr.Marshaller) error {
  41. m.MarshalUint32(o.magic)
  42. m.MarshalUint32(uint32(o.messageType))
  43. m.MarshalUint32(uint32(o.messageLength))
  44. return m.Error
  45. }
  46. func (o *header) UnmarshalXDR(bs []byte) error {
  47. u := &xdr.Unmarshaller{Data: bs}
  48. return o.UnmarshalXDRFrom(u)
  49. }
  50. func (o *header) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  51. o.magic = u.UnmarshalUint32()
  52. o.messageType = int32(u.UnmarshalUint32())
  53. o.messageLength = int32(u.UnmarshalUint32())
  54. return u.Error
  55. }
  56. /*
  57. Ping Structure:
  58. (contains no fields)
  59. struct Ping {
  60. }
  61. */
  62. func (o Ping) XDRSize() int {
  63. return 0
  64. }
  65. func (o Ping) MarshalXDR() ([]byte, error) {
  66. return nil, nil
  67. }
  68. func (o Ping) MustMarshalXDR() []byte {
  69. return nil
  70. }
  71. func (o Ping) MarshalXDRInto(m *xdr.Marshaller) error {
  72. return nil
  73. }
  74. func (o *Ping) UnmarshalXDR(bs []byte) error {
  75. return nil
  76. }
  77. func (o *Ping) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  78. return nil
  79. }
  80. /*
  81. Pong Structure:
  82. (contains no fields)
  83. struct Pong {
  84. }
  85. */
  86. func (o Pong) XDRSize() int {
  87. return 0
  88. }
  89. func (o Pong) MarshalXDR() ([]byte, error) {
  90. return nil, nil
  91. }
  92. func (o Pong) MustMarshalXDR() []byte {
  93. return nil
  94. }
  95. func (o Pong) MarshalXDRInto(m *xdr.Marshaller) error {
  96. return nil
  97. }
  98. func (o *Pong) UnmarshalXDR(bs []byte) error {
  99. return nil
  100. }
  101. func (o *Pong) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  102. return nil
  103. }
  104. /*
  105. JoinRelayRequest Structure:
  106. (contains no fields)
  107. struct JoinRelayRequest {
  108. }
  109. */
  110. func (o JoinRelayRequest) XDRSize() int {
  111. return 0
  112. }
  113. func (o JoinRelayRequest) MarshalXDR() ([]byte, error) {
  114. return nil, nil
  115. }
  116. func (o JoinRelayRequest) MustMarshalXDR() []byte {
  117. return nil
  118. }
  119. func (o JoinRelayRequest) MarshalXDRInto(m *xdr.Marshaller) error {
  120. return nil
  121. }
  122. func (o *JoinRelayRequest) UnmarshalXDR(bs []byte) error {
  123. return nil
  124. }
  125. func (o *JoinRelayRequest) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  126. return nil
  127. }
  128. /*
  129. RelayFull Structure:
  130. (contains no fields)
  131. struct RelayFull {
  132. }
  133. */
  134. func (o RelayFull) XDRSize() int {
  135. return 0
  136. }
  137. func (o RelayFull) MarshalXDR() ([]byte, error) {
  138. return nil, nil
  139. }
  140. func (o RelayFull) MustMarshalXDR() []byte {
  141. return nil
  142. }
  143. func (o RelayFull) MarshalXDRInto(m *xdr.Marshaller) error {
  144. return nil
  145. }
  146. func (o *RelayFull) UnmarshalXDR(bs []byte) error {
  147. return nil
  148. }
  149. func (o *RelayFull) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  150. return nil
  151. }
  152. /*
  153. JoinSessionRequest Structure:
  154. 0 1 2 3
  155. 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
  156. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  157. / /
  158. \ Key (length + padded data) \
  159. / /
  160. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  161. struct JoinSessionRequest {
  162. opaque Key<32>;
  163. }
  164. */
  165. func (o JoinSessionRequest) XDRSize() int {
  166. return 4 + len(o.Key) + xdr.Padding(len(o.Key))
  167. }
  168. func (o JoinSessionRequest) MarshalXDR() ([]byte, error) {
  169. buf := make([]byte, o.XDRSize())
  170. m := &xdr.Marshaller{Data: buf}
  171. return buf, o.MarshalXDRInto(m)
  172. }
  173. func (o JoinSessionRequest) MustMarshalXDR() []byte {
  174. bs, err := o.MarshalXDR()
  175. if err != nil {
  176. panic(err)
  177. }
  178. return bs
  179. }
  180. func (o JoinSessionRequest) MarshalXDRInto(m *xdr.Marshaller) error {
  181. if l := len(o.Key); l > 32 {
  182. return xdr.ElementSizeExceeded("Key", l, 32)
  183. }
  184. m.MarshalBytes(o.Key)
  185. return m.Error
  186. }
  187. func (o *JoinSessionRequest) UnmarshalXDR(bs []byte) error {
  188. u := &xdr.Unmarshaller{Data: bs}
  189. return o.UnmarshalXDRFrom(u)
  190. }
  191. func (o *JoinSessionRequest) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  192. o.Key = u.UnmarshalBytesMax(32)
  193. return u.Error
  194. }
  195. /*
  196. Response Structure:
  197. 0 1 2 3
  198. 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
  199. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  200. | Code |
  201. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  202. / /
  203. \ Message (length + padded data) \
  204. / /
  205. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  206. struct Response {
  207. int Code;
  208. string Message<>;
  209. }
  210. */
  211. func (o Response) XDRSize() int {
  212. return 4 +
  213. 4 + len(o.Message) + xdr.Padding(len(o.Message))
  214. }
  215. func (o Response) MarshalXDR() ([]byte, error) {
  216. buf := make([]byte, o.XDRSize())
  217. m := &xdr.Marshaller{Data: buf}
  218. return buf, o.MarshalXDRInto(m)
  219. }
  220. func (o Response) MustMarshalXDR() []byte {
  221. bs, err := o.MarshalXDR()
  222. if err != nil {
  223. panic(err)
  224. }
  225. return bs
  226. }
  227. func (o Response) MarshalXDRInto(m *xdr.Marshaller) error {
  228. m.MarshalUint32(uint32(o.Code))
  229. m.MarshalString(o.Message)
  230. return m.Error
  231. }
  232. func (o *Response) UnmarshalXDR(bs []byte) error {
  233. u := &xdr.Unmarshaller{Data: bs}
  234. return o.UnmarshalXDRFrom(u)
  235. }
  236. func (o *Response) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  237. o.Code = int32(u.UnmarshalUint32())
  238. o.Message = u.UnmarshalString()
  239. return u.Error
  240. }
  241. /*
  242. ConnectRequest Structure:
  243. 0 1 2 3
  244. 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
  245. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  246. / /
  247. \ ID (length + padded data) \
  248. / /
  249. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  250. struct ConnectRequest {
  251. opaque ID<32>;
  252. }
  253. */
  254. func (o ConnectRequest) XDRSize() int {
  255. return 4 + len(o.ID) + xdr.Padding(len(o.ID))
  256. }
  257. func (o ConnectRequest) MarshalXDR() ([]byte, error) {
  258. buf := make([]byte, o.XDRSize())
  259. m := &xdr.Marshaller{Data: buf}
  260. return buf, o.MarshalXDRInto(m)
  261. }
  262. func (o ConnectRequest) MustMarshalXDR() []byte {
  263. bs, err := o.MarshalXDR()
  264. if err != nil {
  265. panic(err)
  266. }
  267. return bs
  268. }
  269. func (o ConnectRequest) MarshalXDRInto(m *xdr.Marshaller) error {
  270. if l := len(o.ID); l > 32 {
  271. return xdr.ElementSizeExceeded("ID", l, 32)
  272. }
  273. m.MarshalBytes(o.ID)
  274. return m.Error
  275. }
  276. func (o *ConnectRequest) UnmarshalXDR(bs []byte) error {
  277. u := &xdr.Unmarshaller{Data: bs}
  278. return o.UnmarshalXDRFrom(u)
  279. }
  280. func (o *ConnectRequest) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  281. o.ID = u.UnmarshalBytesMax(32)
  282. return u.Error
  283. }
  284. /*
  285. SessionInvitation Structure:
  286. 0 1 2 3
  287. 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
  288. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  289. / /
  290. \ From (length + padded data) \
  291. / /
  292. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  293. / /
  294. \ Key (length + padded data) \
  295. / /
  296. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  297. / /
  298. \ Address (length + padded data) \
  299. / /
  300. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  301. | 16 zero bits | Port |
  302. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  303. | Server Socket (V=0 or 1) |V|
  304. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  305. struct SessionInvitation {
  306. opaque From<32>;
  307. opaque Key<32>;
  308. opaque Address<32>;
  309. unsigned int Port;
  310. bool ServerSocket;
  311. }
  312. */
  313. func (o SessionInvitation) XDRSize() int {
  314. return 4 + len(o.From) + xdr.Padding(len(o.From)) +
  315. 4 + len(o.Key) + xdr.Padding(len(o.Key)) +
  316. 4 + len(o.Address) + xdr.Padding(len(o.Address)) + 4 + 4
  317. }
  318. func (o SessionInvitation) MarshalXDR() ([]byte, error) {
  319. buf := make([]byte, o.XDRSize())
  320. m := &xdr.Marshaller{Data: buf}
  321. return buf, o.MarshalXDRInto(m)
  322. }
  323. func (o SessionInvitation) MustMarshalXDR() []byte {
  324. bs, err := o.MarshalXDR()
  325. if err != nil {
  326. panic(err)
  327. }
  328. return bs
  329. }
  330. func (o SessionInvitation) MarshalXDRInto(m *xdr.Marshaller) error {
  331. if l := len(o.From); l > 32 {
  332. return xdr.ElementSizeExceeded("From", l, 32)
  333. }
  334. m.MarshalBytes(o.From)
  335. if l := len(o.Key); l > 32 {
  336. return xdr.ElementSizeExceeded("Key", l, 32)
  337. }
  338. m.MarshalBytes(o.Key)
  339. if l := len(o.Address); l > 32 {
  340. return xdr.ElementSizeExceeded("Address", l, 32)
  341. }
  342. m.MarshalBytes(o.Address)
  343. m.MarshalUint16(o.Port)
  344. m.MarshalBool(o.ServerSocket)
  345. return m.Error
  346. }
  347. func (o *SessionInvitation) UnmarshalXDR(bs []byte) error {
  348. u := &xdr.Unmarshaller{Data: bs}
  349. return o.UnmarshalXDRFrom(u)
  350. }
  351. func (o *SessionInvitation) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
  352. o.From = u.UnmarshalBytesMax(32)
  353. o.Key = u.UnmarshalBytesMax(32)
  354. o.Address = u.UnmarshalBytesMax(32)
  355. o.Port = u.UnmarshalUint16()
  356. o.ServerSocket = u.UnmarshalBool()
  357. return u.Error
  358. }