Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_fw_table.c
Show First 20 Lines • Show All 2,746 Lines • ▼ Show 20 Lines | classify_srcdst(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype) | ||||
if (F_LEN(cmd) > F_INSN_SIZE(ipfw_insn_u32)) { | if (F_LEN(cmd) > F_INSN_SIZE(ipfw_insn_u32)) { | ||||
/* | /* | ||||
* generic lookup. The key must be | * generic lookup. The key must be | ||||
* in 32bit big-endian format. | * in 32bit big-endian format. | ||||
*/ | */ | ||||
v = ((ipfw_insn_u32 *)cmd)->d[1]; | v = ((ipfw_insn_u32 *)cmd)->d[1]; | ||||
switch (v) { | switch (v) { | ||||
case 0: | case LOOKUP_DST_IP: | ||||
case 1: | case LOOKUP_SRC_IP: | ||||
/* IPv4 src/dst */ | |||||
break; | break; | ||||
case 2: | case LOOKUP_DST_PORT: | ||||
case 3: | case LOOKUP_SRC_PORT: | ||||
/* src/dst port */ | case LOOKUP_UID: | ||||
case LOOKUP_JAIL: | |||||
case LOOKUP_DSCP: | |||||
*ptype = IPFW_TABLE_NUMBER; | *ptype = IPFW_TABLE_NUMBER; | ||||
break; | break; | ||||
case 4: | case LOOKUP_DST_MAC: | ||||
/* uid/gid */ | case LOOKUP_SRC_MAC: | ||||
*ptype = IPFW_TABLE_NUMBER; | *ptype = IPFW_TABLE_MAC; | ||||
break; | break; | ||||
case 5: | |||||
/* jid */ | |||||
*ptype = IPFW_TABLE_NUMBER; | |||||
break; | |||||
case 6: | |||||
/* dscp */ | |||||
*ptype = IPFW_TABLE_NUMBER; | |||||
break; | |||||
} | } | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
classify_via(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype) | classify_via(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype) | ||||
Show All 16 Lines | |||||
{ | { | ||||
*puidx = cmd->arg1; | *puidx = cmd->arg1; | ||||
*ptype = IPFW_TABLE_FLOW; | *ptype = IPFW_TABLE_FLOW; | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | |||||
classify_mac_lookup(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype) | |||||
{ | |||||
*puidx = cmd->arg1; | |||||
*ptype = IPFW_TABLE_MAC; | |||||
return (0); | |||||
} | |||||
static void | static void | ||||
update_arg1(ipfw_insn *cmd, uint16_t idx) | update_arg1(ipfw_insn *cmd, uint16_t idx) | ||||
{ | { | ||||
cmd->arg1 = idx; | cmd->arg1 = idx; | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | static struct opcode_obj_rewrite opcodes[] = { | ||||
.find_bykidx = table_findbykidx, | .find_bykidx = table_findbykidx, | ||||
.create_object = create_table_compat, | .create_object = create_table_compat, | ||||
.manage_sets = table_manage_sets, | .manage_sets = table_manage_sets, | ||||
}, | }, | ||||
{ | { | ||||
.opcode = O_IP_FLOW_LOOKUP, | .opcode = O_IP_FLOW_LOOKUP, | ||||
.etlv = IPFW_TLV_TBL_NAME, | .etlv = IPFW_TLV_TBL_NAME, | ||||
.classifier = classify_flow, | .classifier = classify_flow, | ||||
.update = update_arg1, | |||||
.find_byname = table_findbyname, | |||||
.find_bykidx = table_findbykidx, | |||||
.create_object = create_table_compat, | |||||
.manage_sets = table_manage_sets, | |||||
}, | |||||
{ | |||||
.opcode = O_MAC_SRC_LOOKUP, | |||||
.etlv = IPFW_TLV_TBL_NAME, | |||||
.classifier = classify_mac_lookup, | |||||
.update = update_arg1, | |||||
.find_byname = table_findbyname, | |||||
.find_bykidx = table_findbykidx, | |||||
.create_object = create_table_compat, | |||||
.manage_sets = table_manage_sets, | |||||
}, | |||||
{ | |||||
.opcode = O_MAC_DST_LOOKUP, | |||||
.etlv = IPFW_TLV_TBL_NAME, | |||||
.classifier = classify_mac_lookup, | |||||
.update = update_arg1, | .update = update_arg1, | ||||
.find_byname = table_findbyname, | .find_byname = table_findbyname, | ||||
.find_bykidx = table_findbykidx, | .find_bykidx = table_findbykidx, | ||||
.create_object = create_table_compat, | .create_object = create_table_compat, | ||||
.manage_sets = table_manage_sets, | .manage_sets = table_manage_sets, | ||||
}, | }, | ||||
{ | { | ||||
.opcode = O_XMIT, | .opcode = O_XMIT, | ||||
▲ Show 20 Lines • Show All 396 Lines • Show Last 20 Lines |