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

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