FreeBSD/sys/netpfil/ipfw/ip_fw_table.c
/*
 * Allocate new table config structure using
 * specified @algo and @aname.
 *
 * Returns pointer to config or NULL.
 */
Allocate new table config structure using
specified @algo and @aname.

Returns pointer to config or NULL.
Allocate new table config structure using specified @algo and @aname . Returns pointer to config or NULL .
static struct table_config *
alloc_table_config(struct ip_fw_chain *ch, struct tid_info *ti,
    struct table_algo *ta, char *aname, uint8_t tflags)
{
	char *name, bname[16];
	struct table_config *tc;
	int error;
	ipfw_obj_ntlv *ntlv;
	uint32_t set;
	if (ti->tlvs != NULL) {
		ntlv = ipfw_find_name_tlv_type(ti->tlvs, ti->tlen, ti->uidx,
		    IPFW_TLV_TBL_NAME);
		if (ntlv == NULL)
			return (NULL);
		name = ntlv->name;
		set = ntlv->set;
	} else {
		snprintf(bname, sizeof(bname), "%d", ti->uidx);
		name = bname;
		set = 0;
	}
	tc = malloc(sizeof(struct table_config), M_IPFW, M_WAITOK | M_ZERO);
	tc->no.name = tc->tablename;
	tc->no.subtype = ta->type;
	tc->no.set = set;
	tc->tflags = tflags;
	tc->ta = ta;
	strlcpy(tc->tablename, name, sizeof(tc->tablename));
	tc->vshared = 1;
	error = ta->init(ch, &tc->astate, &tc->ti_copy, aname, tflags);
	if (error != 0) {
		free(tc, M_IPFW);
		return (NULL);
	}
	return (tc);
}
static struct table_config * alloc_table_config ( struct ip_fw_chain * ch , struct tid_info * ti , struct table_algo * ta , char * aname , uint8_t tflags ) { char * name , bname [ 16 ] ; struct table_config * tc ; int error ; ipfw_obj_ntlv * ntlv ; uint32_t set ; if ( ti -> tlvs != NULL ) { ntlv = ipfw_find_name_tlv_type ( ti -> tlvs , ti -> tlen , ti -> uidx , IPFW_TLV_TBL_NAME ) ; if ( ntlv == NULL ) return ( NULL ) ; name = ntlv -> name ; set = ntlv -> set ; } else { snprintf ( bname , sizeof ( bname ) , " " , ti -> uidx ) ; name = bname ; set = 0 ; } tc = malloc ( sizeof ( struct table_config ) , M_IPFW , M_WAITOK | M_ZERO ) ; tc -> no . name = tc -> tablename ; tc -> no . subtype = ta -> type ; tc -> no . set = set ; tc -> tflags = tflags ; tc -> ta = ta ; strlcpy ( tc -> tablename , name , sizeof ( tc -> tablename ) ) ; tc -> vshared = 1 ; error = ta -> init ( ch , & tc -> astate , & tc -> ti_copy , aname , tflags ) ; if ( error != 0 ) { free ( tc , M_IPFW ) ; return ( NULL ) ; } return ( tc ) ; }
Allocate new table config structure using
 specified @algo and @aname.
Allocate new table config structure using specified @algo and @aname .
/* Compat part: convert number to string representation */ /* Set "shared" value type by default */ /* Preallocate data structures for new tables */