Documentation is available at docsis_classifier.php
- <?php
- /**
- * DOCSIS Packet Classifiers
- *
- * @author David Eder <david@eder.us>
- * @copyright 2004 David Eder
- * @package docsis_config
- * @version .3
- */
- /**
- */
- require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_common.php');
- require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_error.php');
- require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_vendor.php');
- define('DOCSIS_UPSTREAM_PACKET_CLASSIFIER', 22);
- define('DOCSIS_DOWNSTREAM_PACKET_CLASSIFIER', 23);
- define('DOCSIS_PACKET_CLASSIFIER_REFERENCE', 1);
- define('DOCSIS_PACKET_CLASSIFIER_IDENTIFIER', 2);
- define('DOCSIS_PACKET_CLASSIFIER_FLOW_REFERENCE', 3);
- define('DOCSIS_PACKET_CLASSIFIER_FLOW_IDENTIFIER', 4);
- define('DOCSIS_PACKET_CLASSIFIER_RULE_PRIORITY', 5);
- define('DOCSIS_PACKET_CLASSIFIER_ACTIVATION_STATE', 6);
- define('DOCSIS_PACKET_CLASSIFIER_DSC_ACTION', 7);
- define('DOCSIS_PACKET_CLASSIFIER_ERROR', 8);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET', 9);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_TOS', 1);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_PROTOCOL', 2);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_ADDRESS', 3);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_MASK', 4);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_ADDRESS', 5);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_MASK', 6);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_START', 7);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_END', 8);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_START', 9);
- define('DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_END', 10);
- define('DOCSIS_PACKET_CLASSIFIER_ETHERNET', 10);
- define('DOCSIS_PACKET_CLASSIFIER_ETHERNET_DEST_MAC', 1);
- define('DOCSIS_PACKET_CLASSIFIER_ETHERNET_SOURCE_MAC', 2);
- define('DOCSIS_PACKET_CLASSIFIER_ETHERNET_DSAP_TYPE', 3);
- define('DOCSIS_PACKET_CLASSIFIER_IEEE', 11);
- define('DOCSIS_PACKET_CLASSIFIER_IEEE_USER_PRIORITY', 1);
- define('DOCSIS_PACKET_CLASSIFIER_IEEE_VLAN_ID', 2);
- /**
- * DOCSIS IP Packet Classifier
- *
- * @package docsis_config
- * @subpackage docsis_classifier
- */
- class docsis_ip_packet_classifier extends docsis_encoder_complex
- {
- /**
- * Constructor
- *
- * @param int $code docsis code
- * @param array $value predefined values
- */
- function docsis_ip_packet_classifier($code=DOCSIS_PACKET_CLASSIFIER_IP_PACKET, $value=array())
- {
- parent::docsis_encoder_complex($code, $value);
- }
- /**
- * Set Type of Service - docsis 1.1
- *
- * The values of the field specify the matching parameters for the IP ToS byte rand and mask. An IP packet with IP ToS byte value "ip-tos"
- * matches this parameter if $low <= (ip-tos AND $mask) <= $high. If this field is ommitted, then comparison of IP packet ToS byte for
- * this entry is irrelavant.
- *
- * @param int $low
- * @param int $high
- * @param int $mask
- */
- function set_type_of_service($low, $high, $mask)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_TOS] =
- new docsis_encoder_string(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_TOS, chr($low) . chr($high) . chr($mask));
- }
- /**
- * Set Protocol - docsis 1.1
- *
- * The value of the field specifies the matching value for the IP Protocol field (RFC-1700). If this parameter is ommitted, then
- * comparison of the IP header Protocol field is irrelevant.
- *
- * There are two special IP Protocol field values: "256" matches traffic with any IP Protocol value, and "257" matches both TCP and UDP
- * traffic. An entry that includes an IP Protocol field value greater than 257 must be invalidated for comparisons (i.e., no traffic can
- * match this entry).
- *
- * @param int $value
- */
- function set_protocol($value)
- {
- if($value < 0 || $value > 257) trigger_error('Protocol must be 0 to 257', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_PROTOCOL] = new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_PROTOCOL, $value);
- }
- /**
- * Set IP Source Address - docsis 1.1
- *
- * @param string $ip
- */
- function set_source_address($ip)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_ADDRESS] = new docsis_encoder_ip(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_ADDRESS, $ip);
- }
- /**
- * Set IP Source Mask - docsis 1.1
- *
- * @param string $mask
- */
- function set_source_mask($mask)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_MASK] = new docsis_encoder_ip(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_MASK, $mask);
- }
- /**
- * Set Destination Address - docsis 1.1
- *
- * @param string $ip
- */
- function set_dest_address($ip)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_ADDRESS] = new docsis_encoder_ip(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_ADDRESS, $ip);
- }
- /**
- * Set Destination Mask - docsis 1.1
- *
- * @param string $mask
- */
- function set_dest_mask($mask)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_MASK] = new docsis_encoder_ip(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_MASK, $mask);
- }
- /**
- * Set TCP/UDP Source Port Start - docsis 1.1
- *
- * @param int $start
- */
- function set_source_port_start($start)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_START] =
- new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_START, $start);
- }
- /**
- * Set TCP/UDP Source Port End - docsis 1.1
- *
- * @param int $end
- */
- function set_source_port_end($end)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_END] =
- new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_SOURCE_PORT_END, $end);
- }
- /**
- * Set TCP/UDP Destination Port Start - docsis 1.1
- *
- * @param int $start
- */
- function set_dest_port_start($start)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_START] =
- new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_START, $start);
- }
- /**
- * Set TCP/UDP Destination Port End - docsis 1.1
- *
- * @param int $end
- */
- function set_dest_port_end($end)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_END] = new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IP_PACKET_DEST_PORT_END, $end);
- }
- }
- /**
- * DOCSIS Ethernet Packet Classifier
- *
- * @package docsis_config
- * @subpackage docsis_classifier
- */
- class docsis_ether_packet_classifier extends docsis_encoder_complex
- {
- /**
- * Constructor
- *
- * @param int $code docsis code
- * @param array $value predefined values
- */
- function docsis_ether_packet_classifier($code=DOCSIS_PACKET_CLASSIFIER_ETHERNET, $value=array())
- {
- parent::docsis_encoder_complex($code, $value);
- }
- /**
- * Set Destination MAC Address - docsis 1.1
- *
- * @param string $mac
- */
- function set_dest_mac($mac)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_ETHERNET_DEST_MAC] = new docsis_encoder_mac(DOCSIS_PACKET_CLASSIFIER_ETHERNET_DEST_MAC, $mac);
- }
- /**
- * Set Source MAC Address - docsis 1.1
- *
- * @param string $mac
- */
- function set_source_mac($mac)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_ETHERNET_SOURCE_MAC] = new docsis_encoder_mac(DOCSIS_PACKET_CLASSIFIER_ETHERNET_SOURCE_MAC, $mac);
- }
- /**
- * Set Ethernet/DSAP/MacType - docsis 1.1
- *
- * $type, $eprot1, and $eprot2 indicate the format of the layer 3 protocol ID in the Ethernet packet as follows:
- *
- * If $type is 0, the rule does not use layer 3 protocol type as a matching criteria. $eprot1 and $eprot2 are ignored.
- *
- * If $type is 1, the rule applies only to frames with contain an Ethertype value. Ethertype values are contained in packets using the
- * DEC-Intel-Xeros (DIX) encapsulation or the RFC-1042 Sub-Network Access Protocol (SNAP) encapsulation formats. $eprot1 and $eprot2 give
- * the 16-bit value of the Ethertype that the packet must match in order to match the rule.
- *
- * If $type is 2, the rule applies only to frames using the IEEE 802.2 encapsulation format with a Destination Service (DSAP) other than
- * 0xAA (which is reserved for SNAP). The lower 8 bits of $eprot1,$eprot2 must match the DSAP byte of the packet in order to match the rule.
- *
- * If $type is 3, the rule applies only to MAC Management Messages (FC field 1100001x) with a "type" field of its MAC Management Message
- * header between the values of $eprot1 and $eprot2, inclusive. As exceptions, the following MAC Management message types must not be
- * classified, and are always transmitted on the primary service flow:
- * <ul>
- * <li>Type 4: RNG_REQ</li>
- * <li>Type 6: REG_REQ</li>
- * <li>Type 7: REG_RSP</li>
- * <li>Type 14: REG_ACK</li>
- * </ul>
- *
- * If $type is 4, the rule is considered a "catch-all" rule that matches all Data PDU packets. The rule does not match MAC Management
- * Messages. $eprot1 and $eprot2 are ignored.
- *
- * If the Ethernet frame contains an 802.1P/Q Tag Header (i.e., Ethertype 0x8100), this object applies to the embedded Ethertype field
- * within the 802.1P/Q header.
- *
- * @param int $type
- * @param int $eprot1
- * @param int $eprot2
- */
- function set_dsap_type($type, $eprot1=0, $eprot2=0)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_ETHERNET_DSAP_TYPE] =
- new docsis_encoder_string(DOCSIS_PACKET_CLASSIFIER_ETHERNET_DSAP_TYPE, chr($type) . chr($eprot1) . chr($eprot2));
- }
- }
- /**
- * DOCSIS IEEE 802 Packet Classifier
- *
- * @package docsis_config
- * @subpackage docsis_classifier
- */
- class docsis_ieee802_packet_classifier extends docsis_encoder_complex
- {
- /**
- * Constructor
- *
- * @param int $code docsis code
- * @param array $value predefined values
- */
- function docsis_ieee802_packet_classifier($code=DOCSIS_PACKET_CLASSIFIER_IEEE, $value=array())
- {
- parent::docsis_encoder_complex($code, $value);
- }
- /**
- * Set IEEE 802.1P User Priority - docsis 1.1
- *
- * The values of the field specify the matching parameters for the IEEE 802.1P user_priority bits. An Ethernet packet with IEEE 802.1P
- * user_priority value "priority" matches these parameters if $low <= priority <= $high.
- *
- * If this parameter is specified for an entry, then Ethernet packets without IEEE 802.1Q encapsulation must not match this entry. If this
- * parameter is specified to an entry on a CM that does not support forwarding of IEEE 802.1Q encapsulated traffic, then this entry must
- * not be use for any traffic.
- *
- * @param int $low
- * @param int $high
- */
- function set_user_priority($low, $high)
- {
- if($low < 0 || $low > 7) trigger_error('User Priority Low must be 0 to 7', E_USER_WARNING);
- if($high < 0 || $high > 7) trigger_error('User Priority High must be 0 to 7', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_IEEE_USER_PRIORITY] =
- new docsis_encoder_string(DOCSIS_PACKET_CLASSIFIER_IEEE_USER_PRIORITY, chr($low) . chr($high));
- }
- /**
- * Set IEEE 802.1Q VLAN_ID - docsis 1.1
- *
- * The value of the field specify the matching value for the IEEE 802.1Q vlan_id bits. Only the first (i.e., most-significant) 12 bits
- * of the specified vland_id field are significant; the final four bits must be ignored for comparison.
- *
- * If this parameter is specified for an entry, then Ethernet packets without IEEE 802.1Q encapsulation must not match this entry. If this
- * parameter is specified to an entry on a CM that does not support forwarding of IEEE 802.1Q encapsulated traffic, then this entry must
- * not be use for any traffic.
- *
- * @param $id
- */
- function set_vlan_id($id)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_IEEE_VLAN_ID] = new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IEEE_VLAN_ID, $id);
- }
- }
- /**
- * DOCSIS Packet Classifier
- *
- * @package docsis_config
- * @subpackage docsis_classifier
- */
- class docsis_packet_classifier extends docsis_encoder_complex
- {
- /**
- * Constructor
- *
- * @param int $code docsis code
- * @param array $value predefined values
- */
- function docsis_packet_classifier($code, $value=array())
- {
- parent::docsis_encoder_complex($code, $value);
- }
- /**
- * Set Classifier Reference - docsis 1.1
- *
- * The value of the field specifies a reference for the Classifier. This value must be unique per Dynamic Service message, configuration
- * file, or Registration Request message.
- *
- * @param int $value
- */
- function set_reference($value)
- {
- if($value < 1 || $value > 255) trigger_error('Reference must be 1 to 255', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_REFERENCE] = new docsis_encoder_uchar(DOCSIS_PACKET_CLASSIFIER_REFERENCE, $value);
- }
- /**
- * Set Classifier Identifier - docsis 1.1
- *
- * The value of the field specifies an identifier for the Classifier. This value must be unique per Service Flow. The CMTS assigns the
- * Packet Classifier Identifier.
- *
- * @param int $value
- */
- function set_identifier($value)
- {
- if($value < 1 || $value > 65535) trigger_error('Identifier must be 1 to 65535', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_IDENTIFIER] = new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_IDENTIFIER, $value);
- }
- /**
- * Set Service Flow Reference - docsis 1.1
- *
- * The value of the field specifies a Service Flow Reference that identifies the corresponding Service Flow.
- *
- * @param int $value
- */
- function set_flow_reference($value)
- {
- if($value < 1 || $value > 65535) trigger_error('Service Flow Reference must be 1 to 65535', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_FLOW_REFERENCE] = new docsis_encoder_ushort(DOCSIS_PACKET_CLASSIFIER_FLOW_REFERENCE, $value);
- }
- /**
- * Set Service Flow Identifier - docsis 1.1
- *
- * The value of the field specifies the Service Flow ID that identifies the corresponding Service Flow.
- *
- * @param int $value
- */
- function set_flow_identifier($value)
- {
- if($value < 1 || $value > 4294967295) trigger_error('Service Flow Identifier must be 1 to 65535', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_FLOW_IDENTIFIER] = new docsis_encoder_uint(DOCSIS_PACKET_CLASSIFIER_FLOW_IDENTIFIER, $value);
- }
- /**
- * Set Rule Priority - docsis 1.1
- *
- * The value of the field specifies the priority for the Classifier, which is used for determining the order of the Classifier. A higher
- * value indicates higher priority
- *
- * @param int $value
- */
- function set_rule_priority($value)
- {
- $this->value[DOCSIS_PACKET_CLASSIFIER_RULE_PRIORITY] = new docsis_encoder_uchar(DOCSIS_PACKET_CLASSIFIER_RULE_PRIORITY, $value);
- }
- /**
- * Set Activation State - docsis 1.1
- *
- * @param boolean $value
- */
- function set_activation_state($value)
- {
- if($value < 0 || $value > 1) trigger_error('Activation State must be 0 or 1', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_ACTIVATION_STATE] = new docsis_encoder_uchar(DOCSIS_PACKET_CLASSIFIER_ACTIVATION_STATE, $value);
- }
- /**
- * Set Dynamic Service Change Action - docsis 1.1
- *
- * 0: Add Classifier
- * 1: Replace Classifier
- * 2: Delete Classifier
- *
- * @param int $value
- */
- function set_dsc_action($value)
- {
- if($value < 0 || $value > 2) trigger_error('Activation State must be 0 or 1 or 2', E_USER_WARNING);
- $this->value[DOCSIS_PACKET_CLASSIFIER_DSC_ACTION] = new docsis_encoder_uchar(DOCSIS_PACKET_CLASSIFIER_DSC_ACTION, $value);
- }
- /**
- * Set Error - docsis 1.1
- *
- * @param docsis_error $value
- */
- function set_error($value)
- {
- // todo: must be a docsis_error
- $this->value[DOCSIS_PACKET_CLASSIFIER_ERROR] = $value;
- }
- /**
- * Set IP Packet Classifier - docsis 1.1
- *
- * @param docsis_ip_packet_classifier $value
- */
- function set_ip_packet_classifier($value)
- {
- // todo: must be a docsis_ip_packet_classifier
- $this->value[DOCSIS_PACKET_CLASSIFIER_IP_PACKET] = $value;
- }
- /**
- * Set MAC Classifier - docsis 1.1
- *
- * @param docsis_ether_packet_classifier $value
- */
- function set_mac_classifier($value)
- {
- // todo: must be a docsis_ether_packet_classifier
- $this->value[DOCSIS_PACKET_CLASSIFIER_ETHERNET] = $value;
- }
- /**
- * Set IEEE 802 Classifier - docsis 1.1
- *
- * @param docsis_ieee802_packet_classifier $value
- */
- function set_ieee802_classifier($value)
- {
- // todo: must be a docsis_ieee802_packet_classifier
- $this->value[DOCSIS_PACKET_CLASSIFIER_IEEE] = $value;
- }
- /**
- * Set Vendor Specific Information - docsis 1.1
- *
- * @param docsis_vendor $value
- */
- function set_vendor($value)
- {
- // todo: must exist be a docsis_vendor
- $this->value[DOCSIS_VENDOR] = $value;
- }
- }
- ?>
Documentation generated on Mon, 14 Nov 2005 17:59:40 -0700 by phpDocumentor 1.3.0RC3