├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CHANGELOG.md ├── CactiCheatSheet.md ├── INFO ├── LICENSE ├── Net ├── DNS2.php ├── DNS2 │ ├── BitMap.php │ ├── Cache.php │ ├── Cache │ │ ├── File.php │ │ └── Shm.php │ ├── Exception.php │ ├── Header.php │ ├── Lookups.php │ ├── Notifier.php │ ├── Packet.php │ ├── Packet │ │ ├── Request.php │ │ └── Response.php │ ├── PrivateKey.php │ ├── Question.php │ ├── RR.php │ ├── RR │ │ ├── A.php │ │ ├── AAAA.php │ │ ├── AFSDB.php │ │ ├── AMTRELAY.php │ │ ├── ANY.php │ │ ├── APL.php │ │ ├── ATMA.php │ │ ├── AVC.php │ │ ├── CAA.php │ │ ├── CDNSKEY.php │ │ ├── CDS.php │ │ ├── CERT.php │ │ ├── CNAME.php │ │ ├── CSYNC.php │ │ ├── DHCID.php │ │ ├── DLV.php │ │ ├── DNAME.php │ │ ├── DNSKEY.php │ │ ├── DS.php │ │ ├── EID.php │ │ ├── EUI48.php │ │ ├── EUI64.php │ │ ├── HINFO.php │ │ ├── HIP.php │ │ ├── IPSECKEY.php │ │ ├── ISDN.php │ │ ├── KEY.php │ │ ├── KX.php │ │ ├── L32.php │ │ ├── L64.php │ │ ├── LOC.php │ │ ├── LP.php │ │ ├── MX.php │ │ ├── NAPTR.php │ │ ├── NID.php │ │ ├── NIMLOC.php │ │ ├── NS.php │ │ ├── NSAP.php │ │ ├── NSEC.php │ │ ├── NSEC3.php │ │ ├── NSEC3PARAM.php │ │ ├── OPENPGPKEY.php │ │ ├── OPT.php │ │ ├── PTR.php │ │ ├── PX.php │ │ ├── RP.php │ │ ├── RRSIG.php │ │ ├── RT.php │ │ ├── SIG.php │ │ ├── SMIMEA.php │ │ ├── SOA.php │ │ ├── SPF.php │ │ ├── SRV.php │ │ ├── SSHFP.php │ │ ├── TA.php │ │ ├── TALINK.php │ │ ├── TKEY.php │ │ ├── TLSA.php │ │ ├── TSIG.php │ │ ├── TXT.php │ │ ├── TYPE65534.php │ │ ├── URI.php │ │ ├── WKS.php │ │ └── X25.php │ ├── Resolver.php │ ├── Socket.php │ ├── Socket │ │ ├── Sockets.php │ │ └── Streams.php │ └── Updater.php ├── LICENSE └── README.md ├── README.md ├── docs ├── CHANGELOG ├── cacti_device_type_xport.csv └── images │ ├── mactrack_wiki_dt-1.png │ ├── mactrack_wiki_dt-2.png │ ├── mactrack_wiki_dt-3.png │ ├── mactrack_wiki_sites-1.png │ ├── mt_devices-1.png │ ├── mt_dts_csv.png │ ├── mt_dts_export.png │ ├── mt_dts_import.png │ ├── mt_dts_import_results.png │ ├── mt_import_device-1.png │ ├── mt_import_device-2.png │ ├── mt_import_device-3.png │ ├── mt_import_device-4.png │ ├── mt_import_oui.png │ ├── mt_view_devices.png │ ├── mt_view_dot1x.png │ ├── mt_view_interfaces.png │ ├── mt_view_ipaddr_1.png │ ├── mt_view_iprange.png │ ├── mt_view_ips.png │ ├── mt_view_macs.png │ └── mt_view_sites.png ├── images ├── create_device.gif ├── disable_collection.png ├── edit_object.png ├── enable_collection.png ├── graph_page_top.gif ├── index.php ├── lock_device.gif ├── purge_device.png ├── rescan_device.gif ├── rescan_site.gif ├── tab_mactrack.png ├── tab_mactrack_down.png ├── unlock_device.gif ├── view_busy.gif ├── view_details.gif ├── view_devices.gif ├── view_graphs.gif ├── view_graphs_disabled.gif ├── view_hosts.gif ├── view_interface_graphs.gif ├── view_interfaces.gif ├── view_ipaddresses.gif ├── view_macs.gif ├── view_networks.gif └── view_none.gif ├── includes └── database.php ├── index.php ├── lib ├── index.php ├── mactrack_3com.php ├── mactrack_aruba_oscx.php ├── mactrack_cabletron.php ├── mactrack_cisco.php ├── mactrack_dell.php ├── mactrack_dlink.php ├── mactrack_enterasys.php ├── mactrack_enterasys_N7.php ├── mactrack_extreme.php ├── mactrack_foundry.php ├── mactrack_functions.php ├── mactrack_h3c_3com.php ├── mactrack_hp.php ├── mactrack_hp_ng.php ├── mactrack_hp_ngi.php ├── mactrack_juniper.php ├── mactrack_linux.php ├── mactrack_norbay.php ├── mactrack_norbay_ng.php ├── mactrack_tplink.php ├── mactrack_trendnet.php └── mactrack_vendors.php ├── locales ├── LC_MESSAGES │ ├── ar-SA.mo │ ├── bg-BG.mo │ ├── de-DE.mo │ ├── el-GR.mo │ ├── es-ES.mo │ ├── fr-FR.mo │ ├── he-IL.mo │ ├── hi-IN.mo │ ├── index.php │ ├── it-IT.mo │ ├── ja-JP.mo │ ├── ko-KR.mo │ ├── nl-NL.mo │ ├── pl-PL.mo │ ├── pt-BR.mo │ ├── pt-PT.mo │ ├── ru-RU.mo │ ├── sv-SE.mo │ ├── tr-TR.mo │ ├── vi-VN.mo │ ├── zh-CN.mo │ └── zh-TW.mo ├── build_gettext.sh ├── index.php └── po │ ├── ar-SA.po │ ├── bg-BG.po │ ├── cacti.pot │ ├── de-DE.po │ ├── el-GR.po │ ├── es-ES.po │ ├── fr-FR.po │ ├── he-IL.po │ ├── hi-IN.po │ ├── index.php │ ├── it-IT.po │ ├── ja-JP.po │ ├── ko-KR.po │ ├── nl-NL.po │ ├── pl-PL.po │ ├── pt-BR.po │ ├── pt-PT.po │ ├── ru-RU.po │ ├── sv-SE.po │ ├── tr-TR.po │ ├── vi-VN.po │ ├── zh-CN.po │ └── zh-TW.po ├── mactrack.css ├── mactrack.js ├── mactrack.sql ├── mactrack_actions.php ├── mactrack_ajax.php ├── mactrack_ajax_admin.php ├── mactrack_convert.php ├── mactrack_device_types.php ├── mactrack_devices.php ├── mactrack_import_ouidb.php ├── mactrack_macauth.php ├── mactrack_macwatch.php ├── mactrack_resolver.php ├── mactrack_scanner.php ├── mactrack_sites.php ├── mactrack_snmp.js ├── mactrack_snmp.php ├── mactrack_utilities.php ├── mactrack_vendormacs.php ├── mactrack_view_arp.php ├── mactrack_view_devices.php ├── mactrack_view_dot1x.php ├── mactrack_view_graphs.php ├── mactrack_view_interfaces.php ├── mactrack_view_ips.php ├── mactrack_view_macs.php ├── mactrack_view_sites.php ├── poller_mactrack.php ├── setup.php └── themes ├── classic └── mactrack.css ├── dark └── mactrack.css ├── modern └── mactrack.css ├── paper-plane └── mactrack.css ├── paw └── mactrack.css └── sunrise └── mactrack.css /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 14 | 15 | **Describe the bug** 16 | A clear and concise description of what the bug is. 17 | 18 | **To Reproduce** 19 | Steps to reproduce the behavior: 20 | 1. Go to '...' 21 | 2. Click on '....' 22 | 3. Scroll down to '....' 23 | 4. See error 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Plugin (please complete the following information):** 32 | - Version: [e.g. 1.2] 33 | - Source: [e.g. cacti.net, package, github] 34 | - Identifer: [e.g. apt/yum package name or github commit ref] 35 | 36 | **Desktop (please complete the following information):** 37 | - OS: [e.g. iOS] 38 | - Browser [e.g. chrome, safari] 39 | - Version [e.g. 22] 40 | 41 | **Smartphone (please complete the following information):** 42 | - Device: [e.g. iPhone6] 43 | - OS: [e.g. iOS8.1] 44 | - Browser [e.g. stock browser, safari] 45 | - Version [e.g. 22] 46 | 47 | **Additional context** 48 | Add any other context about the problem here. 49 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 14 | 15 | **Is your feature request related to a problem? Please describe.** 16 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 17 | 18 | **Describe the solution you'd like** 19 | A clear and concise description of what you want to happen. 20 | 21 | **Describe alternatives you've considered** 22 | A clear and concise description of any alternative solutions or features you've considered. 23 | 24 | **Additional context** 25 | Add any other context or screenshots about the feature request here. 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # +-------------------------------------------------------------------------+ 2 | # | Copyright (C) 2004-2023 The Cacti Group | 3 | # | | 4 | # | This program is free software; you can redistribute it and/or | 5 | # | modify it under the terms of the GNU General Public License | 6 | # | as published by the Free Software Foundation; either version 2 | 7 | # | of the License, or (at your option) any later version. | 8 | # | | 9 | # | This program is distributed in the hope that it will be useful, | 10 | # | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | # | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | # | GNU General Public License for more details. | 13 | # +-------------------------------------------------------------------------+ 14 | # | Cacti: The Complete RRDtool-based Graphing Solution | 15 | # +-------------------------------------------------------------------------+ 16 | # | This code is designed, written, and maintained by the Cacti Group. See | 17 | # | about.php and/or the AUTHORS file for specific developer information. | 18 | # +-------------------------------------------------------------------------+ 19 | # | http://www.cacti.net/ | 20 | # +-------------------------------------------------------------------------+ 21 | 22 | locales/po/*.mo 23 | -------------------------------------------------------------------------------- /CactiCheatSheet.md: -------------------------------------------------------------------------------- 1 | # Cacti documentation 2 | 3 | [TOC] 4 | 5 | ## Changes made in Mactrack plugin 6 | 7 | ### Fixing bug: mac addresses were not visible under MAC Addresses tab 8 | 9 | https://github.com/Cacti/plugin_mactrack/commit/cc681b143cfdd43ec79a800009699308d5832407 10 | 11 | The bug occurred when using Juniper EX2200 Switches. 12 | 13 | ```php 14 | $Xvlanid = substr($num, 0, strpos($num, '.')); 15 | ``` 16 | 17 | was changed to 18 | 19 | ```php 20 | $Xvlanid = substr($num, strpos($num, '.')+1, strpos($num, '.',1)-1); 21 | ``` 22 | 23 | and 24 | 25 | ```php 26 | $ifIndex = @$port_results[$mac_result]; 27 | ``` 28 | 29 | was changed to 30 | 31 | ```php 32 | $ifIndex = @$port_results[".".strval($mac_result)]; 33 | ``` 34 | 35 | in the `lib\mactrack_juniper.php` file. 36 | 37 | An extra dot was added to the keys of the port dictionary when it was made from 38 | the OID. 39 | 40 | ### More bug fixing with Juniper switches 41 | 42 | https://github.com/Cacti/plugin_mactrack/commit/f2deee43c1229e5bd3110e19e685153b57bfc76c 43 | 44 | Changes are available on the link above. 45 | 46 | #### Fixing bug: The MAC addresses had 7 groups instead of 6. They were too 47 | #### long. 48 | 49 | Basically the start position of the substring was wrong. 50 | 51 | #### Fixing Juniper trunk port counter 52 | 53 | When using Juniper switches the trunk counter was not implemented. 54 | 55 | ```php 56 | /* get VLAN Trunk status */ 57 | $vlan_trunkstatus = xform_standard_indexed_data('.1.3.6.1.4.1.2636.3.40.1.5.1.7.1.5', $device); 58 | foreach ($vlan_trunkstatus as $vts) { 59 | if ($vts == 2) { 60 | $device['ports_trunk']++; 61 | } 62 | } 63 | ``` 64 | 65 | was added to the code. 66 | 67 | #### Fixing: port names issue 68 | 69 | Changed Juniper port names, port numbers and port descriptions according to 70 | Cisco's equivalent of the same fields in the DB. Port number became Interface 71 | name (e.g. ge-0/0/0.0). Port name became Interface description. Port description 72 | was added to $ifInterfaces. Tested with EX-2200 switches. 73 | 74 | #### Interface description are now visible under the interfaces tab and 75 | #### port_name cannot be null. 76 | 77 | https://github.com/Cacti/plugin_mactrack/commit/bc5ba709134006488a80b4cf3beae782fd9fbd84 78 | 79 | ### Juniper port ignore 80 | 81 | https://github.com/Cacti/plugin_mactrack/commits/develop (it was not accepted by the official Cacti repository when the documentation was made.) 82 | 83 | Port ignore option was not implemented for Juniper switches. 84 | 85 | ## Mactrack cheat sheet 86 | 87 | ### mactrack scanner 88 | 89 | Main debugging tool: 90 | 91 | -d stands for debug mode. 92 | 93 | -id=deviceid selects the device on which the scan will run 94 | 95 | The result of the scan will be saved to the **mac_track_temp_ports** table in 96 | mysql. It won't be merged into the **mac_track_ports** table which is used by 97 | Cacti to build the view macs webpage. 98 | 99 | ```bash 100 | php mactrack_scanner.php -d -id=10 101 | ``` 102 | 103 | ### mactrack poller 104 | 105 | It runs the SNMP poller on all devices 106 | 107 | ```bash 108 | php poller_mactrack.php -d -f 109 | ``` 110 | 111 | -d stands for debug mode 112 | 113 | -f means force (~ run now, don't wait for the next scheduled scan.) 114 | 115 | ### Terminated mactrack process 116 | 117 | If the poller or the scanner was terminated you should clear the 118 | **mac_track_processes** table by hand. 119 | 120 | ### Clear mac addresses 121 | 122 | To clear the mac addresses from Cacti you should **TRUNCATE** the 123 | **mac_track_ports** table. 124 | 125 | ### Duplicate device bug 126 | 127 | When editing a device from Cacti you should check **mac_track_devices** table. 128 | Sometimes it makes a duplicate entry. Simply delete the old one. 129 | 130 | ----------------------------------------------- 131 | Copyright (c) 2004-2024 - The Cacti Group, Inc. 132 | -------------------------------------------------------------------------------- /INFO: -------------------------------------------------------------------------------- 1 | ; +-------------------------------------------------------------------------+ 2 | ; | Copyright (C) 2004-2023 The Cacti Group | 3 | ; | | 4 | ; | This program is free software; you can redistribute it and/or | 5 | ; | modify it under the terms of the GNU General Public License | 6 | ; | as published by the Free Software Foundation; either version 2 | 7 | ; | of the License, or (at your option) any later version. | 8 | ; | | 9 | ; | This program is distributed in the hope that it will be useful, | 10 | ; | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | ; | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | ; | GNU General Public License for more details. | 13 | ; +-------------------------------------------------------------------------+ 14 | ; | Cacti: The Complete RRDtool-based Graphing Solution | 15 | ; +-------------------------------------------------------------------------+ 16 | ; | This code is designed, written, and maintained by the Cacti Group. See | 17 | ; | about.php and/or the AUTHORS file for specific developer information. | 18 | ; +-------------------------------------------------------------------------+ 19 | ; | http://www.cacti.net/ | 20 | ; +-------------------------------------------------------------------------+ 21 | 22 | [info] 23 | name = mactrack 24 | version = 4.9 25 | longname = Device Tracking 26 | author = The Cacti Group 27 | email = 28 | homepage = http://www.cacti.net 29 | compat = 1.2.14 30 | capabilities = online_view:1, online_mgmt:0, offline_view:0, offline_mgmt:0, remote_collect:0 31 | -------------------------------------------------------------------------------- /Net/DNS2/Exception.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * Exception handler used by Net_DNS2 22 | * 23 | */ 24 | class Net_DNS2_Exception extends Exception 25 | { 26 | private $_request; 27 | private $_response; 28 | 29 | /** 30 | * Constructor - overload the constructor so we can pass in the request 31 | * and response object (when it's available) 32 | * 33 | * @param string $message the exception message 34 | * @param int $code the exception code 35 | * @param object $previous the previous Exception object 36 | * @param object $request the Net_DNS2_Packet_Request object for this request 37 | * @param object $response the Net_DNS2_Packet_Response object for this request 38 | * 39 | * @access public 40 | * 41 | */ 42 | public function __construct( 43 | $message = '', 44 | $code = 0, 45 | $previous = null, 46 | Net_DNS2_Packet_Request $request = null, 47 | Net_DNS2_Packet_Response $response = null 48 | ) { 49 | // 50 | // store the request/response objects (if passed) 51 | // 52 | $this->_request = $request; 53 | $this->_response = $response; 54 | 55 | // 56 | // call the parent constructor 57 | // 58 | // the "previous" argument was added in PHP 5.3.0 59 | // 60 | // https://code.google.com/p/netdns2/issues/detail?id=25 61 | // 62 | if (version_compare(PHP_VERSION, '5.3.0', '>=') == true) { 63 | 64 | parent::__construct($message, $code, $previous); 65 | } else { 66 | 67 | parent::__construct($message, $code); 68 | } 69 | } 70 | 71 | /** 72 | * returns the Net_DNS2_Packet_Request object (if available) 73 | * 74 | * @return Net_DNS2_Packet_Request object 75 | * @access public 76 | * @since function available since release 1.3.1 77 | * 78 | */ 79 | public function getRequest() 80 | { 81 | return $this->_request; 82 | } 83 | 84 | /** 85 | * returns the Net_DNS2_Packet_Response object (if available) 86 | * 87 | * @return Net_DNS2_Packet_Response object 88 | * @access public 89 | * @since function available since release 1.3.1 90 | * 91 | */ 92 | public function getResponse() 93 | { 94 | return $this->_response; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Net/DNS2/Packet/Response.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * This class handles building new DNS response packets; it parses binary packed 22 | * packets that come off the wire 23 | * 24 | */ 25 | class Net_DNS2_Packet_Response extends Net_DNS2_Packet 26 | { 27 | /* 28 | * The name servers that this response came from 29 | */ 30 | public $answer_from; 31 | 32 | /* 33 | * The socket type the answer came from (TCP/UDP) 34 | */ 35 | public $answer_socket_type; 36 | 37 | /* 38 | * The query response time in microseconds 39 | */ 40 | public $response_time = 0; 41 | 42 | /** 43 | * Constructor - builds a new Net_DNS2_Packet_Response object 44 | * 45 | * @param string $data binary DNS packet 46 | * @param integer $size the length of the DNS packet 47 | * 48 | * @throws Net_DNS2_Exception 49 | * @access public 50 | * 51 | */ 52 | public function __construct($data, $size) 53 | { 54 | $this->set($data, $size); 55 | } 56 | 57 | /** 58 | * builds a new Net_DNS2_Packet_Response object 59 | * 60 | * @param string $data binary DNS packet 61 | * @param integer $size the length of the DNS packet 62 | * 63 | * @return boolean 64 | * @throws Net_DNS2_Exception 65 | * @access public 66 | * 67 | */ 68 | public function set($data, $size) 69 | { 70 | // 71 | // store the full packet 72 | // 73 | $this->rdata = $data; 74 | $this->rdlength = $size; 75 | 76 | // 77 | // parse the header 78 | // 79 | // we don't bother checking the size earlier, because the first thing the 80 | // header class does, is check the size and throw and exception if it's 81 | // invalid. 82 | // 83 | $this->header = new Net_DNS2_Header($this); 84 | 85 | // 86 | // if the truncation bit is set, then just return right here, because the 87 | // rest of the packet is probably empty; and there's no point in processing 88 | // anything else. 89 | // 90 | // we also don't need to worry about checking to see if the the header is 91 | // null or not, since the Net_DNS2_Header() constructor will throw an 92 | // exception if the packet is invalid. 93 | // 94 | if ($this->header->tc == 1) { 95 | 96 | return false; 97 | } 98 | 99 | // 100 | // parse the questions 101 | // 102 | for ($x = 0; $x < $this->header->qdcount; ++$x) { 103 | 104 | $this->question[$x] = new Net_DNS2_Question($this); 105 | } 106 | 107 | // 108 | // parse the answers 109 | // 110 | for ($x = 0; $x < $this->header->ancount; ++$x) { 111 | 112 | $o = Net_DNS2_RR::parse($this); 113 | if (!is_null($o)) { 114 | 115 | $this->answer[] = $o; 116 | } 117 | } 118 | 119 | // 120 | // parse the authority section 121 | // 122 | for ($x = 0; $x < $this->header->nscount; ++$x) { 123 | 124 | $o = Net_DNS2_RR::parse($this); 125 | if (!is_null($o)) { 126 | 127 | $this->authority[] = $o; 128 | } 129 | } 130 | 131 | // 132 | // parse the additional section 133 | // 134 | for ($x = 0; $x < $this->header->arcount; ++$x) { 135 | 136 | $o = Net_DNS2_RR::parse($this); 137 | if (!is_null($o)) { 138 | 139 | $this->additional[] = $o; 140 | } 141 | } 142 | 143 | return true; 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Net/DNS2/RR/A.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * A Resource Record - RFC1035 section 3.4.1 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | ADDRESS | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * 27 | */ 28 | class Net_DNS2_RR_A extends Net_DNS2_RR 29 | { 30 | /* 31 | * The IPv4 address in quad-dotted notation 32 | */ 33 | public $address; 34 | 35 | /** 36 | * method to return the rdata portion of the packet as a string 37 | * 38 | * @return string 39 | * @access protected 40 | * 41 | */ 42 | protected function rrToString() 43 | { 44 | return $this->address; 45 | } 46 | 47 | /** 48 | * parses the rdata portion from a standard DNS config line 49 | * 50 | * @param array $rdata a string split line of values for the rdata 51 | * 52 | * @return boolean 53 | * @access protected 54 | * 55 | */ 56 | protected function rrFromString(array $rdata) 57 | { 58 | $value = array_shift($rdata); 59 | 60 | if (Net_DNS2::isIPv4($value) == true) { 61 | 62 | $this->address = $value; 63 | return true; 64 | } 65 | 66 | return false; 67 | } 68 | 69 | /** 70 | * parses the rdata of the Net_DNS2_Packet object 71 | * 72 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 73 | * 74 | * @return boolean 75 | * @access protected 76 | * 77 | */ 78 | protected function rrSet(Net_DNS2_Packet &$packet) 79 | { 80 | if ($this->rdlength > 0) { 81 | 82 | $this->address = inet_ntop($this->rdata); 83 | if ($this->address !== false) { 84 | 85 | return true; 86 | } 87 | } 88 | 89 | return false; 90 | } 91 | 92 | /** 93 | * returns the rdata portion of the DNS packet 94 | * 95 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 96 | * compressed names 97 | * 98 | * @return mixed either returns a binary packed 99 | * string or null on failure 100 | * @access protected 101 | * 102 | */ 103 | protected function rrGet(Net_DNS2_Packet &$packet) 104 | { 105 | $packet->offset += 4; 106 | return inet_pton($this->address); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Net/DNS2/RR/AAAA.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * A Resource Record - RFC1035 section 3.4.1 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | | 25 | * | | 26 | * | | 27 | * | ADDRESS | 28 | * | | 29 | * | (128 bit) | 30 | * | | 31 | * | | 32 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 33 | * 34 | */ 35 | class Net_DNS2_RR_AAAA extends Net_DNS2_RR 36 | { 37 | /* 38 | * the IPv6 address in the preferred hexadecimal values of the eight 39 | * 16-bit pieces 40 | * per RFC1884 41 | * 42 | */ 43 | public $address; 44 | 45 | /** 46 | * method to return the rdata portion of the packet as a string 47 | * 48 | * @return string 49 | * @access protected 50 | * 51 | */ 52 | protected function rrToString() 53 | { 54 | return $this->address; 55 | } 56 | 57 | /** 58 | * parses the rdata portion from a standard DNS config line 59 | * 60 | * @param array $rdata a string split line of values for the rdata 61 | * 62 | * @return boolean 63 | * @access protected 64 | * 65 | */ 66 | protected function rrFromString(array $rdata) 67 | { 68 | // 69 | // expand out compressed formats 70 | // 71 | $value = array_shift($rdata); 72 | if (Net_DNS2::isIPv6($value) == true) { 73 | 74 | $this->address = $value; 75 | return true; 76 | } 77 | 78 | return false; 79 | } 80 | 81 | /** 82 | * parses the rdata of the Net_DNS2_Packet object 83 | * 84 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 85 | * 86 | * @return boolean 87 | * @access protected 88 | * 89 | */ 90 | protected function rrSet(Net_DNS2_Packet &$packet) 91 | { 92 | // 93 | // must be 8 x 16bit chunks, or 16 x 8bit 94 | // 95 | if ($this->rdlength == 16) { 96 | 97 | // 98 | // PHP's inet_ntop returns IPv6 addresses in their compressed form, 99 | // but we want to keep with the preferred standard, so we'll parse 100 | // it manually. 101 | // 102 | $x = unpack('n8', $this->rdata); 103 | if (cacti_sizeof($x) == 8) { 104 | 105 | $this->address = vsprintf('%x:%x:%x:%x:%x:%x:%x:%x', $x); 106 | return true; 107 | } 108 | } 109 | 110 | return false; 111 | } 112 | 113 | /** 114 | * returns the rdata portion of the DNS packet 115 | * 116 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 117 | * compressed names 118 | * 119 | * @return mixed either returns a binary packed 120 | * string or null on failure 121 | * @access protected 122 | * 123 | */ 124 | protected function rrGet(Net_DNS2_Packet &$packet) 125 | { 126 | $packet->offset += 16; 127 | return inet_pton($this->address); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Net/DNS2/RR/AFSDB.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * AFSDB Resource Record - RFC1183 section 1 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | SUBTYPE | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / HOSTNAME / 27 | * / / 28 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 | * 30 | */ 31 | class Net_DNS2_RR_AFSDB extends Net_DNS2_RR 32 | { 33 | /* 34 | * The AFSDB sub type 35 | */ 36 | public $subtype; 37 | 38 | /* 39 | * The AFSDB hostname 40 | */ 41 | public $hostname; 42 | 43 | /** 44 | * method to return the rdata portion of the packet as a string 45 | * 46 | * @return string 47 | * @access protected 48 | * 49 | */ 50 | protected function rrToString() 51 | { 52 | return $this->subtype . ' ' . $this->cleanString($this->hostname) . '.'; 53 | } 54 | 55 | /** 56 | * parses the rdata portion from a standard DNS config line 57 | * 58 | * @param array $rdata a string split line of values for the rdata 59 | * 60 | * @return boolean 61 | * @access protected 62 | * 63 | */ 64 | protected function rrFromString(array $rdata) 65 | { 66 | $this->subtype = array_shift($rdata); 67 | $this->hostname = $this->cleanString(array_shift($rdata)); 68 | 69 | return true; 70 | } 71 | 72 | /** 73 | * parses the rdata of the Net_DNS2_Packet object 74 | * 75 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 76 | * 77 | * @return boolean 78 | * @access protected 79 | * 80 | */ 81 | protected function rrSet(Net_DNS2_Packet &$packet) 82 | { 83 | if ($this->rdlength > 0) { 84 | 85 | // 86 | // unpack the subtype 87 | // 88 | $x = unpack('nsubtype', $this->rdata); 89 | 90 | $this->subtype = $x['subtype']; 91 | $offset = $packet->offset + 2; 92 | 93 | $this->hostname = Net_DNS2_Packet::expand($packet, $offset); 94 | 95 | return true; 96 | } 97 | 98 | return false; 99 | } 100 | 101 | /** 102 | * returns the rdata portion of the DNS packet 103 | * 104 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 105 | * compressed names 106 | * 107 | * @return mixed either returns a binary packed 108 | * string or null on failure 109 | * @access protected 110 | * 111 | */ 112 | protected function rrGet(Net_DNS2_Packet &$packet) 113 | { 114 | if (strlen($this->hostname) > 0) { 115 | 116 | $data = pack('n', $this->subtype); 117 | $packet->offset += 2; 118 | 119 | $data .= $packet->compress($this->hostname, $packet->offset); 120 | 121 | return $data; 122 | } 123 | 124 | return null; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Net/DNS2/RR/ANY.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * This is only used for generating an empty ANY RR. 22 | * 23 | */ 24 | class Net_DNS2_RR_ANY extends Net_DNS2_RR 25 | { 26 | /** 27 | * method to return the rdata portion of the packet as a string 28 | * 29 | * @return string 30 | * @access protected 31 | * 32 | */ 33 | protected function rrToString() 34 | { 35 | return ''; 36 | } 37 | 38 | /** 39 | * parses the rdata portion from a standard DNS config line 40 | * 41 | * @param array $rdata a string split line of values for the rdata 42 | * 43 | * @return boolean 44 | * @access protected 45 | * 46 | */ 47 | protected function rrFromString(array $rdata) 48 | { 49 | return true; 50 | } 51 | 52 | /** 53 | * parses the rdata of the Net_DNS2_Packet object 54 | * 55 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 56 | * 57 | * @return boolean 58 | * @access protected 59 | * 60 | */ 61 | protected function rrSet(Net_DNS2_Packet &$packet) 62 | { 63 | return true; 64 | } 65 | 66 | /** 67 | * returns the rdata portion of the DNS packet 68 | * 69 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 70 | * compressed names 71 | * 72 | * @return mixed either returns a binary packed 73 | * string or null on failure 74 | * @access protected 75 | * 76 | */ 77 | protected function rrGet(Net_DNS2_Packet &$packet) 78 | { 79 | return ''; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Net/DNS2/RR/AVC.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.4.2 17 | * 18 | */ 19 | 20 | /** 21 | * The AVC RR is implemented exactly like the TXT record, so 22 | * for now we just extend the TXT RR and use it. 23 | * 24 | */ 25 | class Net_DNS2_RR_AVC extends Net_DNS2_RR_TXT 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /Net/DNS2/RR/CAA.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.2.0 17 | * 18 | */ 19 | 20 | /** 21 | * CAA Resource Record - http://tools.ietf.org/html/draft-ietf-pkix-caa-03 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | FLAGS | TAG LENGTH | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / TAG / 27 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 28 | * / DATA / 29 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 30 | * 31 | */ 32 | class Net_DNS2_RR_CAA extends Net_DNS2_RR 33 | { 34 | /* 35 | * The critcal flag 36 | */ 37 | public $flags; 38 | 39 | /* 40 | * The property identifier 41 | */ 42 | public $tag; 43 | 44 | /* 45 | * The property value 46 | */ 47 | public $value; 48 | 49 | /** 50 | * method to return the rdata portion of the packet as a string 51 | * 52 | * @return string 53 | * @access protected 54 | * 55 | */ 56 | protected function rrToString() 57 | { 58 | return $this->flags . ' ' . $this->tag . ' "' . 59 | trim($this->cleanString($this->value), '"') . '"'; 60 | } 61 | 62 | /** 63 | * parses the rdata portion from a standard DNS config line 64 | * 65 | * @param array $rdata a string split line of values for the rdata 66 | * 67 | * @return boolean 68 | * @access protected 69 | * 70 | */ 71 | protected function rrFromString(array $rdata) 72 | { 73 | $this->flags = array_shift($rdata); 74 | $this->tag = array_shift($rdata); 75 | 76 | $this->value = trim($this->cleanString(implode(' ', $rdata)), '"'); 77 | 78 | return true; 79 | } 80 | 81 | /** 82 | * parses the rdata of the Net_DNS2_Packet object 83 | * 84 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 85 | * 86 | * @return boolean 87 | * @access protected 88 | * 89 | */ 90 | protected function rrSet(Net_DNS2_Packet &$packet) 91 | { 92 | if ($this->rdlength > 0) { 93 | 94 | // 95 | // unpack the flags and tag length 96 | // 97 | $x = unpack('Cflags/Ctag_length', $this->rdata); 98 | 99 | $this->flags = $x['flags']; 100 | $offset = 2; 101 | 102 | $this->tag = substr($this->rdata, $offset, $x['tag_length']); 103 | $offset += $x['tag_length']; 104 | 105 | $this->value = substr($this->rdata, $offset); 106 | 107 | return true; 108 | } 109 | 110 | return false; 111 | } 112 | 113 | /** 114 | * returns the rdata portion of the DNS packet 115 | * 116 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 117 | * compressed names 118 | * 119 | * @return mixed either returns a binary packed 120 | * string or null on failure 121 | * @access protected 122 | * 123 | */ 124 | protected function rrGet(Net_DNS2_Packet &$packet) 125 | { 126 | if (strlen($this->value) > 0) { 127 | 128 | $data = chr($this->flags); 129 | $data .= chr(strlen($this->tag)) . $this->tag . $this->value; 130 | 131 | $packet->offset += strlen($data); 132 | 133 | return $data; 134 | } 135 | 136 | return null; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Net/DNS2/RR/CDNSKEY.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.4.0 17 | * 18 | */ 19 | 20 | /** 21 | * The CDNSKEY RR is implemented exactly like the DNSKEY record, so 22 | * for now we just extend the DNSKEY RR and use it. 23 | * 24 | * http://www.rfc-editor.org/rfc/rfc7344.txt 25 | * 26 | */ 27 | class Net_DNS2_RR_CDNSKEY extends Net_DNS2_RR_DNSKEY 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /Net/DNS2/RR/CDS.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.2.0 17 | * 18 | */ 19 | 20 | /** 21 | * The CDS RR is implemented exactly like the DS record, so 22 | * for now we just extend the DS RR and use it. 23 | * 24 | * http://www.rfc-editor.org/rfc/rfc7344.txt 25 | * 26 | */ 27 | class Net_DNS2_RR_CDS extends Net_DNS2_RR_DS 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /Net/DNS2/RR/CNAME.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * CNAME Resource Record - RFC1035 section 3.3.1 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / CNAME / 25 | * / / 26 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 27 | * 28 | */ 29 | class Net_DNS2_RR_CNAME extends Net_DNS2_RR 30 | { 31 | /* 32 | * The canonical name 33 | */ 34 | public $cname; 35 | 36 | /** 37 | * method to return the rdata portion of the packet as a string 38 | * 39 | * @return string 40 | * @access protected 41 | * 42 | */ 43 | protected function rrToString() 44 | { 45 | return $this->cleanString($this->cname) . '.'; 46 | } 47 | 48 | /** 49 | * parses the rdata portion from a standard DNS config line 50 | * 51 | * @param array $rdata a string split line of values for the rdata 52 | * 53 | * @return boolean 54 | * @access protected 55 | * 56 | */ 57 | protected function rrFromString(array $rdata) 58 | { 59 | $this->cname = $this->cleanString(array_shift($rdata)); 60 | return true; 61 | } 62 | 63 | /** 64 | * parses the rdata of the Net_DNS2_Packet object 65 | * 66 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 67 | * 68 | * @return boolean 69 | * @access protected 70 | * 71 | */ 72 | protected function rrSet(Net_DNS2_Packet &$packet) 73 | { 74 | if ($this->rdlength > 0) { 75 | 76 | $offset = $packet->offset; 77 | $this->cname = Net_DNS2_Packet::expand($packet, $offset); 78 | 79 | return true; 80 | } 81 | 82 | return false; 83 | } 84 | 85 | /** 86 | * returns the rdata portion of the DNS packet 87 | * 88 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 89 | * compressed names 90 | * 91 | * @return mixed either returns a binary packed 92 | * string or null on failure 93 | * @access protected 94 | * 95 | */ 96 | protected function rrGet(Net_DNS2_Packet &$packet) 97 | { 98 | if (strlen($this->cname) > 0) { 99 | 100 | return $packet->compress($this->cname, $packet->offset); 101 | } 102 | 103 | return null; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Net/DNS2/RR/DLV.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * The DLV RR is implemented exactly like the DS RR; so we just extend that 22 | * class, and use all of it's methods 23 | * 24 | */ 25 | class Net_DNS2_RR_DLV extends Net_DNS2_RR_DS 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /Net/DNS2/RR/DNAME.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * DNAME Resource Record - RFC2672 section 3 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / DNAME / 25 | * / / 26 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 27 | * 28 | */ 29 | class Net_DNS2_RR_DNAME extends Net_DNS2_RR 30 | { 31 | /* 32 | * The target name 33 | */ 34 | public $dname; 35 | 36 | /** 37 | * method to return the rdata portion of the packet as a string 38 | * 39 | * @return string 40 | * @access protected 41 | * 42 | */ 43 | protected function rrToString() 44 | { 45 | return $this->cleanString($this->dname) . '.'; 46 | } 47 | 48 | /** 49 | * parses the rdata portion from a standard DNS config line 50 | * 51 | * @param array $rdata a string split line of values for the rdata 52 | * 53 | * @return boolean 54 | * @access protected 55 | * 56 | */ 57 | protected function rrFromString(array $rdata) 58 | { 59 | $this->dname = $this->cleanString(array_shift($rdata)); 60 | return true; 61 | } 62 | 63 | /** 64 | * parses the rdata of the Net_DNS2_Packet object 65 | * 66 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 67 | * 68 | * @return boolean 69 | * @access protected 70 | * 71 | */ 72 | protected function rrSet(Net_DNS2_Packet &$packet) 73 | { 74 | if ($this->rdlength > 0) { 75 | 76 | $offset = $packet->offset; 77 | $this->dname = Net_DNS2_Packet::expand($packet, $offset); 78 | 79 | return true; 80 | } 81 | 82 | return false; 83 | } 84 | 85 | /** 86 | * returns the rdata portion of the DNS packet 87 | * 88 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 89 | * compressed names 90 | * 91 | * @return mixed either returns a binary packed 92 | * string or null on failure 93 | * @access protected 94 | * 95 | */ 96 | protected function rrGet(Net_DNS2_Packet &$packet) 97 | { 98 | if (strlen($this->dname) > 0) { 99 | 100 | return $packet->compress($this->dname, $packet->offset); 101 | } 102 | 103 | return null; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Net/DNS2/RR/DS.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * DS Resource Record - RFC4034 sction 5.1 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Key Tag | Algorithm | Digest Type | 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 27 | * / / 28 | * / Digest / 29 | * / / 30 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 | * 32 | */ 33 | class Net_DNS2_RR_DS extends Net_DNS2_RR 34 | { 35 | /* 36 | * key tag 37 | */ 38 | public $keytag; 39 | 40 | /* 41 | * algorithm number 42 | */ 43 | public $algorithm; 44 | 45 | /* 46 | * algorithm used to construct the digest 47 | */ 48 | public $digesttype; 49 | 50 | /* 51 | * the digest data 52 | */ 53 | public $digest; 54 | 55 | /** 56 | * method to return the rdata portion of the packet as a string 57 | * 58 | * @return string 59 | * @access protected 60 | * 61 | */ 62 | protected function rrToString() 63 | { 64 | return $this->keytag . ' ' . $this->algorithm . ' ' . $this->digesttype . ' ' . $this->digest; 65 | } 66 | 67 | /** 68 | * parses the rdata portion from a standard DNS config line 69 | * 70 | * @param array $rdata a string split line of values for the rdata 71 | * 72 | * @return boolean 73 | * @access protected 74 | * 75 | */ 76 | protected function rrFromString(array $rdata) 77 | { 78 | $this->keytag = array_shift($rdata); 79 | $this->algorithm = array_shift($rdata); 80 | $this->digesttype = array_shift($rdata); 81 | $this->digest = implode('', $rdata); 82 | 83 | return true; 84 | } 85 | 86 | /** 87 | * parses the rdata of the Net_DNS2_Packet object 88 | * 89 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 90 | * 91 | * @return boolean 92 | * @access protected 93 | * 94 | */ 95 | protected function rrSet(Net_DNS2_Packet &$packet) 96 | { 97 | if ($this->rdlength > 0) { 98 | 99 | // 100 | // unpack the keytag, algorithm and digesttype 101 | // 102 | $x = unpack('nkeytag/Calgorithm/Cdigesttype/H*digest', $this->rdata); 103 | 104 | $this->keytag = $x['keytag']; 105 | $this->algorithm = $x['algorithm']; 106 | $this->digesttype = $x['digesttype']; 107 | $this->digest = $x['digest']; 108 | 109 | return true; 110 | } 111 | 112 | return false; 113 | } 114 | 115 | /** 116 | * returns the rdata portion of the DNS packet 117 | * 118 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 119 | * compressed names 120 | * 121 | * @return mixed either returns a binary packed 122 | * string or null on failure 123 | * @access protected 124 | * 125 | */ 126 | protected function rrGet(Net_DNS2_Packet &$packet) 127 | { 128 | if (strlen($this->digest) > 0) { 129 | 130 | $data = pack('nCCH*', $this->keytag, $this->algorithm, $this->digesttype, $this->digest); 131 | 132 | $packet->offset += strlen($data); 133 | 134 | return $data; 135 | } 136 | 137 | return null; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Net/DNS2/RR/EID.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * EID Resource Record - undefined; the rdata is simply used as-is in it's 22 | * binary format, so not process has to be done. 23 | * 24 | */ 25 | class Net_DNS2_RR_EID extends Net_DNS2_RR 26 | { 27 | /** 28 | * method to return the rdata portion of the packet as a string 29 | * 30 | * @return string 31 | * @access protected 32 | * 33 | */ 34 | protected function rrToString() 35 | { 36 | return ''; 37 | } 38 | 39 | /** 40 | * parses the rdata portion from a standard DNS config line 41 | * 42 | * @param array $rdata a string split line of values for the rdata 43 | * 44 | * @return boolean 45 | * @access protected 46 | * 47 | */ 48 | protected function rrFromString(array $rdata) 49 | { 50 | return true; 51 | } 52 | 53 | /** 54 | * parses the rdata of the Net_DNS2_Packet object 55 | * 56 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 57 | * 58 | * @return boolean 59 | * @access protected 60 | * 61 | */ 62 | protected function rrSet(Net_DNS2_Packet &$packet) 63 | { 64 | return true; 65 | } 66 | 67 | /** 68 | * returns the rdata portion of the DNS packet 69 | * 70 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 71 | * compressed names 72 | * 73 | * @return mixed either returns a binary packed 74 | * string or null on failure 75 | * @access protected 76 | * 77 | */ 78 | protected function rrGet(Net_DNS2_Packet &$packet) 79 | { 80 | return $this->rdata; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Net/DNS2/RR/EUI48.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.2 17 | * 18 | */ 19 | 20 | /** 21 | * EUI48 Resource Record - RFC7043 section 3.1 22 | * 23 | * 0 1 2 3 24 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 25 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 | * | EUI-48 Address | 27 | * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 | * | | 29 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 30 | * 31 | */ 32 | class Net_DNS2_RR_EUI48 extends Net_DNS2_RR 33 | { 34 | /* 35 | * The EUI48 address, in hex format 36 | */ 37 | public $address; 38 | 39 | /** 40 | * method to return the rdata portion of the packet as a string 41 | * 42 | * @return string 43 | * @access protected 44 | * 45 | */ 46 | protected function rrToString() 47 | { 48 | return $this->address; 49 | } 50 | 51 | /** 52 | * parses the rdata portion from a standard DNS config line 53 | * 54 | * @param array $rdata a string split line of values for the rdata 55 | * 56 | * @return boolean 57 | * @access protected 58 | * 59 | */ 60 | protected function rrFromString(array $rdata) 61 | { 62 | $value = array_shift($rdata); 63 | 64 | // 65 | // re: RFC 7043, the field must be represented as six two-digit hex numbers 66 | // separated by hyphens. 67 | // 68 | $a = explode('-', $value); 69 | if (cacti_sizeof($a) != 6) { 70 | 71 | return false; 72 | } 73 | 74 | // 75 | // make sure they're all hex values 76 | // 77 | foreach ($a as $i) { 78 | if (ctype_xdigit($i) == false) { 79 | return false; 80 | } 81 | } 82 | 83 | // 84 | // store it 85 | // 86 | $this->address = strtolower($value); 87 | 88 | return true; 89 | } 90 | 91 | /** 92 | * parses the rdata of the Net_DNS2_Packet object 93 | * 94 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 95 | * 96 | * @return boolean 97 | * @access protected 98 | * 99 | */ 100 | protected function rrSet(Net_DNS2_Packet &$packet) 101 | { 102 | if ($this->rdlength > 0) { 103 | 104 | $x = unpack('C6', $this->rdata); 105 | if (cacti_sizeof($x) == 6) { 106 | 107 | $this->address = vsprintf('%02x-%02x-%02x-%02x-%02x-%02x', $x); 108 | return true; 109 | } 110 | } 111 | 112 | return false; 113 | } 114 | 115 | /** 116 | * returns the rdata portion of the DNS packet 117 | * 118 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 119 | * compressed names 120 | * 121 | * @return mixed either returns a binary packed 122 | * string or null on failure 123 | * @access protected 124 | * 125 | */ 126 | protected function rrGet(Net_DNS2_Packet &$packet) 127 | { 128 | $data = ''; 129 | 130 | $a = explode('-', $this->address); 131 | foreach ($a as $b) { 132 | 133 | $data .= chr(hexdec($b)); 134 | } 135 | 136 | $packet->offset += 6; 137 | return $data; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Net/DNS2/RR/EUI64.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.2 17 | * 18 | */ 19 | 20 | /** 21 | * EUI64 Resource Record - RFC7043 section 4.1 22 | * 23 | * 0 1 2 3 24 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 25 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 | * | EUI-64 Address | 27 | * | | 28 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * 30 | */ 31 | class Net_DNS2_RR_EUI64 extends Net_DNS2_RR 32 | { 33 | /* 34 | * The EUI64 address, in hex format 35 | */ 36 | public $address; 37 | 38 | /** 39 | * method to return the rdata portion of the packet as a string 40 | * 41 | * @return string 42 | * @access protected 43 | * 44 | */ 45 | protected function rrToString() 46 | { 47 | return $this->address; 48 | } 49 | 50 | /** 51 | * parses the rdata portion from a standard DNS config line 52 | * 53 | * @param array $rdata a string split line of values for the rdata 54 | * 55 | * @return boolean 56 | * @access protected 57 | * 58 | */ 59 | protected function rrFromString(array $rdata) 60 | { 61 | $value = array_shift($rdata); 62 | 63 | // 64 | // re: RFC 7043, the field must be represented as 8 two-digit hex numbers 65 | // separated by hyphens. 66 | // 67 | $a = explode('-', $value); 68 | if (cacti_sizeof($a) != 8) { 69 | 70 | return false; 71 | } 72 | 73 | // 74 | // make sure they're all hex values 75 | // 76 | foreach ($a as $i) { 77 | if (ctype_xdigit($i) == false) { 78 | return false; 79 | } 80 | } 81 | 82 | // 83 | // store it 84 | // 85 | $this->address = strtolower($value); 86 | 87 | return true; 88 | } 89 | 90 | /** 91 | * parses the rdata of the Net_DNS2_Packet object 92 | * 93 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 94 | * 95 | * @return boolean 96 | * @access protected 97 | * 98 | */ 99 | protected function rrSet(Net_DNS2_Packet &$packet) 100 | { 101 | if ($this->rdlength > 0) { 102 | 103 | $x = unpack('C8', $this->rdata); 104 | if (cacti_sizeof($x) == 8) { 105 | 106 | $this->address = vsprintf( 107 | '%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x', $x 108 | ); 109 | return true; 110 | } 111 | } 112 | 113 | return false; 114 | } 115 | 116 | /** 117 | * returns the rdata portion of the DNS packet 118 | * 119 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 120 | * compressed names 121 | * 122 | * @return mixed either returns a binary packed 123 | * string or null on failure 124 | * @access protected 125 | * 126 | */ 127 | protected function rrGet(Net_DNS2_Packet &$packet) 128 | { 129 | $data = ''; 130 | 131 | $a = explode('-', $this->address); 132 | foreach ($a as $b) { 133 | 134 | $data .= chr(hexdec($b)); 135 | } 136 | 137 | $packet->offset += 8; 138 | return $data; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /Net/DNS2/RR/HINFO.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * HINFO Resource Record - RFC1035 section 3.3.2 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / CPU / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / OS / 27 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 28 | * 29 | */ 30 | class Net_DNS2_RR_HINFO extends Net_DNS2_RR 31 | { 32 | /* 33 | * computer informatino 34 | */ 35 | public $cpu; 36 | 37 | /* 38 | * operataing system 39 | */ 40 | public $os; 41 | 42 | /** 43 | * method to return the rdata portion of the packet as a string 44 | * 45 | * @return string 46 | * @access protected 47 | * 48 | */ 49 | protected function rrToString() 50 | { 51 | return $this->formatString($this->cpu) . ' ' . $this->formatString($this->os); 52 | } 53 | 54 | /** 55 | * parses the rdata portion from a standard DNS config line 56 | * 57 | * @param array $rdata a string split line of values for the rdata 58 | * 59 | * @return boolean 60 | * @access protected 61 | * 62 | */ 63 | protected function rrFromString(array $rdata) 64 | { 65 | $data = $this->buildString($rdata); 66 | if (cacti_sizeof($data) == 2) { 67 | 68 | $this->cpu = trim($data[0], '"'); 69 | $this->os = trim($data[1], '"'); 70 | 71 | return true; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | /** 78 | * parses the rdata of the Net_DNS2_Packet object 79 | * 80 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 81 | * 82 | * @return boolean 83 | * @access protected 84 | * 85 | */ 86 | protected function rrSet(Net_DNS2_Packet &$packet) 87 | { 88 | if ($this->rdlength > 0) { 89 | 90 | $offset = $packet->offset; 91 | 92 | $this->cpu = Net_DNS2_Packet::label($packet, $offset); 93 | $this->os = Net_DNS2_Packet::label($packet, $offset); 94 | 95 | return true; 96 | } 97 | 98 | return false; 99 | } 100 | 101 | /** 102 | * returns the rdata portion of the DNS packet 103 | * 104 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 105 | * compressed names 106 | * 107 | * @return mixed either returns a binary packed 108 | * string or null on failure 109 | * @access protected 110 | * 111 | */ 112 | protected function rrGet(Net_DNS2_Packet &$packet) 113 | { 114 | if (strlen($this->cpu) > 0) { 115 | 116 | $data = pack('Ca*Ca*', strlen($this->cpu), $this->cpu, strlen($this->os), $this->os); 117 | 118 | $packet->offset += strlen($data); 119 | 120 | return $data; 121 | } 122 | 123 | return null; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /Net/DNS2/RR/ISDN.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * ISDN Resource Record - RFC1183 section 3.2 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / ISDN-address / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / SA / 27 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 28 | * 29 | */ 30 | class Net_DNS2_RR_ISDN extends Net_DNS2_RR 31 | { 32 | /* 33 | * ISDN Number 34 | */ 35 | public $isdnaddress; 36 | 37 | /* 38 | * Sub-Address 39 | */ 40 | public $sa; 41 | 42 | /** 43 | * method to return the rdata portion of the packet as a string 44 | * 45 | * @return string 46 | * @access protected 47 | * 48 | */ 49 | protected function rrToString() 50 | { 51 | return $this->formatString($this->isdnaddress) . ' ' . 52 | $this->formatString($this->sa); 53 | } 54 | 55 | /** 56 | * parses the rdata portion from a standard DNS config line 57 | * 58 | * @param array $rdata a string split line of values for the rdata 59 | * 60 | * @return boolean 61 | * @access protected 62 | * 63 | */ 64 | protected function rrFromString(array $rdata) 65 | { 66 | $data = $this->buildString($rdata); 67 | if (cacti_sizeof($data) >= 1) { 68 | 69 | $this->isdnaddress = $data[0]; 70 | if (isset($data[1])) { 71 | 72 | $this->sa = $data[1]; 73 | } 74 | 75 | return true; 76 | } 77 | 78 | return false; 79 | } 80 | 81 | /** 82 | * parses the rdata of the Net_DNS2_Packet object 83 | * 84 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 85 | * 86 | * @return boolean 87 | * @access protected 88 | * 89 | */ 90 | protected function rrSet(Net_DNS2_Packet &$packet) 91 | { 92 | if ($this->rdlength > 0) { 93 | 94 | $this->isdnaddress = Net_DNS2_Packet::label($packet, $packet->offset); 95 | 96 | // 97 | // look for a SA (sub address) - it's optional 98 | // 99 | if ( (strlen($this->isdnaddress) + 1) < $this->rdlength) { 100 | 101 | $this->sa = Net_DNS2_Packet::label($packet, $packet->offset); 102 | } else { 103 | 104 | $this->sa = ''; 105 | } 106 | 107 | return true; 108 | } 109 | 110 | return false; 111 | } 112 | 113 | /** 114 | * returns the rdata portion of the DNS packet 115 | * 116 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 117 | * compressed names 118 | * 119 | * @return mixed either returns a binary packed 120 | * string or null on failure 121 | * @access protected 122 | * 123 | */ 124 | protected function rrGet(Net_DNS2_Packet &$packet) 125 | { 126 | if (strlen($this->isdnaddress) > 0) { 127 | 128 | $data = chr(strlen($this->isdnaddress)) . $this->isdnaddress; 129 | if (!empty($this->sa)) { 130 | 131 | $data .= chr(strlen($this->sa)); 132 | $data .= $this->sa; 133 | } 134 | 135 | $packet->offset += strlen($data); 136 | 137 | return $data; 138 | } 139 | 140 | return null; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Net/DNS2/RR/KEY.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * the KEY RR is implemented the same as the DNSKEY RR, the only difference 22 | * is how the flags data is parsed. 23 | * 24 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 25 | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 26 | * | A/C | Z | XT| Z | Z | NAMTYP| Z | Z | Z | Z | SIG | 27 | * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 28 | * 29 | * DNSKEY only uses bits 7 and 15 30 | * 31 | * We're not doing anything with these flags right now, so duplicating the 32 | * class like this is fine. 33 | * 34 | */ 35 | class Net_DNS2_RR_KEY extends Net_DNS2_RR_DNSKEY 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /Net/DNS2/RR/KX.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * KX Resource Record - RFC2230 section 3.1 22 | * 23 | * This class is almost identical to MX, except that the the exchanger 24 | * domain is not compressed, it's added as a label 25 | * 26 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 27 | * | PREFERENCE | 28 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 | * / EXCHANGER / 30 | * / / 31 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 32 | * 33 | */ 34 | class Net_DNS2_RR_KX extends Net_DNS2_RR 35 | { 36 | /* 37 | * the preference for this mail exchanger 38 | */ 39 | public $preference; 40 | 41 | /* 42 | * the hostname of the mail exchanger 43 | */ 44 | public $exchange; 45 | 46 | /** 47 | * method to return the rdata portion of the packet as a string 48 | * 49 | * @return string 50 | * @access protected 51 | * 52 | */ 53 | protected function rrToString() 54 | { 55 | return $this->preference . ' ' . $this->cleanString($this->exchange) . '.'; 56 | } 57 | 58 | /** 59 | * parses the rdata portion from a standard DNS config line 60 | * 61 | * @param array $rdata a string split line of values for the rdata 62 | * 63 | * @return boolean 64 | * @access protected 65 | * 66 | */ 67 | protected function rrFromString(array $rdata) 68 | { 69 | $this->preference = array_shift($rdata); 70 | $this->exchange = $this->cleanString(array_shift($rdata)); 71 | 72 | return true; 73 | } 74 | 75 | /** 76 | * parses the rdata of the Net_DNS2_Packet object 77 | * 78 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 79 | * 80 | * @return boolean 81 | * @access protected 82 | * 83 | */ 84 | protected function rrSet(Net_DNS2_Packet &$packet) 85 | { 86 | if ($this->rdlength > 0) { 87 | 88 | // 89 | // parse the preference 90 | // 91 | $x = unpack('npreference', $this->rdata); 92 | $this->preference = $x['preference']; 93 | 94 | // 95 | // get the exchange entry server) 96 | // 97 | $offset = $packet->offset + 2; 98 | $this->exchange = Net_DNS2_Packet::label($packet, $offset); 99 | 100 | return true; 101 | } 102 | 103 | return false; 104 | } 105 | 106 | /** 107 | * returns the rdata portion of the DNS packet 108 | * 109 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 110 | * compressed names 111 | * 112 | * @return mixed either returns a binary packed 113 | * string or null on failure 114 | * @access protected 115 | * 116 | */ 117 | protected function rrGet(Net_DNS2_Packet &$packet) 118 | { 119 | if (strlen($this->exchange) > 0) { 120 | 121 | $data = pack('nC', $this->preference, strlen($this->exchange)) . 122 | $this->exchange; 123 | 124 | $packet->offset += strlen($data); 125 | 126 | return $data; 127 | } 128 | 129 | return null; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Net/DNS2/RR/L32.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.1 17 | * 18 | */ 19 | 20 | /** 21 | * L32 Resource Record - RFC6742 section 2.2 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Preference | Locator32 (16 MSBs) | 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 27 | * | Locator32 (16 LSBs) | 28 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * 30 | */ 31 | class Net_DNS2_RR_L32 extends Net_DNS2_RR 32 | { 33 | /* 34 | * The preference 35 | */ 36 | public $preference; 37 | 38 | /* 39 | * The locator32 field 40 | */ 41 | public $locator32; 42 | 43 | /** 44 | * method to return the rdata portion of the packet as a string 45 | * 46 | * @return string 47 | * @access protected 48 | * 49 | */ 50 | protected function rrToString() 51 | { 52 | return $this->preference . ' ' . $this->locator32; 53 | } 54 | 55 | /** 56 | * parses the rdata portion from a standard DNS config line 57 | * 58 | * @param array $rdata a string split line of values for the rdata 59 | * 60 | * @return boolean 61 | * @access protected 62 | * 63 | */ 64 | protected function rrFromString(array $rdata) 65 | { 66 | $this->preference = array_shift($rdata); 67 | $this->locator32 = array_shift($rdata); 68 | 69 | return true; 70 | } 71 | 72 | /** 73 | * parses the rdata of the Net_DNS2_Packet object 74 | * 75 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 76 | * 77 | * @return boolean 78 | * @access protected 79 | * 80 | */ 81 | protected function rrSet(Net_DNS2_Packet &$packet) 82 | { 83 | if ($this->rdlength > 0) { 84 | 85 | // 86 | // unpack the values 87 | // 88 | $x = unpack('npreference/C4locator', $this->rdata); 89 | 90 | $this->preference = $x['preference']; 91 | 92 | // 93 | // build the locator value 94 | // 95 | $this->locator32 = $x['locator1'] . '.' . $x['locator2'] . '.' . 96 | $x['locator3'] . '.' . $x['locator4']; 97 | 98 | return true; 99 | } 100 | 101 | return false; 102 | } 103 | 104 | /** 105 | * returns the rdata portion of the DNS packet 106 | * 107 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 108 | * compressed names 109 | * 110 | * @return mixed either returns a binary packed 111 | * string or null on failure 112 | * @access protected 113 | * 114 | */ 115 | protected function rrGet(Net_DNS2_Packet &$packet) 116 | { 117 | if (strlen($this->locator32) > 0) { 118 | 119 | // 120 | // break out the locator value 121 | // 122 | $n = explode('.', $this->locator32); 123 | 124 | // 125 | // pack the data 126 | // 127 | return pack('nC4', $this->preference, $n[0], $n[1], $n[2], $n[3]); 128 | } 129 | 130 | return null; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Net/DNS2/RR/L64.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.1 17 | * 18 | */ 19 | 20 | /** 21 | * L64 Resource Record - RFC6742 section 2.3 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Preference | | 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 27 | * | Locator64 | 28 | * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * | | 30 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 | * 32 | */ 33 | class Net_DNS2_RR_L64 extends Net_DNS2_RR 34 | { 35 | /* 36 | * The preference 37 | */ 38 | public $preference; 39 | 40 | /* 41 | * The locator64 field 42 | */ 43 | public $locator64; 44 | 45 | /** 46 | * method to return the rdata portion of the packet as a string 47 | * 48 | * @return string 49 | * @access protected 50 | * 51 | */ 52 | protected function rrToString() 53 | { 54 | return $this->preference . ' ' . $this->locator64; 55 | } 56 | 57 | /** 58 | * parses the rdata portion from a standard DNS config line 59 | * 60 | * @param array $rdata a string split line of values for the rdata 61 | * 62 | * @return boolean 63 | * @access protected 64 | * 65 | */ 66 | protected function rrFromString(array $rdata) 67 | { 68 | $this->preference = array_shift($rdata); 69 | $this->locator64 = array_shift($rdata); 70 | 71 | return true; 72 | } 73 | 74 | /** 75 | * parses the rdata of the Net_DNS2_Packet object 76 | * 77 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 78 | * 79 | * @return boolean 80 | * @access protected 81 | * 82 | */ 83 | protected function rrSet(Net_DNS2_Packet &$packet) 84 | { 85 | if ($this->rdlength > 0) { 86 | 87 | // 88 | // unpack the values 89 | // 90 | $x = unpack('npreference/n4locator', $this->rdata); 91 | 92 | $this->preference = $x['preference']; 93 | 94 | // 95 | // build the locator64 96 | // 97 | $this->locator64 = dechex($x['locator1']) . ':' . 98 | dechex($x['locator2']) . ':' . 99 | dechex($x['locator3']) . ':' . 100 | dechex($x['locator4']); 101 | 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | /** 109 | * returns the rdata portion of the DNS packet 110 | * 111 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 112 | * compressed names 113 | * 114 | * @return mixed either returns a binary packed 115 | * string or null on failure 116 | * @access protected 117 | * 118 | */ 119 | protected function rrGet(Net_DNS2_Packet &$packet) 120 | { 121 | if (strlen($this->locator64) > 0) { 122 | 123 | // 124 | // break out the locator64 125 | // 126 | $n = explode(':', $this->locator64); 127 | 128 | // 129 | // pack the data 130 | // 131 | return pack( 132 | 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]), 133 | hexdec($n[2]), hexdec($n[3]) 134 | ); 135 | } 136 | 137 | return null; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Net/DNS2/RR/LP.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.1 17 | * 18 | */ 19 | 20 | /** 21 | * LP Resource Record - RFC6742 section 2.4 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Preference | / 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / 27 | * / / 28 | * / FQDN / 29 | * / / 30 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 | * 32 | */ 33 | class Net_DNS2_RR_LP extends Net_DNS2_RR 34 | { 35 | /* 36 | * The preference 37 | */ 38 | public $preference; 39 | 40 | /* 41 | * The fdqn field 42 | */ 43 | public $fqdn; 44 | 45 | /** 46 | * method to return the rdata portion of the packet as a string 47 | * 48 | * @return string 49 | * @access protected 50 | * 51 | */ 52 | protected function rrToString() 53 | { 54 | return $this->preference . ' ' . $this->fqdn . '.'; 55 | } 56 | 57 | /** 58 | * parses the rdata portion from a standard DNS config line 59 | * 60 | * @param array $rdata a string split line of values for the rdata 61 | * 62 | * @return boolean 63 | * @access protected 64 | * 65 | */ 66 | protected function rrFromString(array $rdata) 67 | { 68 | $this->preference = array_shift($rdata); 69 | $this->fqdn = trim(array_shift($rdata), '.'); 70 | 71 | return true; 72 | } 73 | 74 | /** 75 | * parses the rdata of the Net_DNS2_Packet object 76 | * 77 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 78 | * 79 | * @return boolean 80 | * @access protected 81 | * 82 | */ 83 | protected function rrSet(Net_DNS2_Packet &$packet) 84 | { 85 | if ($this->rdlength > 0) { 86 | 87 | // 88 | // parse the preference 89 | // 90 | $x = unpack('npreference', $this->rdata); 91 | $this->preference = $x['preference']; 92 | $offset = $packet->offset + 2; 93 | 94 | // 95 | // get the hostname 96 | // 97 | $this->fqdn = Net_DNS2_Packet::expand($packet, $offset); 98 | 99 | return true; 100 | } 101 | 102 | return false; 103 | } 104 | 105 | /** 106 | * returns the rdata portion of the DNS packet 107 | * 108 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 109 | * compressed names 110 | * 111 | * @return mixed either returns a binary packed 112 | * string or null on failure 113 | * @access protected 114 | * 115 | */ 116 | protected function rrGet(Net_DNS2_Packet &$packet) 117 | { 118 | if (strlen($this->fqdn) > 0) { 119 | 120 | $data = pack('n', $this->preference); 121 | $packet->offset += 2; 122 | 123 | $data .= $packet->compress($this->fqdn, $packet->offset); 124 | return $data; 125 | } 126 | 127 | return null; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Net/DNS2/RR/MX.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * MX Resource Record - RFC1035 section 3.3.9 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | PREFERENCE | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / EXCHANGE / 27 | * / / 28 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 | * 30 | */ 31 | class Net_DNS2_RR_MX extends Net_DNS2_RR 32 | { 33 | /* 34 | * the preference for this mail exchanger 35 | */ 36 | public $preference; 37 | 38 | /* 39 | * the hostname of the mail exchanger 40 | */ 41 | public $exchange; 42 | 43 | /** 44 | * method to return the rdata portion of the packet as a string 45 | * 46 | * @return string 47 | * @access protected 48 | * 49 | */ 50 | protected function rrToString() 51 | { 52 | return $this->preference . ' ' . $this->cleanString($this->exchange) . '.'; 53 | } 54 | 55 | /** 56 | * parses the rdata portion from a standard DNS config line 57 | * 58 | * @param array $rdata a string split line of values for the rdata 59 | * 60 | * @return boolean 61 | * @access protected 62 | * 63 | */ 64 | protected function rrFromString(array $rdata) 65 | { 66 | $this->preference = array_shift($rdata); 67 | $this->exchange = $this->cleanString(array_shift($rdata)); 68 | 69 | return true; 70 | } 71 | 72 | /** 73 | * parses the rdata of the Net_DNS2_Packet object 74 | * 75 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 76 | * 77 | * @return boolean 78 | * @access protected 79 | * 80 | */ 81 | protected function rrSet(Net_DNS2_Packet &$packet) 82 | { 83 | if ($this->rdlength > 0) { 84 | 85 | // 86 | // parse the preference 87 | // 88 | $x = unpack('npreference', $this->rdata); 89 | $this->preference = $x['preference']; 90 | 91 | // 92 | // get the exchange entry server) 93 | // 94 | $offset = $packet->offset + 2; 95 | $this->exchange = Net_DNS2_Packet::expand($packet, $offset); 96 | 97 | return true; 98 | } 99 | 100 | return false; 101 | } 102 | 103 | /** 104 | * returns the rdata portion of the DNS packet 105 | * 106 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 107 | * compressed names 108 | * 109 | * @return mixed either returns a binary packed 110 | * string or null on failure 111 | * @access protected 112 | * 113 | */ 114 | protected function rrGet(Net_DNS2_Packet &$packet) 115 | { 116 | if (strlen($this->exchange) > 0) { 117 | 118 | $data = pack('n', $this->preference); 119 | $packet->offset += 2; 120 | 121 | $data .= $packet->compress($this->exchange, $packet->offset); 122 | return $data; 123 | } 124 | 125 | return null; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Net/DNS2/RR/NID.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.3.1 17 | * 18 | */ 19 | 20 | /** 21 | * NID Resource Record - RFC6742 section 2.1 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Preference | | 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 27 | * | NodeID | 28 | * + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * | | 30 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 | * 32 | */ 33 | class Net_DNS2_RR_NID extends Net_DNS2_RR 34 | { 35 | /* 36 | * The preference 37 | */ 38 | public $preference; 39 | 40 | /* 41 | * The node ID field 42 | */ 43 | public $nodeid; 44 | 45 | /** 46 | * method to return the rdata portion of the packet as a string 47 | * 48 | * @return string 49 | * @access protected 50 | * 51 | */ 52 | protected function rrToString() 53 | { 54 | return $this->preference . ' ' . $this->nodeid; 55 | } 56 | 57 | /** 58 | * parses the rdata portion from a standard DNS config line 59 | * 60 | * @param array $rdata a string split line of values for the rdata 61 | * 62 | * @return boolean 63 | * @access protected 64 | * 65 | */ 66 | protected function rrFromString(array $rdata) 67 | { 68 | $this->preference = array_shift($rdata); 69 | $this->nodeid = array_shift($rdata); 70 | 71 | return true; 72 | } 73 | 74 | /** 75 | * parses the rdata of the Net_DNS2_Packet object 76 | * 77 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 78 | * 79 | * @return boolean 80 | * @access protected 81 | * 82 | */ 83 | protected function rrSet(Net_DNS2_Packet &$packet) 84 | { 85 | if ($this->rdlength > 0) { 86 | 87 | // 88 | // unpack the values 89 | // 90 | $x = unpack('npreference/n4nodeid', $this->rdata); 91 | 92 | $this->preference = $x['preference']; 93 | 94 | // 95 | // build the node id 96 | // 97 | $this->nodeid = dechex($x['nodeid1']) . ':' . 98 | dechex($x['nodeid2']) . ':' . 99 | dechex($x['nodeid3']) . ':' . 100 | dechex($x['nodeid4']); 101 | 102 | return true; 103 | } 104 | 105 | return false; 106 | } 107 | 108 | /** 109 | * returns the rdata portion of the DNS packet 110 | * 111 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 112 | * compressed names 113 | * 114 | * @return mixed either returns a binary packed 115 | * string or null on failure 116 | * @access protected 117 | * 118 | */ 119 | protected function rrGet(Net_DNS2_Packet &$packet) 120 | { 121 | if (strlen($this->nodeid) > 0) { 122 | 123 | // 124 | // break out the node id 125 | // 126 | $n = explode(':', $this->nodeid); 127 | 128 | // 129 | // pack the data 130 | // 131 | return pack( 132 | 'n5', $this->preference, hexdec($n[0]), hexdec($n[1]), 133 | hexdec($n[2]), hexdec($n[3]) 134 | ); 135 | } 136 | 137 | return null; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Net/DNS2/RR/NIMLOC.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * NIMLOC Resource Record - undefined; the rdata is simply used as-is in it's 22 | * binary format, so not process has to be done. 23 | * 24 | */ 25 | class Net_DNS2_RR_NIMLOC extends Net_DNS2_RR 26 | { 27 | /** 28 | * method to return the rdata portion of the packet as a string 29 | * 30 | * @return string 31 | * @access protected 32 | * 33 | */ 34 | protected function rrToString() 35 | { 36 | return ''; 37 | } 38 | 39 | /** 40 | * parses the rdata portion from a standard DNS config line 41 | * 42 | * @param array $rdata a string split line of values for the rdata 43 | * 44 | * @return boolean 45 | * @access protected 46 | * 47 | */ 48 | protected function rrFromString(array $rdata) 49 | { 50 | return true; 51 | } 52 | 53 | /** 54 | * parses the rdata of the Net_DNS2_Packet object 55 | * 56 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 57 | * 58 | * @return boolean 59 | * @access protected 60 | * 61 | */ 62 | protected function rrSet(Net_DNS2_Packet &$packet) 63 | { 64 | return true; 65 | } 66 | 67 | /** 68 | * returns the rdata portion of the DNS packet 69 | * 70 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 71 | * compressed names 72 | * 73 | * @return mixed either returns a binary packed 74 | * string or null on failure 75 | * @access protected 76 | * 77 | */ 78 | protected function rrGet(Net_DNS2_Packet &$packet) 79 | { 80 | return $this->rdata; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Net/DNS2/RR/NS.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * NS Resource Record - RFC1035 section 3.3.11 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / NSDNAME / 25 | * / / 26 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 27 | * 28 | */ 29 | class Net_DNS2_RR_NS extends Net_DNS2_RR 30 | { 31 | /* 32 | * the hostname of the DNS server 33 | */ 34 | public $nsdname; 35 | 36 | /** 37 | * method to return the rdata portion of the packet as a string 38 | * 39 | * @return string 40 | * @access protected 41 | * 42 | */ 43 | protected function rrToString() 44 | { 45 | return $this->cleanString($this->nsdname) . '.'; 46 | } 47 | 48 | /** 49 | * parses the rdata portion from a standard DNS config line 50 | * 51 | * @param array $rdata a string split line of values for the rdata 52 | * 53 | * @return boolean 54 | * @access protected 55 | * 56 | */ 57 | protected function rrFromString(array $rdata) 58 | { 59 | $this->nsdname = $this->cleanString(array_shift($rdata)); 60 | return true; 61 | } 62 | 63 | /** 64 | * parses the rdata of the Net_DNS2_Packet object 65 | * 66 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 67 | * 68 | * @return boolean 69 | * @access protected 70 | * 71 | */ 72 | protected function rrSet(Net_DNS2_Packet &$packet) 73 | { 74 | if ($this->rdlength > 0) { 75 | 76 | $offset = $packet->offset; 77 | $this->nsdname = Net_DNS2_Packet::expand($packet, $offset); 78 | 79 | return true; 80 | } 81 | 82 | return false; 83 | } 84 | 85 | /** 86 | * returns the rdata portion of the DNS packet 87 | * 88 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 89 | * compressed names 90 | * 91 | * @return mixed either returns a binary packed 92 | * string or null on failure 93 | * @access protected 94 | * 95 | */ 96 | protected function rrGet(Net_DNS2_Packet &$packet) 97 | { 98 | if (strlen($this->nsdname) > 0) { 99 | 100 | return $packet->compress($this->nsdname, $packet->offset); 101 | } 102 | 103 | return null; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Net/DNS2/RR/NSEC.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * NSEC Resource Record - RFC3845 section 2.1 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * / Next Domain Name / 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 27 | * / List of Type Bit Map(s) / 28 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * 30 | */ 31 | class Net_DNS2_RR_NSEC extends Net_DNS2_RR 32 | { 33 | /* 34 | * The next owner name 35 | */ 36 | public $next_domain_name; 37 | 38 | /* 39 | * identifies the RRset types that exist at the NSEC RR's owner name. 40 | */ 41 | public $type_bit_maps = []; 42 | 43 | /** 44 | * method to return the rdata portion of the packet as a string 45 | * 46 | * @return string 47 | * @access protected 48 | * 49 | */ 50 | protected function rrToString() 51 | { 52 | $data = $this->cleanString($this->next_domain_name) . '.'; 53 | 54 | foreach ($this->type_bit_maps as $rr) { 55 | 56 | $data .= ' ' . $rr; 57 | } 58 | 59 | return $data; 60 | } 61 | 62 | /** 63 | * parses the rdata portion from a standard DNS config line 64 | * 65 | * @param array $rdata a string split line of values for the rdata 66 | * 67 | * @return boolean 68 | * @access protected 69 | * 70 | */ 71 | protected function rrFromString(array $rdata) 72 | { 73 | $this->next_domain_name = $this->cleanString(array_shift($rdata)); 74 | $this->type_bit_maps = $rdata; 75 | 76 | return true; 77 | } 78 | 79 | /** 80 | * parses the rdata of the Net_DNS2_Packet object 81 | * 82 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 83 | * 84 | * @return boolean 85 | * @access protected 86 | * 87 | */ 88 | protected function rrSet(Net_DNS2_Packet &$packet) 89 | { 90 | if ($this->rdlength > 0) { 91 | 92 | // 93 | // expand the next domain name 94 | // 95 | $offset = $packet->offset; 96 | $this->next_domain_name = Net_DNS2_Packet::expand($packet, $offset); 97 | 98 | // 99 | // parse out the RR's from the bitmap 100 | // 101 | $this->type_bit_maps = Net_DNS2_BitMap::bitMapToArray( 102 | substr($this->rdata, $offset - $packet->offset) 103 | ); 104 | 105 | return true; 106 | } 107 | 108 | return false; 109 | } 110 | 111 | /** 112 | * returns the rdata portion of the DNS packet 113 | * 114 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 115 | * compressed names 116 | * 117 | * @return mixed either returns a binary packed 118 | * string or null on failure 119 | * @access protected 120 | * 121 | */ 122 | protected function rrGet(Net_DNS2_Packet &$packet) 123 | { 124 | if (strlen($this->next_domain_name) > 0) { 125 | 126 | $data = $packet->compress($this->next_domain_name, $packet->offset); 127 | $bitmap = Net_DNS2_BitMap::arrayToBitMap($this->type_bit_maps); 128 | 129 | $packet->offset += strlen($bitmap); 130 | 131 | return $data . $bitmap; 132 | } 133 | 134 | return null; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Net/DNS2/RR/OPENPGPKEY.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.4.0 17 | * 18 | */ 19 | 20 | /** 21 | * OPENPGPKEY Resource Record - https://tools.ietf.org/html/draft-ietf-dane-openpgpkey-01 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * / / 26 | * / OpenPGP Public KeyRing / 27 | * / / 28 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 | * 30 | */ 31 | class Net_DNS2_RR_OPENPGPKEY extends Net_DNS2_RR 32 | { 33 | /* 34 | * the public key 35 | */ 36 | public $key; 37 | 38 | /** 39 | * method to return the rdata portion of the packet as a string 40 | * 41 | * @return string 42 | * @access protected 43 | * 44 | */ 45 | protected function rrToString() 46 | { 47 | return $this->key; 48 | } 49 | 50 | /** 51 | * parses the rdata portion from a standard DNS config line 52 | * 53 | * @param array $rdata a string split line of values for the rdata 54 | * 55 | * @return boolean 56 | * @access protected 57 | * 58 | */ 59 | protected function rrFromString(array $rdata) 60 | { 61 | $this->key = array_shift($rdata); 62 | 63 | return true; 64 | } 65 | 66 | /** 67 | * parses the rdata of the Net_DNS2_Packet object 68 | * 69 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 70 | * 71 | * @return boolean 72 | * @access protected 73 | * 74 | */ 75 | protected function rrSet(Net_DNS2_Packet &$packet) 76 | { 77 | if ($this->rdlength > 0) { 78 | 79 | $this->key = base64_encode(substr($this->rdata, 0, $this->rdlength)); 80 | 81 | return true; 82 | } 83 | 84 | return false; 85 | } 86 | 87 | /** 88 | * returns the rdata portion of the DNS packet 89 | * 90 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 91 | * compressed names 92 | * 93 | * @return mixed either returns a binary packed 94 | * string or null on failure 95 | * @access protected 96 | * 97 | */ 98 | protected function rrGet(Net_DNS2_Packet &$packet) 99 | { 100 | if (strlen($this->key) > 0) { 101 | 102 | $data = base64_decode($this->key); 103 | 104 | $packet->offset += strlen($data); 105 | 106 | return $data; 107 | } 108 | 109 | return null; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Net/DNS2/RR/PTR.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * PTR Resource Record - RFC1035 section 3.3.12 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / PTRDNAME / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * 27 | */ 28 | class Net_DNS2_RR_PTR extends Net_DNS2_RR 29 | { 30 | /* 31 | * the hostname of the PTR entry 32 | */ 33 | public $ptrdname; 34 | 35 | /** 36 | * method to return the rdata portion of the packet as a string 37 | * 38 | * @return string 39 | * @access protected 40 | * 41 | */ 42 | protected function rrToString() 43 | { 44 | return rtrim($this->ptrdname, '.') . '.'; 45 | } 46 | 47 | /** 48 | * parses the rdata portion from a standard DNS config line 49 | * 50 | * @param array $rdata a string split line of values for the rdata 51 | * 52 | * @return boolean 53 | * @access protected 54 | * 55 | */ 56 | protected function rrFromString(array $rdata) 57 | { 58 | $this->ptrdname = rtrim(implode(' ', $rdata), '.'); 59 | return true; 60 | } 61 | 62 | /** 63 | * parses the rdata of the Net_DNS2_Packet object 64 | * 65 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 66 | * 67 | * @return boolean 68 | * @access protected 69 | * 70 | */ 71 | protected function rrSet(Net_DNS2_Packet &$packet) 72 | { 73 | if ($this->rdlength > 0) { 74 | 75 | $offset = $packet->offset; 76 | $this->ptrdname = Net_DNS2_Packet::expand($packet, $offset); 77 | 78 | return true; 79 | } 80 | 81 | return false; 82 | } 83 | 84 | /** 85 | * returns the rdata portion of the DNS packet 86 | * 87 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 88 | * compressed names 89 | * 90 | * @return mixed either returns a binary packed 91 | * string or null on failure 92 | * @access protected 93 | * 94 | */ 95 | protected function rrGet(Net_DNS2_Packet &$packet) 96 | { 97 | if (strlen($this->ptrdname) > 0) { 98 | 99 | return $packet->compress($this->ptrdname, $packet->offset); 100 | } 101 | 102 | return null; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Net/DNS2/RR/PX.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * PX Resource Record - RFC2163 section 4 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | PREFERENCE | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / MAP822 / 27 | * / / 28 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 | * / MAPX400 / 30 | * / / 31 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-- 32 | * 33 | */ 34 | class Net_DNS2_RR_PX extends Net_DNS2_RR 35 | { 36 | /* 37 | * preference 38 | */ 39 | public $preference; 40 | 41 | /* 42 | * the RFC822 part of the MCGAM 43 | */ 44 | public $map822; 45 | 46 | /* 47 | * the X.400 part of the MCGAM 48 | */ 49 | public $mapx400; 50 | 51 | /** 52 | * method to return the rdata portion of the packet as a string 53 | * 54 | * @return string 55 | * @access protected 56 | * 57 | */ 58 | protected function rrToString() 59 | { 60 | return $this->preference . ' ' . $this->cleanString($this->map822) . '. ' . 61 | $this->cleanString($this->mapx400) . '.'; 62 | } 63 | 64 | /** 65 | * parses the rdata portion from a standard DNS config line 66 | * 67 | * @param array $rdata a string split line of values for the rdata 68 | * 69 | * @return boolean 70 | * @access protected 71 | * 72 | */ 73 | protected function rrFromString(array $rdata) 74 | { 75 | $this->preference = $rdata[0]; 76 | $this->map822 = $this->cleanString($rdata[1]); 77 | $this->mapx400 = $this->cleanString($rdata[2]); 78 | 79 | return true; 80 | } 81 | 82 | /** 83 | * parses the rdata of the Net_DNS2_Packet object 84 | * 85 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 86 | * 87 | * @return boolean 88 | * @access protected 89 | * 90 | */ 91 | protected function rrSet(Net_DNS2_Packet &$packet) 92 | { 93 | if ($this->rdlength > 0) { 94 | 95 | // 96 | // parse the preference 97 | // 98 | $x = unpack('npreference', $this->rdata); 99 | $this->preference = $x['preference']; 100 | 101 | $offset = $packet->offset + 2; 102 | 103 | $this->map822 = Net_DNS2_Packet::expand($packet, $offset); 104 | $this->mapx400 = Net_DNS2_Packet::expand($packet, $offset); 105 | 106 | return true; 107 | } 108 | 109 | return false; 110 | } 111 | 112 | /** 113 | * returns the rdata portion of the DNS packet 114 | * 115 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 116 | * compressed names 117 | * 118 | * @return mixed either returns a binary packed 119 | * string or null on failure 120 | * @access protected 121 | * 122 | */ 123 | protected function rrGet(Net_DNS2_Packet &$packet) 124 | { 125 | if (strlen($this->map822) > 0) { 126 | 127 | $data = pack('n', $this->preference); 128 | $packet->offset += 2; 129 | 130 | $data .= $packet->compress($this->map822, $packet->offset); 131 | $data .= $packet->compress($this->mapx400, $packet->offset); 132 | 133 | return $data; 134 | } 135 | 136 | return null; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Net/DNS2/RR/RP.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * RP Resource Record - RFC1183 section 2.2 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / mboxdname / 25 | * / / 26 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 27 | * / txtdname / 28 | * / / 29 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 30 | * 31 | */ 32 | class Net_DNS2_RR_RP extends Net_DNS2_RR 33 | { 34 | /* 35 | * mailbox for the responsible person 36 | */ 37 | public $mboxdname; 38 | 39 | /* 40 | * is a domain name for which TXT RR's exists 41 | */ 42 | public $txtdname; 43 | 44 | /** 45 | * method to return the rdata portion of the packet as a string 46 | * 47 | * @return string 48 | * @access protected 49 | * 50 | */ 51 | protected function rrToString() 52 | { 53 | return $this->cleanString($this->mboxdname) . '. ' . $this->cleanString($this->txtdname) . '.'; 54 | } 55 | 56 | /** 57 | * parses the rdata portion from a standard DNS config line 58 | * 59 | * @param array $rdata a string split line of values for the rdata 60 | * 61 | * @return boolean 62 | * @access protected 63 | * 64 | */ 65 | protected function rrFromString(array $rdata) 66 | { 67 | $this->mboxdname = $this->cleanString($rdata[0]); 68 | $this->txtdname = $this->cleanString($rdata[1]); 69 | 70 | return true; 71 | } 72 | 73 | /** 74 | * parses the rdata of the Net_DNS2_Packet object 75 | * 76 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 77 | * 78 | * @return boolean 79 | * @access protected 80 | * 81 | */ 82 | protected function rrSet(Net_DNS2_Packet &$packet) 83 | { 84 | if ($this->rdlength > 0) { 85 | 86 | $offset = $packet->offset; 87 | 88 | $this->mboxdname = Net_DNS2_Packet::expand($packet, $offset, true); 89 | $this->txtdname = Net_DNS2_Packet::expand($packet, $offset); 90 | 91 | return true; 92 | } 93 | 94 | return false; 95 | } 96 | 97 | /** 98 | * returns the rdata portion of the DNS packet 99 | * 100 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 101 | * compressed names 102 | * 103 | * @return mixed either returns a binary packed 104 | * string or null on failure 105 | * @access protected 106 | * 107 | */ 108 | protected function rrGet(Net_DNS2_Packet &$packet) 109 | { 110 | if (strlen($this->mboxdname) > 0) { 111 | 112 | return $packet->compress($this->mboxdname, $packet->offset) . 113 | $packet->compress($this->txtdname, $packet->offset); 114 | } 115 | 116 | return null; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Net/DNS2/RR/RT.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * RT Resource Record - RFC1183 section 3.3 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * | preference | 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / intermediate-host / 27 | * / / 28 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 29 | * 30 | */ 31 | class Net_DNS2_RR_RT extends Net_DNS2_RR 32 | { 33 | /* 34 | * the preference of this route 35 | */ 36 | public $preference; 37 | 38 | /* 39 | * host which will servce as an intermediate in reaching the owner host 40 | */ 41 | public $intermediatehost; 42 | 43 | /** 44 | * method to return the rdata portion of the packet as a string 45 | * 46 | * @return string 47 | * @access protected 48 | * 49 | */ 50 | protected function rrToString() 51 | { 52 | return $this->preference . ' ' . 53 | $this->cleanString($this->intermediatehost) . '.'; 54 | } 55 | 56 | /** 57 | * parses the rdata portion from a standard DNS config line 58 | * 59 | * @param array $rdata a string split line of values for the rdata 60 | * 61 | * @return boolean 62 | * @access protected 63 | * 64 | */ 65 | protected function rrFromString(array $rdata) 66 | { 67 | $this->preference = $rdata[0]; 68 | $this->intermediatehost = $this->cleanString($rdata[1]); 69 | 70 | return true; 71 | } 72 | 73 | /** 74 | * parses the rdata of the Net_DNS2_Packet object 75 | * 76 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 77 | * 78 | * @return boolean 79 | * @access protected 80 | * 81 | */ 82 | protected function rrSet(Net_DNS2_Packet &$packet) 83 | { 84 | if ($this->rdlength > 0) { 85 | 86 | // 87 | // unpack the preference 88 | // 89 | $x = unpack('npreference', $this->rdata); 90 | 91 | $this->preference = $x['preference']; 92 | $offset = $packet->offset + 2; 93 | 94 | $this->intermediatehost = Net_DNS2_Packet::expand($packet, $offset); 95 | 96 | return true; 97 | } 98 | 99 | return false; 100 | } 101 | 102 | /** 103 | * returns the rdata portion of the DNS packet 104 | * 105 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 106 | * compressed names 107 | * 108 | * @return mixed either returns a binary packed 109 | * string or null on failure 110 | * @access protected 111 | * 112 | */ 113 | protected function rrGet(Net_DNS2_Packet &$packet) 114 | { 115 | if (strlen($this->intermediatehost) > 0) { 116 | 117 | $data = pack('n', $this->preference); 118 | $packet->offset += 2; 119 | 120 | $data .= $packet->compress($this->intermediatehost, $packet->offset); 121 | 122 | return $data; 123 | } 124 | 125 | return null; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Net/DNS2/RR/SMIMEA.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.4.2 17 | * 18 | */ 19 | 20 | /** 21 | * The SMIMEA RR is implemented exactly like the TLSA record, so 22 | * for now we just extend the TLSA RR and use it. 23 | * 24 | */ 25 | class Net_DNS2_RR_SMIMEA extends Net_DNS2_RR_TLSA 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /Net/DNS2/RR/SPF.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * The SPF RR is implemented exactly like the TXT record, so 22 | * for now we just extend the TXT RR and use it. 23 | * 24 | */ 25 | class Net_DNS2_RR_SPF extends Net_DNS2_RR_TXT 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /Net/DNS2/RR/TA.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.2.0 17 | * 18 | */ 19 | 20 | /** 21 | * The TA RR is implemented exactly like the DS record, so 22 | * for now we just extend the DS RR and use it. 23 | * 24 | */ 25 | class Net_DNS2_RR_TA extends Net_DNS2_RR_DS 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /Net/DNS2/RR/TALINK.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * @category Networking 9 | * @package Net_DNS2 10 | * @author Mike Pultz 11 | * @copyright 2020 Mike Pultz 12 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 13 | * @link https://netdns2.com/ 14 | * @since File available since Release 1.2.0 15 | * 16 | */ 17 | 18 | /** 19 | * TALINK Resource Record - DNSSEC Trust Anchor 20 | * 21 | * http://tools.ietf.org/id/draft-ietf-dnsop-dnssec-trust-history-00.txt 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / PREVIOUS / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * / NEXT / 27 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 28 | * 29 | */ 30 | class Net_DNS2_RR_TALINK extends Net_DNS2_RR 31 | { 32 | /* 33 | * the previous domain name 34 | */ 35 | public $previous; 36 | 37 | /* 38 | * the next domain name 39 | */ 40 | public $next; 41 | 42 | /** 43 | * method to return the rdata portion of the packet as a string 44 | * 45 | * @return string 46 | * @access protected 47 | * 48 | */ 49 | protected function rrToString() 50 | { 51 | return $this->cleanString($this->previous) . '. ' . 52 | $this->cleanString($this->next) . '.'; 53 | } 54 | 55 | /** 56 | * parses the rdata portion from a standard DNS config line 57 | * 58 | * @param array $rdata a string split line of values for the rdata 59 | * 60 | * @return boolean 61 | * @access protected 62 | * 63 | */ 64 | protected function rrFromString(array $rdata) 65 | { 66 | $this->previous = $this->cleanString($rdata[0]); 67 | $this->next = $this->cleanString($rdata[1]); 68 | 69 | return true; 70 | } 71 | 72 | /** 73 | * parses the rdata of the Net_DNS2_Packet object 74 | * 75 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 76 | * 77 | * @return boolean 78 | * @access protected 79 | * 80 | */ 81 | protected function rrSet(Net_DNS2_Packet &$packet) 82 | { 83 | if ($this->rdlength > 0) { 84 | 85 | $offset = $packet->offset; 86 | 87 | $this->previous = Net_DNS2_Packet::label($packet, $offset); 88 | $this->next = Net_DNS2_Packet::label($packet, $offset); 89 | 90 | return true; 91 | } 92 | 93 | return false; 94 | } 95 | 96 | /** 97 | * returns the rdata portion of the DNS packet 98 | * 99 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 100 | * compressed names 101 | * 102 | * @return mixed either returns a binary packed 103 | * string or null on failure 104 | * @access protected 105 | * 106 | */ 107 | protected function rrGet(Net_DNS2_Packet &$packet) 108 | { 109 | if ( (strlen($this->previous) > 0) || (strlen($this->next) > 0) ) { 110 | 111 | $data = chr(strlen($this->previous)) . $this->previous . 112 | chr(strlen($this->next)) . $this->next; 113 | 114 | $packet->offset += strlen($data); 115 | 116 | return $data; 117 | } 118 | 119 | return null; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Net/DNS2/RR/TXT.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * TXT Resource Record - RFC1035 section 3.3.14 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / TXT-DATA / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * 27 | */ 28 | class Net_DNS2_RR_TXT extends Net_DNS2_RR 29 | { 30 | /* 31 | * an array of the text strings 32 | */ 33 | public $text = []; 34 | 35 | /** 36 | * method to return the rdata portion of the packet as a string 37 | * 38 | * @return string 39 | * @access protected 40 | * 41 | */ 42 | protected function rrToString() 43 | { 44 | if (cacti_sizeof($this->text) == 0) { 45 | return '""'; 46 | } 47 | 48 | $data = ''; 49 | 50 | foreach ($this->text as $t) { 51 | 52 | $data .= $this->formatString($t) . ' '; 53 | } 54 | 55 | return trim($data); 56 | } 57 | 58 | /** 59 | * parses the rdata portion from a standard DNS config line 60 | * 61 | * @param array $rdata a string split line of values for the rdata 62 | * 63 | * @return boolean 64 | * @access protected 65 | * 66 | */ 67 | protected function rrFromString(array $rdata) 68 | { 69 | $data = $this->buildString($rdata); 70 | if (cacti_sizeof($data) > 0) { 71 | 72 | $this->text = $data; 73 | } 74 | 75 | return true; 76 | } 77 | 78 | /** 79 | * parses the rdata of the Net_DNS2_Packet object 80 | * 81 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 82 | * 83 | * @return boolean 84 | * @access protected 85 | * 86 | */ 87 | protected function rrSet(Net_DNS2_Packet &$packet) 88 | { 89 | if ($this->rdlength > 0) { 90 | 91 | $length = $packet->offset + $this->rdlength; 92 | $offset = $packet->offset; 93 | 94 | while ($length > $offset) { 95 | 96 | $this->text[] = Net_DNS2_Packet::label($packet, $offset); 97 | } 98 | 99 | return true; 100 | } 101 | 102 | return false; 103 | } 104 | 105 | /** 106 | * returns the rdata portion of the DNS packet 107 | * 108 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 109 | * compressed names 110 | * 111 | * @return mixed either returns a binary packed 112 | * string or null on failure 113 | * @access protected 114 | * 115 | */ 116 | protected function rrGet(Net_DNS2_Packet &$packet) 117 | { 118 | $data = null; 119 | 120 | foreach ($this->text as $t) { 121 | 122 | $data .= chr(strlen($t)) . $t; 123 | } 124 | 125 | $packet->offset += strlen($data); 126 | 127 | return $data; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Net/DNS2/RR/TYPE65534.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.2.5 17 | * 18 | */ 19 | 20 | /** 21 | * TYPE65534 - Private space 22 | * 23 | * Since Bind 9.8 beta, it use a private recode as documented 24 | * in the Bind ARM, chapter 4, "Private-type records. 25 | * Basically they store signing process state. 26 | * 27 | */ 28 | class Net_DNS2_RR_TYPE65534 extends Net_DNS2_RR 29 | { 30 | /* 31 | * The Private data field 32 | */ 33 | public $private_data; 34 | 35 | /** 36 | * method to return the rdata portion of the packet as a string 37 | * 38 | * @return string 39 | * @access protected 40 | * 41 | */ 42 | protected function rrToString() 43 | { 44 | return base64_encode($this->private_data); 45 | } 46 | 47 | /** 48 | * parses the rdata portion from a standard DNS config line 49 | * 50 | * @param array $rdata a string split line of values for the rdata 51 | * 52 | * @return boolean 53 | * @access protected 54 | * 55 | */ 56 | protected function rrFromString(array $rdata) 57 | { 58 | $this->private_data = base64_decode(implode('', $rdata)); 59 | 60 | return true; 61 | } 62 | 63 | /** 64 | * parses the rdata of the Net_DNS2_Packet object 65 | * 66 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 67 | * 68 | * @return boolean 69 | * @access protected 70 | * 71 | */ 72 | protected function rrSet(Net_DNS2_Packet &$packet) 73 | { 74 | if ($this->rdlength > 0) { 75 | $this->private_data = $this->rdata; 76 | 77 | return true; 78 | } 79 | 80 | return false; 81 | } 82 | 83 | /** 84 | * returns the rdata portion of the DNS packet 85 | * 86 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 87 | * compressed names 88 | * 89 | * @return mixed either returns a binary packed 90 | * string or null on failure 91 | * @access protected 92 | * 93 | */ 94 | protected function rrGet(Net_DNS2_Packet &$packet) 95 | { 96 | if (strlen($this->private_data) > 0) { 97 | 98 | $data = $this->private_data; 99 | 100 | $packet->offset += strlen($data); 101 | 102 | return $data; 103 | } 104 | 105 | return null; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Net/DNS2/RR/URI.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 1.2.0 17 | * 18 | */ 19 | 20 | /** 21 | * URI Resource Record - http://tools.ietf.org/html/draft-faltstrom-uri-06 22 | * 23 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 24 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 | * | Priority | Weight | 26 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 27 | * / / 28 | * / Target / 29 | * / / 30 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 31 | * 32 | */ 33 | class Net_DNS2_RR_URI extends Net_DNS2_RR 34 | { 35 | /* 36 | * The priority of this target host. 37 | */ 38 | public $priority; 39 | 40 | /* 41 | * a relative weight for entries with the same priority 42 | */ 43 | public $weight; 44 | 45 | /* 46 | * The domain name of the target host 47 | */ 48 | public $target; 49 | 50 | /** 51 | * method to return the rdata portion of the packet as a string 52 | * 53 | * @return string 54 | * @access protected 55 | * 56 | */ 57 | protected function rrToString() 58 | { 59 | // 60 | // presentation format has double quotes (") around the target. 61 | // 62 | return $this->priority . ' ' . $this->weight . ' "' . $this->target . '"'; 63 | } 64 | 65 | /** 66 | * parses the rdata portion from a standard DNS config line 67 | * 68 | * @param array $rdata a string split line of values for the rdata 69 | * 70 | * @return boolean 71 | * @access protected 72 | * 73 | */ 74 | protected function rrFromString(array $rdata) 75 | { 76 | $this->priority = $rdata[0]; 77 | $this->weight = $rdata[1]; 78 | $this->target = trim(strtolower(trim($rdata[2])), '"'); 79 | 80 | return true; 81 | } 82 | 83 | /** 84 | * parses the rdata of the Net_DNS2_Packet object 85 | * 86 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 87 | * 88 | * @return boolean 89 | * @access protected 90 | * 91 | */ 92 | protected function rrSet(Net_DNS2_Packet &$packet) 93 | { 94 | if ($this->rdlength > 0) { 95 | 96 | // 97 | // unpack the priority and weight 98 | // 99 | $x = unpack('npriority/nweight/a*target', $this->rdata); 100 | 101 | $this->priority = $x['priority']; 102 | $this->weight = $x['weight']; 103 | $this->target = $x['target']; 104 | 105 | return true; 106 | } 107 | 108 | return false; 109 | } 110 | 111 | /** 112 | * returns the rdata portion of the DNS packet 113 | * 114 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 115 | * compressed names 116 | * 117 | * @return mixed either returns a binary packed 118 | * string or null on failure 119 | * @access protected 120 | * 121 | */ 122 | protected function rrGet(Net_DNS2_Packet &$packet) 123 | { 124 | if (strlen($this->target) > 0) { 125 | 126 | $data = pack('nna*', $this->priority, $this->weight, $this->target); 127 | 128 | $packet->offset += strlen($data); 129 | 130 | return $data; 131 | } 132 | 133 | return null; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Net/DNS2/RR/X25.php: -------------------------------------------------------------------------------- 1 | . All rights reserved. 7 | * 8 | * See LICENSE for more details. 9 | * 10 | * @category Networking 11 | * @package Net_DNS2 12 | * @author Mike Pultz 13 | * @copyright 2020 Mike Pultz 14 | * @license http://www.opensource.org/licenses/bsd-license.php BSD License 15 | * @link https://netdns2.com/ 16 | * @since File available since Release 0.6.0 17 | * 18 | */ 19 | 20 | /** 21 | * X25 Resource Record - RFC1183 section 3.1 22 | * 23 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 24 | * / PSDN-address / 25 | * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 26 | * 27 | */ 28 | class Net_DNS2_RR_X25 extends Net_DNS2_RR 29 | { 30 | /* 31 | * The PSDN address 32 | */ 33 | public $psdnaddress; 34 | 35 | /** 36 | * method to return the rdata portion of the packet as a string 37 | * 38 | * @return string 39 | * @access protected 40 | * 41 | */ 42 | protected function rrToString() 43 | { 44 | return $this->formatString($this->psdnaddress); 45 | } 46 | 47 | /** 48 | * parses the rdata portion from a standard DNS config line 49 | * 50 | * @param array $rdata a string split line of values for the rdata 51 | * 52 | * @return boolean 53 | * @access protected 54 | * 55 | */ 56 | protected function rrFromString(array $rdata) 57 | { 58 | $data = $this->buildString($rdata); 59 | if (cacti_sizeof($data) == 1) { 60 | 61 | $this->psdnaddress = $data[0]; 62 | return true; 63 | } 64 | 65 | return false; 66 | } 67 | 68 | /** 69 | * parses the rdata of the Net_DNS2_Packet object 70 | * 71 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet to parse the RR from 72 | * 73 | * @return boolean 74 | * @access protected 75 | * 76 | */ 77 | protected function rrSet(Net_DNS2_Packet &$packet) 78 | { 79 | if ($this->rdlength > 0) { 80 | 81 | $this->psdnaddress = Net_DNS2_Packet::label($packet, $packet->offset); 82 | return true; 83 | } 84 | 85 | return false; 86 | } 87 | 88 | /** 89 | * returns the rdata portion of the DNS packet 90 | * 91 | * @param Net_DNS2_Packet &$packet a Net_DNS2_Packet packet use for 92 | * compressed names 93 | * 94 | * @return mixed either returns a binary packed 95 | * string or null on failure 96 | * @access protected 97 | * 98 | */ 99 | protected function rrGet(Net_DNS2_Packet &$packet) 100 | { 101 | if (strlen($this->psdnaddress) > 0) { 102 | 103 | $data = chr(strlen($this->psdnaddress)) . $this->psdnaddress; 104 | 105 | $packet->offset += strlen($data); 106 | 107 | return $data; 108 | } 109 | 110 | return null; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Net/LICENSE: -------------------------------------------------------------------------------- 1 | Net_DNS2 - DNS Library for handling lookups and updates. 2 | 3 | Copyright (c) 2010-2020, Mike Pultz . 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in 15 | the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | * Neither the name of Mike Pultz nor the names of his contributors 19 | may be used to endorse or promote products derived from this 20 | software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 | POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /Net/README.md: -------------------------------------------------------------------------------- 1 | # Net\_DNS2 - Native PHP DNS Resolver and Updater # 2 | 3 | ### The main features for this package include: ### 4 | 5 | * Increased performance; most requests are 2-10x faster than Net\_DNS 6 | * Near drop-in replacement for Net\_DNS 7 | * Uses modern PHP classes and exceptions 8 | * Support for IPv4 and IPv6, TCP and UDP sockets. 9 | * Includes a separate, more intuitive "Updater" class for handling dynamic update 10 | * Support zone signing using TSIG and SIG(0) for updates and zone transfers 11 | * Includes a local cache using shared memory or flat file to improve performance 12 | * includes many more RR's, including DNSSEC RR's. 13 | 14 | 15 | ## Installing Net\_DNS2 ## 16 | 17 | You can download it directly from PEAR: http://pear.php.net/package/Net_DNS2 18 | 19 | ``` 20 | pear install Net_DNS2 21 | ``` 22 | 23 | Or you can require it directly via Composer: https://packagist.org/packages/pear/net_dns2 24 | 25 | ``` 26 | composer require pear/net_dns2 27 | ``` 28 | 29 | Or download the source above. 30 | 31 | ## Requirements ## 32 | 33 | * PHP 5.4+ 34 | * The PHP INI setting `mbstring.func_overload` equals 0, 1, 4, or 5. 35 | 36 | 37 | ## Using Net\_DNS2 ## 38 | 39 | See the Net\_DNS2 Website for more details - https://netdns2.com/ 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mactrack 2 | 3 | The MacTrack plugin is designed to scan network switches, routers and 4 | intelligent hubs for connected devices, and record their location either based 5 | upon the portname or alias of the switch or hub. It also attempts to discover 6 | the ip address of the mac address from the routers included in the MacTrack 7 | database. MacTrack can also use arpwatch to gether IP to MAC address 8 | associations. 9 | 10 | MacTrack has the ability to also notify admins or security personnel when the 11 | MAC address of a missing or stolen computer re-appears on the network. This can 12 | be helpful in recovering lost equipment. Through MacTrack's interface 13 | monitoring feature, a Network Administrator can get a very good idea of where 14 | utilization is, where there are errors, etc within their network. 15 | 16 | ## Features 17 | 18 | * Scans Devices 19 | 20 | * Finds Macs 21 | 22 | * Associates Macs with their IP's 23 | 24 | * Keeps a Nice Inventory of Port Counts 25 | 26 | * Finds Stolen/Lost PC's 27 | 28 | * Tells you when someone is connected who shouldn't be 29 | 30 | ## Prerequisites 31 | 32 | The MacTrack on GitHub requires Cacti 1.2.14 as a minimum. 33 | 34 | ## Installation 35 | 36 | Just like any Cacti plugin, untar the package to the Cacti plugins directory, 37 | rename the directory to 'mactrack', and then from Cacti's Plugin Management 38 | interface, Install and Enable the plugin. 39 | 40 | ## Documentation 41 | 42 | Some basic documentation and steps to follow as well as some troubleshooting 43 | tips you can find on the [MacTrack 44 | Wiki](https://github.com/Cacti/plugin_mactrack/wiki)! 45 | 46 | ## Workflow 47 | 48 | Configure mactrack - Console -> Settings -> Mactrack tab 49 | Add Mactrack Site - Console -> Mactrack -> Sites 50 | Add/import devices - Console -> Mactrack -> Devices -> Add device or Management -> Choose host -> Import into Mactrack Database 51 | Create new or enable prepared Device Types - Console -> Mactrack -> Device Types 52 | 53 | ## Bugs and Feature Enhancements 54 | 55 | Bug and feature enhancements for the Mactrack plugin are handled in GitHub. You 56 | may want try first searching the Cacti forums for a solution before creating an 57 | issue in GitHub. 58 | 59 | ## Special Thanks 60 | 61 | * *Jimmy Conner (cigamit)* 62 | 63 | For bringing the plugin architecture to the world of Cacti and providing 64 | continual support of my development efforts. 65 | 66 | * *Larry Adams (TheWitness)* 67 | 68 | For supporting this monster on his free time even though he no longer works in 69 | the network space. 70 | 71 | * *Reinhard Scheck (gandalf)* 72 | 73 | The European Cacti strongman and Cacti/RRDtool guru. Thanks for keeping me 74 | honest. 75 | 76 | * *Cacti Users Everywhere* 77 | 78 | For just using Cacti. Thanks for giving me a hobby to live for. 79 | 80 | ----------------------------------------------- 81 | Copyright (c) 2004-2024 - The Cacti Group, Inc. 82 | -------------------------------------------------------------------------------- /docs/CHANGELOG: -------------------------------------------------------------------------------- 1 | Cacti - MacTrack CHANGELOG 2 | 3 | 3.0 4 | -bug#0002310: SNMP Option Set Call to undefined function mactrack_save_button() 5 | 6 | 1.0 7 | -feature: Make mac_track_temp_ports and mac_track_ips memory tables for faster performance 8 | -bug: Fix all export functions. Only allow upto 10k records to be exported at any time. 9 | -bug: Allow import to work with csv files that are 1) out of order, 2) contain extra columns 10 | -bug: Initial polling does not start automatically as it should 11 | 12 | Pre-Beta: 13 | -bug: Complete implementation of the export sites. Can't believe that I did not finish this before I changed jobs 14 | -bug: Fix Devices and Device Types in order to export all rows, not just the current display 15 | -bug: Modify database structure to create distinction between operating ports and active mac addresses 16 | -bug: Correct the valid_snmp_host function that was incorrectly allowing a host to change snmp communities when it was down 17 | -bug: Correct the storing of sysObjectID into the mac_track_devices table in Windows 18 | -bug: Change some table Pk's to be more consistent with actual deployments 19 | -bug: Allow changing of database maintenance time to work as expected 20 | -bug: Do not include bridge root ports in data collection 21 | -bug: Detect ignore ports properly on Cabletron SEHI's 22 | -bug: Fix Enable/Disable device support 23 | -bug: Fix raw DNS UDP datagram creation code 24 | -bug: Don't clear filters for other reports when clearing for one 25 | -bug: Fix the utilities section of MacTrack. Did not look too good 26 | -bug: Correct issue where Hex IP address was not being converted properly 27 | -feature: Implement Device sorting from the console 28 | -feature: Implement ignorePorts processing for pre-defined functions 29 | -feature: Implement device and device type import functions 30 | -feature: Implement device, device type, and port result export functions 31 | -feature: Implement scanning_function registration in the vendor include files 32 | -feature: Implement row's pulldown feature in MacTrack reporting interface 33 | -feature: Use Cacti's builtin snmp functions instead of php_snmp extension 34 | -feature: Fully implement device_types support as intended in the alpha release 35 | -feature: Add the snmp_port to the devices table for those who have to poke holes in firewall's to gain access to devices 36 | -feature: Implement ignorePorts processing for pre-defined functions 37 | -feature: Implement device and device type import functions 38 | -feature: Implement device, device type, and port result export functions 39 | -feature: Implement scanning_function registration in the vendor include files 40 | -feature: Implement row's pulldown feature in MacTrack Viewer 41 | -feature: Use Cacti's builtin snmp functions instead of php_snmp extension 42 | -feature: Fully implement device_types support as intended in the alpha release 43 | -feature: Allow the detection of Cisco Voice VLAN's properly for some model Cisco switches 44 | -feature: Add new module "mactrack_resolver.php" to perform reverse DNS (1 thread for now) 45 | -feature: Add DNS hostname to MacTrack reporting interface 46 | -feature: Add MacTrack reporting interface. Add sites, and devices reports. Allow export of Devices and Macs/IP's 47 | -feature: Add filtering of sites in the new reporting interface 48 | -feature: Major revamp to Reporting interface, some bug fixes and adding of IP's to Device table. 49 | -bug: Changed devicetype and availability ERROR's to WARNINGS 50 | -bug: Don't display DNS Hostname or search from it if you are not performing reverse lookup 51 | -bug: Correct row's counter in Detailed Site Report View 52 | -feature: Allow the administrator to dynamically change the number of concurrent processes 53 | -bug: Perform Database Maintenance as it should be 54 | -bug: When in site detail, don't give the option to edit a site. It does not make sense 55 | -feature: Add export to IP Range Report. 56 | -bug: Fix Max/Current IP's count in IP Range Report. 57 | -feature: Add Refresh Selector to Tracking Collection Status Page 58 | -bug: Do not rescan using a Rotational Readstring that was already used by default 59 | -bug: Device Import error message showing incorrect header field 60 | -feature: Modify the "mac_track_temp_ports" and "mac_track_ips" tables to be HEAP Type, meaning they only reside in memory 61 | 62 | ----------------------------------------------- 63 | Copyright (c) 2004-2023 - The Cacti Group, Inc. 64 | -------------------------------------------------------------------------------- /docs/cacti_device_type_xport.csv: -------------------------------------------------------------------------------- 1 | "vendor","description","device_type","sysDescr_match","sysObjectID_match","scanning_function","ip_scanning_function","dot1x_scanning_function","serial_number_oid","lowPort","highPort" 2 | "Cisco","2960 Switch Base","2","C2960-LANBASEK9-M","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 3 | "Cisco","2960 Switch Lite","2","C2960-LANLITEK9-M","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 4 | "Cisco","43xx Router","3","ISR Software","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 5 | "Cisco","45xx Switch","2","4500","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 6 | "Cisco","45xx Switch","2","cat4000","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 7 | "Cisco","6513 Switch/Router","2","s72033_rp","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 8 | "Cisco","94xx Switch","2","CAT9K_IOSXE","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 9 | "Cisco","ASR Router","3","PPC_LINUX_IOSD-IPBAS","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 10 | "Cisco","Blade Center 10/100","2","CIGESM-I6K2L2Q4-M","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 11 | "Cisco","BladeCenter2 10G","2","CBS31X0","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 12 | "Cisco","C2600 Router","3","C2600","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 13 | "Cisco","C2800 Router","3","C2800","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 14 | "Cisco","C2900 Router","3","C2900","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 15 | "Cisco","C2950 Switch","2","C2950","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 16 | "Cisco","C2960S Switch","2","C2960S","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 17 | "Cisco","C2960X Switch","2","C2960X","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","get_cisco_dot1x_table","","0","0" 18 | "Cisco","C3550 Switch","2","C3550","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 19 | "Cisco","C3560 Switch","2","C3560","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 20 | "Cisco","C3750 Switch","2","C3750","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 21 | "Cisco","C3900 Router","3","C3900","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 22 | "Cisco","C3x50 Switch","2","CAT3K","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 23 | "Cisco","C870 Router","3","C870","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 24 | "Cisco","CAT3K_CAA-UNIVERSALK9-M","2","CAT3K_CAA-UNIVERSALK9-M","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 25 | "Cisco","CAT4500","2","cat4500","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 26 | "Cisco","CE500 Switch","1","CE500","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 27 | "Cisco","Cisco ASA","3","Adaptive Security Appliance","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 28 | "Dell","DellBladeCenter","2","Ethernet Switch","","get_dell_dot1q_switch_ports","get_CTAlias_table","0","","0","0" 29 | "IBM","IBM Flex System Fabric","2","IBM Flex System Fabric","","get_generic_dot1q_switch_ports","get_standard_arp_table","0","","0","0" 30 | "Cisco","Nexus 5K","1","n5000","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0",".1.3.6.1.4.1.9.12.3.1.3.1038","0","0" 31 | "Cisco","Nexus 7K","2","n7000","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0",".1.3.6.1.4.1.9.12.3.1.3.932","0","0" 32 | "Cisco","Nexus 9K","2","NX-OS","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0",".1.3.6.1.4.1.9.12.3.1.3.1850","0","0" 33 | "Cisco","Nexus Generic","2","nxos","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 34 | "HP","ProCurve Switch","2","ProCurve Switch","","get_procurve_ngi_switch_ports","get_standard_arp_table","0","","0","0" 35 | "Cisco","VG224","3","vg224","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 36 | "Cisco","VG3X0","3","VG3X0","","get_IOS_dot1dTpFdbEntry_ports","get_standard_arp_table","0","","0","0" 37 | -------------------------------------------------------------------------------- /docs/images/mactrack_wiki_dt-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mactrack_wiki_dt-1.png -------------------------------------------------------------------------------- /docs/images/mactrack_wiki_dt-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mactrack_wiki_dt-2.png -------------------------------------------------------------------------------- /docs/images/mactrack_wiki_dt-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mactrack_wiki_dt-3.png -------------------------------------------------------------------------------- /docs/images/mactrack_wiki_sites-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mactrack_wiki_sites-1.png -------------------------------------------------------------------------------- /docs/images/mt_devices-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_devices-1.png -------------------------------------------------------------------------------- /docs/images/mt_dts_csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_dts_csv.png -------------------------------------------------------------------------------- /docs/images/mt_dts_export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_dts_export.png -------------------------------------------------------------------------------- /docs/images/mt_dts_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_dts_import.png -------------------------------------------------------------------------------- /docs/images/mt_dts_import_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_dts_import_results.png -------------------------------------------------------------------------------- /docs/images/mt_import_device-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_import_device-1.png -------------------------------------------------------------------------------- /docs/images/mt_import_device-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_import_device-2.png -------------------------------------------------------------------------------- /docs/images/mt_import_device-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_import_device-3.png -------------------------------------------------------------------------------- /docs/images/mt_import_device-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_import_device-4.png -------------------------------------------------------------------------------- /docs/images/mt_import_oui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_import_oui.png -------------------------------------------------------------------------------- /docs/images/mt_view_devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_devices.png -------------------------------------------------------------------------------- /docs/images/mt_view_dot1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_dot1x.png -------------------------------------------------------------------------------- /docs/images/mt_view_interfaces.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_interfaces.png -------------------------------------------------------------------------------- /docs/images/mt_view_ipaddr_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_ipaddr_1.png -------------------------------------------------------------------------------- /docs/images/mt_view_iprange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_iprange.png -------------------------------------------------------------------------------- /docs/images/mt_view_ips.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_ips.png -------------------------------------------------------------------------------- /docs/images/mt_view_macs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_macs.png -------------------------------------------------------------------------------- /docs/images/mt_view_sites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/docs/images/mt_view_sites.png -------------------------------------------------------------------------------- /images/create_device.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/images/create_device.gif -------------------------------------------------------------------------------- /images/disable_collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/images/disable_collection.png -------------------------------------------------------------------------------- /images/edit_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/images/edit_object.png -------------------------------------------------------------------------------- /images/enable_collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/images/enable_collection.png -------------------------------------------------------------------------------- /images/graph_page_top.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cacti/plugin_mactrack/8d5524922b3d94ce1d8a401e486dae7bb5ea4c41/images/graph_page_top.gif -------------------------------------------------------------------------------- /images/index.php: -------------------------------------------------------------------------------- 1 | /dev/null` 28 | if [ $? -gt 0 ] 29 | then 30 | echo "ERROR: unable to locate realpath" 31 | echo 32 | echo "Linux: Confirm coreutils installed" 33 | echo "Mac: Brew install coreutils" 34 | echo 35 | exit 1 36 | fi 37 | BASE_PATH=`${REALPATH_BIN} ${0} | sed s#/locales/${SCRIPT_NAME}##` 38 | 39 | # locate xgettext for processing 40 | XGETTEXT_BIN=`which xgettext 2>/dev/null` 41 | if [ $? -gt 0 ] 42 | then 43 | echo "ERROR: Unable to locate xgettext" 44 | echo 45 | echo "Linux: Install GNU gettext" 46 | echo "Mac: Brew install GNU gettext" 47 | echo 48 | exit 1 49 | fi 50 | 51 | # Update main gettext POT file with application strings 52 | echo "Updating Cacti language gettext language file..." 53 | cd ${BASE_PATH} 54 | 55 | ${XGETTEXT_BIN} --no-wrap --copyright-holder="The Cacti Group" --package-name="Cacti" --package-version=`cat include/cacti_version` --msgid-bugs-address="developers@cacti.net" -F -k__gettext -k__ -k__n:1,2 -k__x:1c,2 -k__xn:1c,2,3 -k__esc -k__esc_n:1,2 -k__esc_x:1c,2 -k__esc_xn:1c,2,3 -k__date -o locales/po/cacti.pot `find . -maxdepth 2 -name \*.php` 56 | 57 | sed -i 's/FULL NAME /Cacti Developers /g' locales/po/cacti.pot 58 | sed -i 's/LANGUAGE /Cacti Developers /g' locales/po/cacti.pot 59 | sed -i 's/CHARSET/UTF-8/g' locales/po/cacti.pot 60 | 61 | # Merge any changes to POT file into language files 62 | echo "Merging updates to language files..." 63 | 64 | for file in `ls -1 locales/po/*.po`;do 65 | echo "Updating $file from cacti.pot" 66 | msgmerge --backup off --no-wrap --update -F $file locales/po/cacti.pot 67 | done 68 | 69 | for file in `ls -1 locales/po/*.po`;do 70 | ofile=$(basename --suffix=.po ${file}) 71 | echo "Converting $file to LC_MESSAGES/${ofile}.mo" 72 | msgfmt ${file} -o locales/LC_MESSAGES/${ofile}.mo 73 | done 74 | 75 | exit 0 76 | -------------------------------------------------------------------------------- /locales/index.php: -------------------------------------------------------------------------------- 1 |