MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_unpack_auth_chunks

Function sctp_unpack_auth_chunks

freebsd/netinet/sctp_auth.c:208–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208int
209sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
210 sctp_auth_chklist_t *list)
211{
212 int i;
213 int size;
214
215 if (list == NULL)
216 return (0);
217
218 if (num_chunks <= 32) {
219 /* just pull them, one byte each */
220 for (i = 0; i < num_chunks; i++) {
221 (void)sctp_auth_add_chunk(*ptr++, list);
222 }
223 size = num_chunks;
224 } else {
225 int index, offset;
226
227 /* unpack from a 32 byte bitfield */
228 for (index = 0; index < 32; index++) {
229 for (offset = 0; offset < 8; offset++) {
230 if (ptr[index] & (1 << offset)) {
231 (void)sctp_auth_add_chunk((index * 8) + offset, list);
232 }
233 }
234 }
235 size = 32;
236 }
237 return (size);
238}
239
240/*
241 * allocate structure space for a key of length keylen

Callers

nothing calls this directly

Calls 1

sctp_auth_add_chunkFunction · 0.85

Tested by

no test coverage detected