1/* Do not edit: automatically built by gen_msg.awk. */
2
3#include "db_config.h"
4
5#include "db_int.h"
6#include "dbinc/db_swap.h"
7
8/*
9 * PUBLIC: void __repmgr_handshake_marshal __P((ENV *,
10 * PUBLIC:	 __repmgr_handshake_args *, u_int8_t *));
11 */
12void
13__repmgr_handshake_marshal(env, argp, bp)
14	ENV *env;
15	__repmgr_handshake_args *argp;
16	u_int8_t *bp;
17{
18	DB_HTONS_COPYOUT(env, bp, argp->port);
19	DB_HTONL_COPYOUT(env, bp, argp->priority);
20}
21
22/*
23 * PUBLIC: int __repmgr_handshake_unmarshal __P((ENV *,
24 * PUBLIC:	 __repmgr_handshake_args *, u_int8_t *, size_t, u_int8_t **));
25 */
26int
27__repmgr_handshake_unmarshal(env, argp, bp, max, nextp)
28	ENV *env;
29	__repmgr_handshake_args *argp;
30	u_int8_t *bp;
31	size_t max;
32	u_int8_t **nextp;
33{
34	if (max < __REPMGR_HANDSHAKE_SIZE)
35		goto too_few;
36	DB_NTOHS_COPYIN(env, argp->port, bp);
37	DB_NTOHL_COPYIN(env, argp->priority, bp);
38
39	if (nextp != NULL)
40		*nextp = bp;
41	return (0);
42
43too_few:
44	__db_errx(env,
45	    "Not enough input bytes to fill a __repmgr_handshake message");
46	return (EINVAL);
47}
48
49/*
50 * PUBLIC: void __repmgr_ack_marshal __P((ENV *, __repmgr_ack_args *,
51 * PUBLIC:	 u_int8_t *));
52 */
53void
54__repmgr_ack_marshal(env, argp, bp)
55	ENV *env;
56	__repmgr_ack_args *argp;
57	u_int8_t *bp;
58{
59	DB_HTONL_COPYOUT(env, bp, argp->generation);
60	DB_HTONL_COPYOUT(env, bp, argp->lsn.file);
61	DB_HTONL_COPYOUT(env, bp, argp->lsn.offset);
62}
63
64/*
65 * PUBLIC: int __repmgr_ack_unmarshal __P((ENV *, __repmgr_ack_args *,
66 * PUBLIC:	 u_int8_t *, size_t, u_int8_t **));
67 */
68int
69__repmgr_ack_unmarshal(env, argp, bp, max, nextp)
70	ENV *env;
71	__repmgr_ack_args *argp;
72	u_int8_t *bp;
73	size_t max;
74	u_int8_t **nextp;
75{
76	if (max < __REPMGR_ACK_SIZE)
77		goto too_few;
78	DB_NTOHL_COPYIN(env, argp->generation, bp);
79	DB_NTOHL_COPYIN(env, argp->lsn.file, bp);
80	DB_NTOHL_COPYIN(env, argp->lsn.offset, bp);
81
82	if (nextp != NULL)
83		*nextp = bp;
84	return (0);
85
86too_few:
87	__db_errx(env,
88	    "Not enough input bytes to fill a __repmgr_ack message");
89	return (EINVAL);
90}
91
92/*
93 * PUBLIC: void __repmgr_version_proposal_marshal __P((ENV *,
94 * PUBLIC:	 __repmgr_version_proposal_args *, u_int8_t *));
95 */
96void
97__repmgr_version_proposal_marshal(env, argp, bp)
98	ENV *env;
99	__repmgr_version_proposal_args *argp;
100	u_int8_t *bp;
101{
102	DB_HTONL_COPYOUT(env, bp, argp->min);
103	DB_HTONL_COPYOUT(env, bp, argp->max);
104}
105
106/*
107 * PUBLIC: int __repmgr_version_proposal_unmarshal __P((ENV *,
108 * PUBLIC:	 __repmgr_version_proposal_args *, u_int8_t *, size_t,
109 * PUBLIC:	 u_int8_t **));
110 */
111int
112__repmgr_version_proposal_unmarshal(env, argp, bp, max, nextp)
113	ENV *env;
114	__repmgr_version_proposal_args *argp;
115	u_int8_t *bp;
116	size_t max;
117	u_int8_t **nextp;
118{
119	if (max < __REPMGR_VERSION_PROPOSAL_SIZE)
120		goto too_few;
121	DB_NTOHL_COPYIN(env, argp->min, bp);
122	DB_NTOHL_COPYIN(env, argp->max, bp);
123
124	if (nextp != NULL)
125		*nextp = bp;
126	return (0);
127
128too_few:
129	__db_errx(env,
130	    "Not enough input bytes to fill a __repmgr_version_proposal message");
131	return (EINVAL);
132}
133
134/*
135 * PUBLIC: void __repmgr_version_confirmation_marshal __P((ENV *,
136 * PUBLIC:	 __repmgr_version_confirmation_args *, u_int8_t *));
137 */
138void
139__repmgr_version_confirmation_marshal(env, argp, bp)
140	ENV *env;
141	__repmgr_version_confirmation_args *argp;
142	u_int8_t *bp;
143{
144	DB_HTONL_COPYOUT(env, bp, argp->version);
145}
146
147/*
148 * PUBLIC: int __repmgr_version_confirmation_unmarshal __P((ENV *,
149 * PUBLIC:	 __repmgr_version_confirmation_args *, u_int8_t *, size_t,
150 * PUBLIC:	 u_int8_t **));
151 */
152int
153__repmgr_version_confirmation_unmarshal(env, argp, bp, max, nextp)
154	ENV *env;
155	__repmgr_version_confirmation_args *argp;
156	u_int8_t *bp;
157	size_t max;
158	u_int8_t **nextp;
159{
160	if (max < __REPMGR_VERSION_CONFIRMATION_SIZE)
161		goto too_few;
162	DB_NTOHL_COPYIN(env, argp->version, bp);
163
164	if (nextp != NULL)
165		*nextp = bp;
166	return (0);
167
168too_few:
169	__db_errx(env,
170	    "Not enough input bytes to fill a __repmgr_version_confirmation message");
171	return (EINVAL);
172}
173
174