Source for file docsis_flow.php

Documentation is available at docsis_flow.php

  1. <?php
  2. /**
  3. * DOCSIS Service Flow
  4. *
  5. * @author David Eder <david@eder.us>
  6. * @copyright 2004 David Eder
  7. * @package docsis_config
  8. * @version .3
  9. */
  10.  
  11. /**
  12. */
  13. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_common.php');
  14. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_error.php');
  15. require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'docsis_vendor.php');
  16.  
  17. define('DOCSIS_FLOW_UP', 24);
  18. define('DOCSIS_FLOW_IDENTIFIER_2', 3);
  19. define('DOCSIS_FLOW_MAX_CONCAT_BURST', 14);
  20. define('DOCSIS_FLOW_SCHED_TYPE', 15);
  21. define('DOCSIS_FLOW_REQUEST_POLICY', 16);
  22. define('DOCSIS_FLOW_POLLING_INTERVAL', 17);
  23. define('DOCSIS_FLOW_POLL_JITTER', 18);
  24. define('DOCSIS_FLOW_UNSOLICITED_GRANT_SIZE', 19);
  25. define('DOCSIS_FLOW_NOMINAL_GRANT_SIZE', 20);
  26. define('DOCSIS_FLOW_GRANT_JITTER', 21);
  27. define('DOCSIS_FLOW_GRANTS_PER_INTERVAL', 22);
  28. define('DOCSIS_FLOW_TOS_MASK', 23);
  29. define('DOCSIS_FLOW_UNSOLICITED_GRANT_TIME', 24);
  30. define('DOCSIS_FLOW_DOWN', 25);
  31. define('DOCSIS_FLOW_MAX_DOWN_LATENCY', 14);
  32.  
  33. // shared
  34. define('DOCSIS_FLOW_REFERENCE', 1);
  35. define('DOCSIS_FLOW_IDENTIFIER', 2);
  36. define('DOCSIS_FLOW_CLASS_NAME', 4);
  37. define('DOCSIS_FLOW_ERROR', 5);
  38. define('DOCSIS_FLOW_QOS', 6);
  39. define('DOCSIS_FLOW_TRAFFIC_PRIORITY', 7);
  40. define('DOCSIS_FLOW_MAX_RATE', 8);
  41. define('DOCSIS_FLOW_MAX_BURST', 9);
  42. define('DOCSIS_FLOW_MIN_RESERVED_RATE', 10);
  43. define('DOCSIS_FLOW_MIN_RESERVED_PACKET_SIZE', 11);
  44. define('DOCSIS_FLOW_ACTIVE_QOS_TIMEOUT', 12);
  45. define('DOCSIS_FLOW_ADMITTED_QOS_TIMEOUT', 13);
  46.  
  47. /**
  48. * DOCSIS Service Flow
  49. *
  50. * @package docsis_config
  51. * @subpackage docsis_flow
  52. */
  53. class docsis_flow extends docsis_encoder_complex
  54. {
  55. /**
  56. * Constructor
  57. *
  58. * @param int $code docsis code
  59. * @param array $value predefined values
  60. */
  61. function docsis_flow($code, $value=array())
  62. {
  63. parent::docsis_encoder_complex($code, $value);
  64. }
  65.  
  66. /**
  67. * Set Service Flow Reference
  68. *
  69. * See Radio Frequency Interface Specification C.2.2.3.1
  70. *
  71. * @param int $value
  72. */
  73. function set_reference($value)
  74. {
  75. if($value < 1 || $value > 65535) trigger_error('Reference must be 1 to 65535', E_USER_WARNING);
  76. $this->value[DOCSIS_FLOW_REFERENCE] = new docsis_encoder_ushort(DOCSIS_FLOW_REFERENCE, $value);
  77. }
  78.  
  79. /**
  80. * Set Service Flow Identifier
  81. *
  82. * See Radio Frequency Interface Specification C.2.2.3.2
  83. *
  84. * The configuration file MUST NOT contain this parameter.
  85. *
  86. * @param int $value
  87. */
  88. function set_identifier($value)
  89. {
  90. if($value < 1 || $value > 4294967295) trigger_error('Identifier must be 1 to 4294967295', E_USER_WARNING);
  91. $this->value[DOCSIS_FLOW_IDENTIFIER] = new docsis_encoder_uint(DOCSIS_FLOW_IDENTIFIER, $value);
  92. }
  93.  
  94. /**
  95. * Set Service Class Name
  96. *
  97. * See Radio Frequency Interface Specification C.2.2.3.4
  98. *
  99. * @param string $value
  100. */
  101. function set_class_name($value)
  102. {
  103. if(strpos($value, chr(0)) !== false)
  104. trigger_error('Name cannot include the NULL character', E_USER_WARNING);
  105. $this->value[DOCSIS_FLOW_CLASS_NAME] = new docsis_encoder_string(DOCSIS_FLOW_CLASS_NAME, $value . chr(0));
  106. }
  107.  
  108. /**
  109. * Set Quality of Service Parameter Set Type
  110. *
  111. * See Radio Frequency Interface Specification C.2.2.3.5
  112. *
  113. * @param boolena $provisionioned
  114. * @param boolena $admitted
  115. * @param boolena $active
  116. */
  117. function set_qos($provisioned, $admitted, $active)
  118. {
  119. if($provisioned < 0 || $provisioned > 1) trigger_error('Provisioned must be 0 or 1', E_USER_WARNING);
  120. if($admitted < 0 || $admitted > 1) trigger_error('Admitted must be 0 or 1', E_USER_WARNING);
  121. if($active < 0 || $active > 1) trigger_error('Active must be 0 or 1', E_USER_WARNING);
  122. $this->value[DOCSIS_FLOW_QOS] = new docsis_encoder_uchar(DOCSIS_FLOW_QOS, $provisioned + 2 * $admitted + 4 * $active);
  123. }
  124.  
  125. /**
  126. * Set Error
  127. *
  128. * See Radio Frequency Interface Specification C.2.2.4
  129. *
  130. * @param docsis_error $value
  131. */
  132. function set_error($value)
  133. {
  134. // todo: must be a docsis_error
  135. $this->value[DOCSIS_FLOW_ERROR] = $value;
  136. }
  137.  
  138. /**
  139. * Set Traffic Priority
  140. *
  141. * See Radio Frequency Interface Specification C.2.2.5.1
  142. *
  143. * @param int $value
  144. */
  145. function set_traffic_priority($value)
  146. {
  147. if($value < 0 || $value > 7) trigger_error('Identifier must be 0 to 7', E_USER_WARNING);
  148. $this->value[DOCSIS_FLOW_TRAFFIC_PRIORITY] = new docsis_encoder_uchar(DOCSIS_FLOW_TRAFFIC_PRIORITY, $value);
  149. }
  150.  
  151. /**
  152. * Set Maximum Sustained Traffic Rate
  153. *
  154. * See Radio Frequency Interface Specification C.2.2.5.2
  155. *
  156. * @param int $value
  157. */
  158. function set_max_rate($value)
  159. {
  160. $this->value[DOCSIS_FLOW_MAX_RATE] = new docsis_encoder_uint(DOCSIS_FLOW_MAX_RATE, $value);
  161. }
  162.  
  163. /**
  164. * Set Maximum Traffic Burst
  165. *
  166. * See Radio Frequency Interface Specification C.2.2.5.3
  167. *
  168. * @param int $value
  169. */
  170. function set_max_burst($value)
  171. {
  172. if($value < 1521) trigger_error('Burst must be greater than 1520', E_USER_WARNING);
  173. $this->value[DOCSIS_FLOW_MAX_BURST] = new docsis_encoder_uint(DOCSIS_FLOW_MAX_BURST, $value);
  174. }
  175.  
  176. /**
  177. * Set Minimum Reserved Traffic Rate
  178. *
  179. * See Radio Frequency Interface Specification C.2.2.5.4
  180. *
  181. * @param int $value
  182. */
  183. function set_min_reserved_rate($value)
  184. {
  185. $this->value[DOCSIS_FLOW_MIN_RESERVED_RATE] = new docsis_encoder_uint(DOCSIS_FLOW_MIN_RESERVED_RATE, $value);
  186. }
  187.  
  188. /**
  189. * Set Assumed Minimum Reserved Rate Packet Size
  190. *
  191. * See Radio Frequency Interface Specification C.2.2.5.5
  192. *
  193. * @param int $value
  194. */
  195. function set_min_reserved_packet_size($value)
  196. {
  197. $this->value[DOCSIS_FLOW_MIN_RESERVED_PACKET_SIZE] = new docsis_encoder_ushort(DOCSIS_FLOW_MIN_RESERVED_PACKET_SIZE, $value);
  198. }
  199.  
  200. /**
  201. * Set Timeout for Active QoS Parameters
  202. *
  203. * See Radio Frequency Interface Specification C.2.2.5.6
  204. *
  205. * @param int $value
  206. */
  207. function set_active_qos_timeout($value)
  208. {
  209. $this->value[DOCSIS_FLOW_ACTIVE_QOS_TIMEOUT] = new docsis_encoder_ushort(DOCSIS_FLOW_ACTIVE_QOS_TIMEOUT, $value);
  210. }
  211.  
  212. /**
  213. * Set Timeout for Admitted QoS Parameters
  214. *
  215. * See Radio Frequency Interface Specification C.2.2.5.7
  216. *
  217. * @param int $value
  218. */
  219. function set_admitted_qos_timeout($value)
  220. {
  221. $this->value[DOCSIS_FLOW_ADMITTED_QOS_TIMEOUT] = new docsis_encoder_ushort(DOCSIS_FLOW_ADMITTED_QOS_TIMEOUT, $value);
  222. }
  223.  
  224. /**
  225. * Set Vendor Specific QoS Parameters
  226. *
  227. * See Radio Frequency Interface Specification C.2.2.5.8
  228. *
  229. * @param int $value
  230. */
  231. function set_vendor($value)
  232. {
  233. // todo: must exist be a docsis_vendor
  234. $this->value[DOCSIS_VENDOR] = $value;
  235. }
  236. }
  237.  
  238. /**
  239. * DOCSIS Service Flow Up
  240. *
  241. * @package docsis_config
  242. * @subpackage docsis_flow
  243. */
  244. class docsis_flow_up extends docsis_flow
  245. {
  246. /**
  247. * Constructor
  248. *
  249. * @param int $code docsis code
  250. * @param array $value predefined values
  251. */
  252. function docsis_flow_up($code=DOCSIS_FLOW_UP, $value=array())
  253. {
  254. parent::docsis_flow($code, $value);
  255. }
  256.  
  257. /**
  258. * Set
  259. *
  260. * See Radio Frequency Interface Specification C.2.2.3.3
  261. *
  262. * @param int $value
  263. */
  264. function set_identifier_2($value)
  265. {
  266. if($value < 1 || $value > 16383) trigger_error('Identifier2 must be 1 to 16383', E_USER_WARNING);
  267. $this->value[DOCSIS_FLOW_IDENTIFIER_2] = new docsis_encoder_ushort(DOCSIS_FLOW_IDENTIFIER_2, $value);
  268. }
  269.  
  270. /**
  271. * Set Maximum Traffic Burst
  272. *
  273. * See Radio Frequency Interface Specification C.2.2.6.1
  274. *
  275. * @param int $value
  276. */
  277. function set_max_concat_burst($value)
  278. {
  279. $this->value[DOCSIS_FLOW_MAX_CONCAT_BURST] = new docsis_encoder_ushort(DOCSIS_FLOW_MAX_CONCAT_BURST, $value);
  280. }
  281.  
  282. /**
  283. * Set Service Flow Scheduling Type
  284. *
  285. * See Radio Frequency Interface Specification C.2.2.6.2
  286. *
  287. * Types:
  288. * <ul>
  289. * <li>0 Reserved</li>
  290. * <li>1 Undefined (CMTS implementation-dependent)</li>
  291. * <li>2 Best Effort</li>
  292. * <li>3 Non-Real-Time Polling Service</li>
  293. * <li>4 Real-Time Polling Service</li>
  294. * <li>5 Unsolicited Grant Service with Activity Detection</li>
  295. * <li>6 Unsolicited Grant Service</li>
  296. * <li>7-255 Reserved for future use</li>
  297. * </ul>
  298. *
  299. * @param int $type
  300. */
  301. function set_sched_type($type)
  302. {
  303. if($type < 1 || $type > 6) trigger_error('Scheduling Type must be 1 to 6', E_USER_WARNING);
  304. $this->value[DOCSIS_FLOW_SCHED_TYPE] = new docsis_encoder_uchar(DOCSIS_FLOW_SCHED_TYPE, $type);
  305. }
  306.  
  307. /**
  308. * Set
  309. *
  310. * See Radio Frequency Interface Specification C.2.2.6.3
  311. *
  312. * <ul>
  313. * <li>bit 0# The Service Flow MUST NOT use "all CMs" broadcast request opportunities.</li>
  314. * <li>bit 1# The Service Flow MUST NOT use Priority Request multicast request opportunities.</li>
  315. * <li>bit 2# The Service Flow MUST NOT use Request/Data opportunities for Requests.</li>
  316. * <li>bit 3# The Service Flow MUST NOT use Request/Data opportunities for Data.</li>
  317. * <li>bit 4# The Service Flow MUST NOT piggyback requests with data.</li>
  318. * <li>bit 5# The Service Flow MUST NOT concatenate data.</li>
  319. * <li>bit 6# The Service Flow MUST NOT fragment data.</li>
  320. * <li>bit 7# The Service Flow MUST NOT suppress payload headers.</li>
  321. * <li>bit 8# The Service Flow MUST NOT drop packets that do not fit in the Unsolicited Grant Size.</li>
  322. * </ul>
  323. *
  324. * @param int $value
  325. */
  326. function set_request_policy($value)
  327. {
  328. if($value < 0 || $value > 511) trigger_error('Request Policy must be 0 to 511', E_USER_WARNING);
  329. $this->value[DOCSIS_FLOW_REQUEST_POLICY] = new docsis_encoder_uint(DOCSIS_FLOW_REQUEST_POLICY, $value);
  330. }
  331.  
  332. /**
  333. * Set Nominal Polling Interval
  334. *
  335. * See Radio Frequency Interface Specification C.2.2.6.4
  336. *
  337. * @param int $value microseconds
  338. */
  339. function set_polling_interval($value)
  340. {
  341. $this->value[DOCSIS_FLOW_POLLING_INTERVAL] = new docsis_encoder_uint(DOCSIS_FLOW_POLLING_INTERVAL, $value);
  342. }
  343.  
  344. /**
  345. * Set Tolerated Poll Jitter
  346. *
  347. * See Radio Frequency Interface Specification C.2.2.6.5
  348. *
  349. * @param int $value microseconds
  350. */
  351. function set_poll_jitter($value)
  352. {
  353. $this->value[DOCSIS_FLOW_POLL_JITTER] = new docsis_encoder_uint(DOCSIS_FLOW_POLL_JITTER, $value);
  354. }
  355.  
  356. /**
  357. * Set Unsolicited Grant Size
  358. *
  359. * See Radio Frequency Interface Specification C.2.2.6.6
  360. *
  361. * @param int $value
  362. */
  363. function set_unsolicited_grant_size($value)
  364. {
  365. $this->value[DOCSIS_FLOW_UNSOLICITED_GRANT_SIZE] = new docsis_encoder_ushort(DOCSIS_FLOW_UNSOLICITED_GRANT_SIZE, $value);
  366. }
  367.  
  368. /**
  369. * Set Nominal Grant Size
  370. *
  371. * See Radio Frequency Interface Specification C.2.2.6.7
  372. *
  373. * @param int $value
  374. */
  375. function set_nominal_grant_size($value)
  376. {
  377. $this->value[DOCSIS_FLOW_NOMINAL_GRANT_SIZE] = new docsis_encoder_uint(DOCSIS_FLOW_NOMINAL_GRANT_SIZE, $value);
  378. }
  379.  
  380. /**
  381. * Set Tolerated Grant Jitter
  382. *
  383. * See Radio Frequency Interface Specification C.2.2.6.8
  384. *
  385. * @param int $value microseconds
  386. */
  387. function set_grant_jitter($value)
  388. {
  389. $this->value[DOCSIS_FLOW_GRANT_JITTER] = new docsis_encoder_uint(DOCSIS_FLOW_GRANT_JITTER, $value);
  390. }
  391.  
  392. /**
  393. * Set Grants per Interval
  394. *
  395. * See Radio Frequency Interface Specification C.2.2.6.9
  396. *
  397. * @param int $value
  398. */
  399. function set_grants_per_interval($value)
  400. {
  401. if($value < 0 || $value > 127) trigger_error('Grants per Interval must be 0 to 127', E_USER_WARNING);
  402. $this->value[DOCSIS_FLOW_GRANTS_PER_INTERVAL] = new docsis_encoder_uchar(DOCSIS_FLOW_GRANTS_PER_INTERVAL, $value);
  403. }
  404.  
  405. /**
  406. * Set IP Type of Service Overwrite
  407. *
  408. * See Radio Frequency Interface Specification C.2.2.6.10
  409. *
  410. * @param int $and tos and-mask
  411. * @param int $or tos or-mask
  412. */
  413. function set_tos_mask($and, $or)
  414. {
  415. $this->value[DOCSIS_FLOW_TOS_MASK] = new docsis_encoder_string(DOCSIS_FLOW_TOS_MASK, chr($and) . chr($or));
  416. }
  417.  
  418. /**
  419. * Set Unsolicited Grant Time Reference
  420. *
  421. * See Radio Frequency Interface Specification C.2.2.6.11
  422. *
  423. * @param int $value timestamp
  424. */
  425. function set_unsolicited_grant_time($value)
  426. {
  427. $this->value[DOCSIS_FLOW_UNSOLICITED_GRANT_TIME] = new docsis_encoder_uint(DOCSIS_FLOW_UNSOLICITED_GRANT_TIME, $value);
  428. }
  429. }
  430.  
  431. /**
  432. * DOCSIS Service Flow Down
  433. *
  434. * @package docsis_config
  435. * @subpackage docsis_flow
  436. */
  437. class docsis_flow_down extends docsis_flow
  438. {
  439. /**
  440. * Constructor
  441. *
  442. * @param int $code docsis code
  443. * @param array $value predefined values
  444. */
  445. function docsis_flow_down($code=DOCSIS_FLOW_DOWN, $value=array())
  446. {
  447. parent::docsis_flow($code, $value);
  448. }
  449.  
  450. /**
  451. * Set Maximum Downstream Latency
  452. *
  453. * See Radio Frequency Interface Specification C.2.2.7.1
  454. *
  455. * @param int $value microseconds
  456. */
  457. function set_max_down_latency($value)
  458. {
  459. $this->value[DOCSIS_FLOW_MAX_DOWN_LATENCY] = new docsis_encoder_uint(DOCSIS_FLOW_MAX_DOWN_LATENCY, $value);
  460. }
  461. }
  462. ?>

Documentation generated on Mon, 14 Nov 2005 18:00:23 -0700 by phpDocumentor 1.3.0RC3