| 2563 | } |
| 2564 | |
| 2565 | static int |
| 2566 | foreach_state(struct cmdline_opts *co, struct format_opts *fo, |
| 2567 | caddr_t base, size_t sz, state_cb dyn_bc, void *dyn_arg) |
| 2568 | { |
| 2569 | int ttype; |
| 2570 | state_cb *fptr; |
| 2571 | void *farg; |
| 2572 | ipfw_obj_tlv *tlv; |
| 2573 | ipfw_obj_ctlv *ctlv; |
| 2574 | |
| 2575 | fptr = NULL; |
| 2576 | ttype = 0; |
| 2577 | |
| 2578 | while (sz > 0) { |
| 2579 | ctlv = (ipfw_obj_ctlv *)base; |
| 2580 | switch (ctlv->head.type) { |
| 2581 | case IPFW_TLV_DYNSTATE_LIST: |
| 2582 | base += sizeof(*ctlv); |
| 2583 | sz -= sizeof(*ctlv); |
| 2584 | ttype = IPFW_TLV_DYN_ENT; |
| 2585 | fptr = dyn_bc; |
| 2586 | farg = dyn_arg; |
| 2587 | break; |
| 2588 | default: |
| 2589 | return (sz); |
| 2590 | } |
| 2591 | |
| 2592 | while (sz > 0) { |
| 2593 | tlv = (ipfw_obj_tlv *)base; |
| 2594 | if (tlv->type != ttype) |
| 2595 | break; |
| 2596 | |
| 2597 | fptr(co, fo, farg, tlv + 1); |
| 2598 | sz -= tlv->length; |
| 2599 | base += tlv->length; |
| 2600 | } |
| 2601 | } |
| 2602 | |
| 2603 | return (sz); |
| 2604 | } |
| 2605 | |
| 2606 | static void |
| 2607 | prepare_format_opts(struct cmdline_opts *co, struct format_opts *fo, |
no outgoing calls
no test coverage detected