spacer
spacer search

SwissCenter

Search
spacer
Main Menu
Home
Documentation + FAQ
Screenshots
Downloads
Forums
Bug Tracking
History
Login
Username

Password

Remember me
?
No account yet?

Locations of visitors to this page

 
Home arrow Forums

SwissCenter Forums  


Calling MAC address in linux - 2009/09/10 14:45 Hi Nigel,

In this thread the issue of calling the MAC address of the client popped up.

Looking in table ‘clients[i]’ of the Swiss DB none of the MAC address were included. It might be related to the way the MAC address is called in file ‘[i]/base/server.php (function get_mac_addr($ip) which I think it’s not working with Linux (don’t ask me why …).

However, I found the following script that works:
Code:

 /* * Getting MAC Address using PHP * Md. Nazmul Basher */ //get the Macaddress of Server     class GetMacAddr     {         var $return_array = array();         var $mac_addr;         function GetMacAddr($os_type)         {             switch ( strtolower($os_type) )             {             case "linux":             $this->forLinux();             break;             case "solaris":             break;             case "unix":             break;             case "aix":             break;             default:             $this->forWindows();             break;             }             $temp_array = array();             foreach ( $this->return_array as $value )             {                 if ( preg_match"/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i"$value$temp_array ) )                 {                 $this->mac_addr $temp_array[0];                 break;                 }             }         unset($temp_array);         return $this->mac_addr;         }         function forWindows()         {             @exec("ipconfig /all"$this->return_array);             if ( $this->return_array )                 return $this->return_array;             else{                 $ipconfig $_SERVER["WINDIR"]."\system32\ipconfig.exe";             if ( is_file($ipconfig) )                 @exec($ipconfig." /all"$this->return_array);             else                 @exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all"$this->return_array);             return $this->return_array;             }         }         function forLinux()         {             @exec("ifconfig -a"$this->return_array);             return $this->return_array;         }     } // echo Macaddress of Server $mac = new GetMacAddr(PHP_OS); echo $mac->mac_addr;

regards, Klaas

---------------------------------------------------------------------------
SwissCenter SVN 1315
Simese 2.5.9 / PHP 5.2.9-1 / MySQL 5.1.32 / Windows XP SP3
Apache 2.2.11 / PHP 5.2.10 / MySQL 5.1.34 / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.2-0914
Pinnacle SC200 / PCH A-110
  | | The administrator has disabled public write access.
Re: Calling MAC address in linux - 2009/09/11 08:16 This will only return the MAC address of the server which we don't want. We need the MAC address of the players to uniquely identify them on the network. Players : Netgear EVA700 | Popcorn A-100 (091202) | Popcorn A-200 (100208)
Webserver : Simese v2.6.4 | Apache 2.2.14 | PHP v5.2.12 | MySQL v5.1.32
Server : Windows 7 Home Premium 64bit
Spec : Intel C2Q Q6600 - 4GB RAM - 3TB HDD
AV : Pioneer VSX-915 | Samsung LE40C650
  | | The administrator has disabled public write access.
Re: Calling MAC address in linux - 2009/09/11 16:09 hummm ... indeed, I see it now (not so clever idea)

Going over file '/base/sever.php' there's a specific
Code:

 function is_synology()

see row 26 through 46. As I understand line 28, this function is still in a testing phase.

Maybe the problem is related to this function. Is the function already tested, and if not, how can I support the test?

regards, Klaas

---------------------------------------------------------------------------
SwissCenter SVN 1315
Simese 2.5.9 / PHP 5.2.9-1 / MySQL 5.1.32 / Windows XP SP3
Apache 2.2.11 / PHP 5.2.10 / MySQL 5.1.34 / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.2-0914
Pinnacle SC200 / PCH A-110
  | | The administrator has disabled public write access.
Re: Calling MAC address in linux - 2009/09/11 16:59 The function is_synology is not currently used, not sure what it was intended for.

To get the MAC address of devices on the LAN we use:

arp -a IP

where IP is the address of your player. It should return something like:

Code:

 Microsoft Windows [Version 6.0.6002] Copyright (c2006 Microsoft Corporation.  All rights reserved. C:\Users\Nigel>arp -a 192.168.0.20 Interface: 192.168.0.2 --- 0x10   Internet Address      Physical Address      Type   192.168.0.20          00-06-dc-41-d0-76     dynamic


Does this work on the Synlogy or can you find something similar?
Players : Netgear EVA700 | Popcorn A-100 (091202) | Popcorn A-200 (100208)
Webserver : Simese v2.6.4 | Apache 2.2.14 | PHP v5.2.12 | MySQL v5.1.32
Server : Windows 7 Home Premium 64bit
Spec : Intel C2Q Q6600 - 4GB RAM - 3TB HDD
AV : Pioneer VSX-915 | Samsung LE40C650
  | | The administrator has disabled public write access.
Re: Calling MAC address in linux - 2009/09/11 18:04 Hi Nigel,

Well, ARP cannot be installed on the Synology box, and as a result command
Code:

 arp -a IP

doesn't work on the Synology.

However, ARPING does work on the Synology and returns the MAC address. The result
Code:

 Synology>arping -I eth0 -c 1 192.168.0.80  ARPING 192.168.0.80  60 bytes from 00:06:dc:44:10:e9 (192.168.0.80): index=0 time=11.646 msec  --- 192.168.0.80 statistics ---  1 packets transmitted1 packets received,   0unanswered  Synology>

NOTE: IP 192.168.0.80 is the one of my PCH.

regards, Klaas

BTW must be logged in as root to use ARPING

---------------------------------------------------------------------------
SwissCenter SVN 1315
Simese 2.5.9 / PHP 5.2.9-1 / MySQL 5.1.32 / Windows XP SP3
Apache 2.2.11 / PHP 5.2.10 / MySQL 5.1.34 / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.2-0914
Pinnacle SC200 / PCH A-110
  | | The administrator has disabled public write access.
Re: Calling MAC address in linux - 2009/09/12 05:40 Hi Nigel,

I tried the script I posted above, but included the ARP and ARPING commands (which work on the command line). The part I changed looks like this:
Code:

        function forWindows()         {             @exec("arp -a 192.168.0.80"$this->return_array);             if ( $this->return_array )                 return $this->return_array;             else{                 $ipconfig $_SERVER["WINDIR"]."\system32\ipconfig.exe";             if ( is_file($ipconfig) )                 @exec($ipconfig." /all"$this->return_array);             else                 @exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all"$this->return_array);             return $this->return_array;             }         }         function forLinux()         {             @exec("arping -I eth0 -c 1 192.168.0.80"$this->return_array);             return $this->return_array;         }

On my XP/Simese system it’s working fine, but my SynologyLinux/Apache doesn’t return anaything. Could this have something to do that you need to logged in as ROOT?

regards, Klaas

---------------------------------------------------------------------------
SwissCenter SVN 1315
Simese 2.5.9 / PHP 5.2.9-1 / MySQL 5.1.32 / Windows XP SP3
Apache 2.2.11 / PHP 5.2.10 / MySQL 5.1.34 / Linux Synology 2.6.15
Synology DS107+ (128), firmware: DSM 2.2-0914
Pinnacle SC200 / PCH A-110
  | | The administrator has disabled public write access.
spacer
 

Screenshots

www.flickr.com
This is a Flickr badge showing public photos from swisscenter. Make your own badge here.


 

Mambo is Free Software released under the GNU/GPL License.
spacer