Last active
October 24, 2017 08:15
-
-
Save maakunh/0fa24ecdd3c2dd4a5f02406ae6ee1448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "parse_arp_from_pcap.php"; | |
//センサーネットワークアドレスを取得する | |
$network_addr = sensor_network_addr(); | |
list($network_ip, $mask) = explode('/', $network_addr); | |
$imax = pow(2, 32 - $mask) - 2; | |
$sensor_ip_addr = sensor_ip_addr(); | |
$sensor_mac_address = sensor_mac_address(); | |
$url = sensor_server_url().'/arp_controls_ip_get_api'; | |
while(1){ | |
for($i = 1; $i <= $imax; $i++){ | |
$ip_long = ip2long($network_ip) + $i; | |
$ip_address = long2ip($ip_long); | |
$flg_arp_controls = flg_arp_controls_ip($url,$ip_address); | |
echo $flg_arp_controls.PHP_EOL; | |
if($flg_arp_controls == 0){ //コントロールテーブルにないIPアドレスのみARP要求する | |
$rtn = exec('/home/ubuntu/arp_watch/arp_request '.$ip_address.' 00:00:00:00:00:00 '.$sensor_ip_addr.' '.$sensor_mac_address.' ff:ff:ff:ff:ff:ff > /dev/null &'); | |
echo long2ip($ip_long).'<-'.$sensor_ip_addr.PHP_EOL; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment