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

Function pack_object

tools/ipfw/ipfw2.c:3036–3071  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3034}
3035
3036static uint16_t
3037pack_object(struct tidx *tstate, const char *name, int otype)
3038{
3039 ipfw_obj_ntlv *ntlv;
3040 uint32_t i;
3041
3042 for (i = 0; i < tstate->count; i++) {
3043 if (strcmp(tstate->idx[i].name, name) != 0)
3044 continue;
3045 if (tstate->idx[i].set != tstate->set)
3046 continue;
3047 if (tstate->idx[i].head.type != otype)
3048 continue;
3049
3050 return (tstate->idx[i].idx);
3051 }
3052
3053 if (tstate->count + 1 > tstate->size) {
3054 tstate->size += 4;
3055 tstate->idx = realloc(tstate->idx, tstate->size *
3056 sizeof(ipfw_obj_ntlv));
3057 if (tstate->idx == NULL)
3058 return (0);
3059 }
3060
3061 ntlv = &tstate->idx[i];
3062 memset(ntlv, 0, sizeof(ipfw_obj_ntlv));
3063 strlcpy(ntlv->name, name, sizeof(ntlv->name));
3064 ntlv->head.type = otype;
3065 ntlv->head.length = sizeof(ipfw_obj_ntlv);
3066 ntlv->set = tstate->set;
3067 ntlv->idx = ++tstate->counter;
3068 tstate->count++;
3069
3070 return (ntlv->idx);
3071}
3072
3073static uint16_t
3074pack_table(struct tidx *tstate, const char *name)

Callers 2

pack_tableFunction · 0.85
compile_ruleFunction · 0.85

Calls 4

strcmpFunction · 0.85
memsetFunction · 0.85
reallocFunction · 0.50
strlcpyFunction · 0.50

Tested by

no test coverage detected