Lines Matching +full:cs +full:- +full:out

1 /*-
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 #include "netdissect-stdinc.h"
44 size_t misalignment = (size_t)(p - buf) % alignment;
49 return p + (alignment - misalignment);
57 nd_cpack_align_and_reserve(struct cpack_state *cs, size_t wordsize)
62 next = nd_cpack_next_boundary(cs->c_buf, cs->c_next, wordsize);
65 if (next - cs->c_buf + wordsize > cs->c_len)
73 nd_cpack_advance(struct cpack_state *cs, const size_t toskip)
76 if (cs->c_next - cs->c_buf + toskip > cs->c_len)
77 return -1;
78 cs->c_next += toskip;
83 nd_cpack_init(struct cpack_state *cs, const uint8_t *buf, size_t buflen)
85 memset(cs, 0, sizeof(*cs));
87 cs->c_buf = buf;
88 cs->c_len = buflen;
89 cs->c_next = cs->c_buf;
94 /* Unpack a 64-bit unsigned integer. */
96 nd_cpack_uint64(netdissect_options *ndo, struct cpack_state *cs, uint64_t *u)
100 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
101 return -1;
106 cs->c_next = next + sizeof(*u);
110 /* Unpack a 64-bit signed integer. */
112 nd_cpack_int64(netdissect_options *ndo, struct cpack_state *cs, int64_t *u)
116 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
117 return -1;
122 cs->c_next = next + sizeof(*u);
126 /* Unpack a 32-bit unsigned integer. */
128 nd_cpack_uint32(netdissect_options *ndo, struct cpack_state *cs, uint32_t *u)
132 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
133 return -1;
138 cs->c_next = next + sizeof(*u);
142 /* Unpack a 32-bit signed integer. */
144 nd_cpack_int32(netdissect_options *ndo, struct cpack_state *cs, int32_t *u)
148 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
149 return -1;
154 cs->c_next = next + sizeof(*u);
158 /* Unpack a 16-bit unsigned integer. */
160 nd_cpack_uint16(netdissect_options *ndo, struct cpack_state *cs, uint16_t *u)
164 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
165 return -1;
170 cs->c_next = next + sizeof(*u);
174 /* Unpack a 16-bit signed integer. */
176 nd_cpack_int16(netdissect_options *ndo, struct cpack_state *cs, int16_t *u)
180 if ((next = nd_cpack_align_and_reserve(cs, sizeof(*u))) == NULL)
181 return -1;
186 cs->c_next = next + sizeof(*u);
190 /* Unpack an 8-bit unsigned integer. */
192 nd_cpack_uint8(netdissect_options *ndo, struct cpack_state *cs, uint8_t *u)
195 if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
196 return -1;
198 *u = GET_U_1(cs->c_next);
201 cs->c_next++;
205 /* Unpack an 8-bit signed integer. */
207 nd_cpack_int8(netdissect_options *ndo, struct cpack_state *cs, int8_t *u)
210 if ((size_t)(cs->c_next - cs->c_buf) >= cs->c_len)
211 return -1;
213 *u = GET_S_1(cs->c_next);
216 cs->c_next++;