MCPcopy Index your code
hub / github.com/F-Stack/f-stack / sctp_process_tcb

Function sctp_process_tcb

tools/netstat/sctp.c:208–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208static void
209sctp_process_tcb(struct xsctp_tcb *xstcb,
210 char *buf, const size_t buflen, size_t *offset, int *indent)
211{
212 int i, xl_total = 0, xr_total = 0, x_max;
213 struct xsctp_raddr *xraddr;
214 struct xsctp_laddr *xladdr;
215 struct xladdr_entry *prev_xl = NULL, *xl = NULL, *xl_tmp;
216 struct xraddr_entry *prev_xr = NULL, *xr = NULL, *xr_tmp;
217
218 LIST_INIT(&xladdr_head);
219 LIST_INIT(&xraddr_head);
220
221 /*
222 * Make `struct xladdr_list' list and `struct xraddr_list' list
223 * to handle the address flexibly.
224 */
225 while (*offset < buflen) {
226 xladdr = (struct xsctp_laddr *)(buf + *offset);
227 *offset += sizeof(struct xsctp_laddr);
228 if (xladdr->last == 1)
229 break;
230
231 prev_xl = xl;
232 xl = malloc(sizeof(struct xladdr_entry));
233 if (xl == NULL) {
234 xo_warnx("malloc %lu bytes",
235 (u_long)sizeof(struct xladdr_entry));
236 goto out;
237 }
238 xl->xladdr = xladdr;
239 if (prev_xl == NULL)
240 LIST_INSERT_HEAD(&xladdr_head, xl, xladdr_entries);
241 else
242 LIST_INSERT_AFTER(prev_xl, xl, xladdr_entries);
243 xl_total++;
244 }
245
246 while (*offset < buflen) {
247 xraddr = (struct xsctp_raddr *)(buf + *offset);
248 *offset += sizeof(struct xsctp_raddr);
249 if (xraddr->last == 1)
250 break;
251
252 prev_xr = xr;
253 xr = malloc(sizeof(struct xraddr_entry));
254 if (xr == NULL) {
255 xo_warnx("malloc %lu bytes",
256 (u_long)sizeof(struct xraddr_entry));
257 goto out;
258 }
259 xr->xraddr = xraddr;
260 if (prev_xr == NULL)
261 LIST_INSERT_HEAD(&xraddr_head, xr, xraddr_entries);
262 else
263 LIST_INSERT_AFTER(prev_xr, xr, xraddr_entries);
264 xr_total++;
265 }

Callers 1

sctp_process_inpcbFunction · 0.85

Calls 9

mallocFunction · 0.85
xo_warnxFunction · 0.85
xo_open_listFunction · 0.85
xo_open_instanceFunction · 0.85
xo_emitFunction · 0.85
sctp_statesprintFunction · 0.85
xo_close_instanceFunction · 0.85
sctp_print_addressFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected