Treat IPv4 subnet masks as distinct from addresses

While IPv4 subnet masks are obviously related and similar to IPv4
addresses, they are distinct enough that they need to be treated
seperately in some aspects.  For instance, there is no value in
attempting to resolve a subnet mask.

This change creates a new display type: BASE_NETMASK, which allows distinction from FT_IPv4
(and possible name resolution) where appropriate.

Change-Id: I99e19c9a58eb613f8e58d481af84c30e2e5e14d7
Reviewed-on: https://code.wireshark.org/review/10438
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Jeffrey Smith 2015-09-06 20:56:30 -05:00 committed by Michael Mann
parent b02a0ee48a
commit 57d954e168
21 changed files with 63 additions and 29 deletions

View File

@ -138,6 +138,13 @@ FIELDDISPLAY --For FT_UINT{8,16,24,32,40,48,56,64} and
a separator between bytes.
BASE_NONE has no separator between bytes
--For FT_IPv4:
BASE_NETMASK - Used for IPv4 address that should never
attempted to be resolved (like netmasks)
otherwise:
(must be) BASE_NONE
--For all other types:
BASE_NONE

View File

@ -250,7 +250,7 @@ static void mark_lval_deprecated(const char *s);
[-[:alnum:]_\.:]+\/[[:digit:]]+ {
[-[:alnum:]_\.:]*\/[[:digit:]]+ {
/* CIDR */
return set_lval(TOKEN_UNPARSED, yytext);
}

View File

@ -565,7 +565,7 @@ proto_register_adwin_config(void)
},
{ &hf_adwin_config_netmask,
{ "Netmask", "adwin_config.netmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }
},
{ &hf_adwin_config_netmask_count,

View File

@ -3444,7 +3444,7 @@ proto_register_afs(void)
{ &hf_afs_cm_ipaddr, { "IP Address", "afs.cm.ipaddr",
FT_IPv4, BASE_NONE, 0, 0, NULL, HFILL }},
{ &hf_afs_cm_netmask, { "Netmask", "afs.cm.netmask",
FT_IPv4, BASE_NONE, 0, 0, NULL, HFILL }},
FT_IPv4, BASE_NETMASK, 0, 0, NULL, HFILL }},
{ &hf_afs_cm_mtu, { "MTU", "afs.cm.mtu",
FT_UINT32, BASE_DEC, 0, 0, NULL, HFILL }},

View File

@ -6258,7 +6258,7 @@ proto_register_bootp(void)
{ &hf_bootp_option_subnet_mask,
{ "Subnet Mask", "bootp.option.subnet_mask",
FT_IPv4, BASE_NONE, NULL, 0x00,
FT_IPv4, BASE_NETMASK, NULL, 0x00,
"Option 1: Subnet Mask", HFILL }},
{ &hf_bootp_option_time_offset,
@ -6358,7 +6358,7 @@ proto_register_bootp(void)
{ &hf_bootp_option_policy_filter_subnet_mask,
{ "Subnet Mask", "bootp.option.policy_filter.subnet_mask",
FT_IPv4, BASE_NONE, NULL, 0x00,
FT_IPv4, BASE_NETMASK, NULL, 0x00,
"Option 21: Subnet Mask", HFILL }},
{ &hf_bootp_option_non_local_source_routing,

View File

@ -5424,7 +5424,7 @@ proto_register_capwap_control(void)
},
{ &hf_capwap_fortinet_cfg_mask,
{ "Mask", "capwap.control.fortinet.cfg.mask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }
},
{ &hf_capwap_fortinet_split_tun_cfg_enable_local_subnet,
@ -5583,7 +5583,7 @@ proto_register_capwap_control(void)
},
{ &hf_capwap_cisco_ap_static_ip_netmask,
{ "Netmask", "capwap.control.cisco.ap_static_ip.netmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }
},
{ &hf_capwap_cisco_ap_static_ip_gateway,

View File

@ -360,7 +360,7 @@ proto_register_slarp(void)
/* XXX - need an FT_ for netmasks, which is like FT_IPV4 but doesn't
get translated to a host name. */
{ &hf_slarp_netmask,
{ "Netmask", "slarp.netmask", FT_IPv4, BASE_NONE,
{ "Netmask", "slarp.netmask", FT_IPv4, BASE_NETMASK,
NULL, 0x0, NULL, HFILL }},
{ &hf_slarp_mysequence,
{ "Outgoing sequence number", "slarp.mysequence", FT_UINT32, BASE_DEC,

View File

@ -745,7 +745,7 @@ proto_register_dvmrp(void)
NULL, 0, NULL, HFILL }},
{ &hf_netmask,
{ "Netmask", "dvmrp.netmask", FT_IPv4, BASE_NONE,
{ "Netmask", "dvmrp.netmask", FT_IPv4, BASE_NETMASK,
NULL, 0, "DVMRP Netmask", HFILL }},
{ &hf_metric,

View File

@ -2917,7 +2917,7 @@ proto_register_enip(void)
{ &hf_tcpip_ic_subnet_mask,
{ "Subnet Mask", "cip.tcpip.subnet_mask",
FT_IPv4, BASE_NONE, NULL, 0,
FT_IPv4, BASE_NETMASK, NULL, 0,
NULL, HFILL }},
{ &hf_tcpip_ic_gateway,

View File

@ -3898,7 +3898,7 @@ proto_register_epl(void)
},
{ &hf_epl_asnd_identresponse_snm,
{ "SubnetMask", "epl.asnd.ires.subnet",
FT_IPv4, BASE_NONE, NULL, 0x00, NULL, HFILL }
FT_IPv4, BASE_NETMASK, NULL, 0x00, NULL, HFILL }
},
{ &hf_epl_asnd_identresponse_gtw,
{ "DefaultGateway", "epl.asnd.ires.gateway",

View File

@ -2566,7 +2566,7 @@ void proto_register_gvcp(void)
{ &hf_gvcp_forceip_static_subnet_mask,
{ "Subnet Mask", "gvcp.cmd.forceip.subnetmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }},
{ &hf_gvcp_forceip_static_default_gateway,
@ -2847,7 +2847,7 @@ void proto_register_gvcp(void)
{ &hf_gvcp_current_subnet_mask,
{ "Subnet Mask", "gvcp.bootstrap.currentsubnetmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }},
/* GVCP_CURRENT_DEFAULT_GATEWAY_0, 1, 2, 3 */
@ -2933,7 +2933,7 @@ void proto_register_gvcp(void)
{& hf_gvcp_persistent_subnet,
{ "Persistent Subnet Mask", "gvcp.bootstrap.persistentsubnetmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL
}},

View File

@ -6314,7 +6314,7 @@ proto_register_isakmp(void)
"An IPv4 address on the internal network", HFILL }},
{ &hf_isakmp_cfg_attr_internal_ip4_netmask,
{ "INTERNAL IP4 NETMASK", "isakmp.cfg.attr.internal_ip4_netmask",
FT_IPv4, BASE_NONE, NULL, 0x00,
FT_IPv4, BASE_NETMASK, NULL, 0x00,
"The internal network's netmask", HFILL }},
{ &hf_isakmp_cfg_attr_internal_ip4_dns,
{ "INTERNAL IP4 DNS", "isakmp.cfg.attr.internal_ip4_dns",
@ -6366,7 +6366,7 @@ proto_register_isakmp(void)
"The protected sub-networks that this edge-device protects (IP)", HFILL }},
{ &hf_isakmp_cfg_attr_internal_ip4_subnet_netmask,
{ "INTERNAL IP4 SUBNET (NETMASK)", "isakmp.cfg.attr.internal_ip4_subnet_netmask",
FT_IPv4, BASE_NONE, NULL, 0x00,
FT_IPv4, BASE_NETMASK, NULL, 0x00,
"The protected sub-networks that this edge-device protects (IP)", HFILL }},
{ &hf_isakmp_cfg_attr_supported_attributes,
{ "SUPPORTED ATTRIBUTES", "isakmp.cfg.attr.supported_attributes",

View File

@ -816,7 +816,7 @@ void proto_register_olsr(void) {
{ &hf_olsr_netmask,
{ "Netmask", "olsr.netmask",
FT_IPv4, BASE_NONE, NULL, 0,
FT_IPv4, BASE_NETMASK, NULL, 0,
NULL, HFILL
}
},

View File

@ -672,7 +672,7 @@ proto_register_opsi(void)
},
{ &hf_framed_netmask_att,
{ "Framed netmask", "opsi.attr.framed_netmask",
FT_IPv4, BASE_NONE, NULL, 0x00,
FT_IPv4, BASE_NETMASK, NULL, 0x00,
NULL, HFILL }
},
{ &hf_framed_routing_att,

View File

@ -3164,7 +3164,7 @@ proto_register_ospf(void)
BASE_NONE, NULL, 0x0, NULL, HFILL }},
{&hf_ospf_hello_network_mask,
{ "Network Mask", "ospf.hello.network_mask", FT_IPv4,
BASE_NONE, NULL, 0x0, NULL, HFILL }},
BASE_NETMASK, NULL, 0x0, NULL, HFILL }},
{&hf_ospf_hello_interface_id,
{ "Interface ID", "ospf.hello.interface_id", FT_UINT32,
BASE_DEC, NULL, 0x0, NULL, HFILL }},
@ -3265,7 +3265,7 @@ proto_register_ospf(void)
{ "Network LSA", "ospf.lsa.network", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_network_netmask,
{ "Netmask", "ospf.lsa.network.netmask", FT_IPv4, BASE_NONE, NULL, 0x0,
{ "Netmask", "ospf.lsa.network.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_network_attachrtr,
{ "Attached Router", "ospf.lsa.network.attchrtr", FT_IPv4, BASE_NONE, NULL, 0x0,
@ -3278,14 +3278,14 @@ proto_register_ospf(void)
{ "Summary LSA (ASBR)", "ospf.lsa.asbr", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_asbr_netmask,
{ "Netmask", "ospf.lsa.asbr.netmask", FT_IPv4, BASE_NONE, NULL, 0x0,
{ "Netmask", "ospf.lsa.asbr.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_asext,
{ "AS-External LSA (ASBR)", "ospf.lsa.asext", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_asext_netmask,
{ "Netmask", "ospf.lsa.asext.netmask", FT_IPv4, BASE_NONE, NULL, 0x0,
{ "Netmask", "ospf.lsa.asext.netmask", FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }},
{&hf_ospf_ls_asext_fwdaddr,
{ "Forwarding Address", "ospf.lsa.asext.fwdaddr", FT_IPv4, BASE_NONE, NULL, 0x0,

View File

@ -108,7 +108,7 @@ static header_field_info hfi_rip_ip RIP_HFI_INIT = {
NULL, 0, NULL, HFILL};
static header_field_info hfi_rip_netmask RIP_HFI_INIT = {
"Netmask", "rip.netmask", FT_IPv4, BASE_NONE,
"Netmask", "rip.netmask", FT_IPv4, BASE_NETMASK,
NULL, 0, NULL, HFILL};
static header_field_info hfi_rip_next_hop RIP_HFI_INIT = {

View File

@ -1112,7 +1112,7 @@ proto_register_rsip(void)
},
{ &hf_rsip_parameter_address_ipv4_netmask,
{ "IPv4 Netmask", "rsip.parameter.netmask",
FT_IPv4, BASE_NONE, NULL, 0x0,
FT_IPv4, BASE_NETMASK, NULL, 0x0,
NULL, HFILL }
},
{ &hf_rsip_parameter_address_ipv6,

View File

@ -1033,7 +1033,7 @@ proto_register_smcr(void)
{ &hf_smcr_proposal_outgoing_interface_subnet_mask, {
"Outgoing Interface Subnet Mask",
"smcr.outgoing.interface.subnet.mask",
FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL}},
FT_IPv4, BASE_NETMASK, NULL, 0x0, NULL, HFILL}},
{ &hf_smcr_proposal_outgoing_subnet_mask_signifcant_bits, {
"Outgoing Interface Subnet Mask Number of Significant Bits",

View File

@ -1175,7 +1175,7 @@ proto_register_wassp(void)
0x0, NULL, HFILL }},
{ &hf_static_bp_netmask,
{ "STATIC-BP-NETMASK", "wassp.static.bp.netmask", FT_IPv4, BASE_NONE, NULL,
{ "STATIC-BP-NETMASK", "wassp.static.bp.netmask", FT_IPv4, BASE_NETMASK, NULL,
0x0, NULL, HFILL }},
{ &hf_static_bp_gateway,
@ -1235,7 +1235,7 @@ proto_register_wassp(void)
0x0, NULL, HFILL }},
{ &hf_ap_netmask,
{ "AP-NETMASK", "wassp.ap.netmask", FT_IPv4, BASE_NONE, NULL,
{ "AP-NETMASK", "wassp.ap.netmask", FT_IPv4, BASE_NETMASK, NULL,
0x0, NULL, HFILL }},
{ &hf_ap_gateway,

View File

@ -6174,6 +6174,22 @@ tmp_fld_check_assert(header_field_info *hfinfo)
ftype_name(hfinfo->type));
break;
case FT_IPv4:
switch (hfinfo->display) {
case BASE_NONE:
case BASE_NETMASK:
break;
default:
tmp_str = val_to_str_wmem(NULL, hfinfo->display, hf_display, "(Unknown: 0x%x)");
g_error("Field '%s' (%s) is an IPv4 value (%s)"
" but is being displayed as %s\n",
hfinfo->name, hfinfo->abbrev,
ftype_name(hfinfo->type), tmp_str);
wmem_free(NULL, tmp_str);
break;
}
break;
default:
if (hfinfo->display != BASE_NONE) {
tmp_str = val_to_str_wmem(NULL, hfinfo->display, hf_display, "(Bit count: %d)");
@ -6659,7 +6675,14 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
addr.len = 4;
addr.data = &n_addr;
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
if (hfinfo->display == BASE_NETMASK)
{
addr_str = (char*)address_to_str(NULL, &addr);
}
else
{
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
}
g_snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name, addr_str);
wmem_free(NULL, addr_str);

View File

@ -520,7 +520,11 @@ typedef enum {
SEP_DOT = 8, /**< hexadecimal bytes with a period (.) between each byte */
SEP_DASH = 9, /**< hexadecimal bytes with a dash (-) between each byte */
SEP_COLON = 10, /**< hexadecimal bytes with a colon (:) between each byte */
SEP_SPACE = 11 /**< hexadecimal bytes with a space between each byte */
SEP_SPACE = 11, /**< hexadecimal bytes with a space between each byte */
/* Address types */
BASE_NETMASK = 12 /**< Used for IPv4 address that shouldn't be resolved (like for netmasks) */
} field_display_e;
/* Following constants have to be ORed with a field_display_e when dissector