config_parser Package

cisco_router_parser Module

Created on May 11, 2011

@author: peymankazemian

class sts.headerspace.config_parser.cisco_router_parser.ciscoRouter(switch_id)[source]

Bases: object

Cisco router parser. The generated transfer function will have three sub-layers: 1) from input port to fwd port: the packet will go through input acl, and vlan untag process 2) from fwd port to pre-output port: the forwarding table will find output port. but the output filter has not been applied yet. 3) from pre-output port to output port: this is where output acl filter is being done. So in order to see the ultimate faith of packet, we need to apply the tf.T() 3 consequative times.

static HS_FORMAT()[source]
PORT_ID_MULTIPLIER = 1
PORT_TYPE_MULTIPLIER = 10000
SWITCH_ID_MULTIPLIER = 100000
__init__(switch_id)[source]

Constructor

acl_dictionary_entry_to_bytearray(dic_entry)[source]
static acl_dictionary_entry_to_string(entry)[source]
generate_port_ids(additional_ports)[source]

looks at all the ports that has FWD mode for any vlan or appear as forwarding port of a forwarding rule, and assign a unique ID to them based on switch_id and a random port id. addition_ports will also be considered and assigned a unqie ID. This is for ports that exist on the switch but are not part of any vlan or output of forwarding rules.

generate_transfer_function(tf)[source]

After calling read_config_file(), read_spanning_tree_file() and read_route_file(), generate_port_ids(), and optionally optimize_forwarding_table(), this method may be called to generate transfer function rules corresponding to this box. The rules will be added to transfer function tf passed to the function.

static get_ethernet_port_name(port)[source]
get_port_id(port_name)[source]
static get_protocol_number(proto_name)[source]
get_switch_id()[source]
static get_tcp_port_number(port_name)[source]
static get_transport_port_number(port)[source]
static get_udp_port_number(port_name)[source]
static make_acl_dictionary_entry()[source]
optimize_forwarding_table()[source]
parse_access_list_entry(entry, line_counter)[source]
read_arp_table_file(file_path)[source]

Reads in CISCO router arp table - sh arp

read_config_file(file_path)[source]

Reads in the CISCO router config file and extracts access list entries and the ports/vlans they apply to.

read_mac_table_file(file_path)[source]

Reads in CISCO mac address table - sh mac-address-table

read_route_file(file_path)[source]

Reads in the CISCO router “sh ip cef” output and extracts the forwarding table entries.

read_spanning_tree_file(file_path)[source]

Reads in, the CISCO router “sh spanning-tree” output and extracts the list of ports that are in FWD mode for each vlan.

set_field(arr, field, value, right_mask)[source]

Sets the field in byte array arr to value. @arr: the bytearray to set the field bits to value. @field: ‘vlan’, ‘ip_src’, ‘ip_dst’, ‘ip_proto’, ‘tcp_src’, ‘tcp_dst’, ‘tcp_ctrl’ @value: an integer number, of the width equal to field’s width @right_mask: number of bits, from right that should be ignored when written to field. e.g. to have a /24 ip address, set mask to 8.

set_hs_format(hs_format)[source]
set_replaced_vlan(vlan)[source]
set_witch_id(switch_id)[source]
wc_to_parsed_string(byte_arr)[source]

helper Module

Created on Jun 1, 2011

@author: peymankazemian

sts.headerspace.config_parser.helper.compress_ip_list(ip_list)[source]

ip_list is a list of ip address, subnet, next_hop,... of type (int,int,string,...) we compress it, and return a list of (int ip address,int subnet,next_hop,[ip_list_elem]) where list of ip_list_elem shows which input ipl_list elem is compressed to create the output entry and next_hop is a string indicating the next hop.

sts.headerspace.config_parser.helper.dotted_ip_to_int(dotted_ip)[source]
sts.headerspace.config_parser.helper.dotted_subnet_to_int(dotted_subnet)[source]
sts.headerspace.config_parser.helper.find_num_mask_bits_left_mak(mask)[source]
sts.headerspace.config_parser.helper.find_num_mask_bits_right_mak(mask)[source]
sts.headerspace.config_parser.helper.int_to_dotted_ip(intip)[source]
sts.headerspace.config_parser.helper.is_ip_address(str)[source]
sts.headerspace.config_parser.helper.is_ip_subnet(str)[source]
class sts.headerspace.config_parser.helper.node[source]

Bases: object

__init__()[source]
is_leaf()[source]
optimize(action)[source]
output_compressed(power, cip, result)[source]
printSelf(indent)[source]
sts.headerspace.config_parser.helper.range_to_wildcard(r_s, r_e, length)[source]

hp_switch_parser Module

Created on Jul 6, 2011

@author: peymankazemian

class sts.headerspace.config_parser.hp_switch_parser.HPSwitch(switch_id)[source]
__init__(switch_id)[source]
read_config_file(file)[source]

openflow_parser Module

Created on Mar 7, 2012

@author: rcs

sts.headerspace.config_parser.openflow_parser.HS_FORMAT()[source]
sts.headerspace.config_parser.openflow_parser.default_display(bytes)[source]
sts.headerspace.config_parser.openflow_parser.ethernet_display(bytes)[source]
class sts.headerspace.config_parser.openflow_parser.field_info

Bases: tuple

field_info(position, length)

length

Alias for field number 1

position

Alias for field number 0

sts.headerspace.config_parser.openflow_parser.generate_transfer_function(tf, software_switch, ignore_lldp=True)[source]

The rules will be added to transfer function tf passed to the function.

sts.headerspace.config_parser.openflow_parser.get_kw_for_field_match(field_match)[source]
sts.headerspace.config_parser.openflow_parser.get_uniq_port_id(switch, port)[source]

HSA assumes uniquely labeled ports

sts.headerspace.config_parser.openflow_parser.ip_display(bytes)[source]
sts.headerspace.config_parser.openflow_parser.ofp_actions_to_hsa_rewrite(ofp_actions)[source]
sts.headerspace.config_parser.openflow_parser.ofp_actions_to_output_ports(ofp_actions, switch, all_port_ids, in_port_id)[source]
sts.headerspace.config_parser.openflow_parser.ofp_match_to_hsa_match(ofp_match)[source]
sts.headerspace.config_parser.openflow_parser.ofp_match_to_input_ports(ofp_match, switch, all_port_ids)[source]
sts.headerspace.config_parser.openflow_parser.optimize_forwarding_table(self)[source]
sts.headerspace.config_parser.openflow_parser.set_field(arr, field, value, right_mask=0)[source]

Sets the field in byte array arr to value. @arr: the bytearray to set the field bits to value. @field: ‘eth_src’,’eth_dst’,’vlan’,’vlan_priority’,’eth_frame’,’ip_tos’,’ip_src’,’ip_dst’,’ip_proto’,’tcp_src’,’tcp_dst’ @value: an integer number, of the width equal to field’s width @right_mask: number of bits, from right that should be ignored when written to field. e.g. to have a /24 ip address, set mask to 8.

sts.headerspace.config_parser.openflow_parser.tf_from_switch(ntf, switch, real_switch)[source]
sts.headerspace.config_parser.openflow_parser.wc_to_parsed_string(byte_arr)[source]

test_parser Module

Created on Jul 5, 2011

@author: peymankazemian

test_parser_gen Module

Table Of Contents

Previous topic

headerspace Package

Next topic

headerspace Package

This Page