add experimental portforwarding stuff
[GitHub/Stricted/speedport-hybrid-php-api.git] / lib / trait / Firewall.class.php
1 <?php
2 /**
3 * @author Jan Altensen (Stricted)
4 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
5 * @copyright 2015 Jan Altensen (Stricted)
6 */
7 trait Firewall {
8 /**
9 * get all Portforwarding Entrys
10 *
11 * @return array
12 */
13 public function getPortforwardingEntrys () {
14 $data = $this->getData('Portforwarding');
15 $data = $this->getValues($data);
16
17 //print_r($data);
18
19 if (isset($data['addportuw'])) {
20 return $data['addportuw'];
21 }
22 else {
23 return array();
24 }
25 }
26
27 /**
28 * delete Portforwarding Entry
29 *
30 * @param integer $id
31 *
32 * @return array
33 */
34 public function deletePortforwardingEntry ($id) {
35 $this->checkLogin();
36
37 $path = 'data/Portforwarding.json';
38 $fields = array('csrf_token' => $this->token,
39 'id_portforward' => $id,
40 'deleteEntry' => 'delete'
41 );
42
43 $data = $this->sentRequest($path, $fields, true);
44 $data = $this->getValues($data['body']);
45
46 if ($data['status'] == 'ok') {
47 return $data;
48 }
49 else {
50 throw new RouterException('can not delete Phone Book Entry');
51 }
52 }
53
54 /**
55 * add Portforwarding Entry
56 *
57 * @param string $name
58 * @param integer $device
59 */
60 public function addPortforwardingEntry ($name, $device) {
61 // TODO: find a way to make this possible
62 /* fields:
63 *
64 * portuw_name
65 * portuw_device
66 * optvar_portuw_template = -1
67 * tcp_public_from
68 * tcp_public_to
69 * tcp_private_dest
70 * tcp_private_to
71 * portuwtcp_id = -1
72 *
73 * udp_public_from
74 * udp_public_to
75 * udp_private_dest
76 * udp_private_to
77 * portuwudp_id = -1
78 */
79 }
80
81 /**
82 * edit Portforwarding Entry
83 *
84 * @param integer $id
85 * @param string $name
86 * @param integer $device
87 */
88 public function editPortforwardingEntry ($id, $name, $device) {
89 // TODO: find a way to make this possible
90 }
91 }