diff options
author | ramon <ramongomez@us.es> | 2011-06-17 10:02:48 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2011-06-17 10:02:48 +0000 |
commit | f48b8f97cef668b42c725f0e9724502ebae636f0 (patch) | |
tree | 6ef494cdd3daf39f79680ea4fcb6dfaa9ad5f9e1 /client/engine | |
parent | c5d597c7c2e3284c82a801e563605d49dd7d723a (diff) |
Versión 1.0.2: librería Net.lib trata solo interfaces de red activas (cerrar #370)
git-svn-id: https://opengnsys.es/svn/branches/version1.0@2075 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/engine')
-rwxr-xr-x | client/engine/Net.lib | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/client/engine/Net.lib b/client/engine/Net.lib index 6ac5a94a..293dc050 100755 --- a/client/engine/Net.lib +++ b/client/engine/Net.lib @@ -4,7 +4,7 @@ #@brief Librería o clase Net #@class Net #@brief Funciones básicas de red. -#@version 0.10 +#@version 1.0.2 #@warning License: GNU GPLv3+ #*/ @@ -37,7 +37,7 @@ echo $HOST #/** # ogGetNetInterface #@brief Muestra la interfaz de red del sistema -#@return str_interfaz - interfaz de red +#@return str_interface - interfaz de red #@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing #@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf #@author Antonio J. Doblas Viso. Universidad de Malaga. @@ -45,13 +45,10 @@ echo $HOST #*/ ## function ogGetNetInterface () { - echo $DEVICE - +echo $DEVICE } - - #/** # ogGetIpAddress #@brief Muestra la dirección IP del sistema @@ -63,19 +60,25 @@ function ogGetNetInterface () #@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf #@author Antonio J. Doblas Viso. Universidad de Malaga. #@date 2011-02-24 +#@version 1.0.2 - Soporte para varias tarjetas de red +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-06-17 #*/ ## function ogGetIpAddress () { local IP -if [ -n $IPV4ADDR ] -then - echo $IPV4ADDR +if [ -n $IPV4ADDR ]; then + IP=$IPV4ADDR else - # Obtener direcciones IP. /* (comentario para Doxygen) - IP=$(ip address show | awk '$2!~/lo/ { readline; if ($1~/inet$/) {sub (/\/.*/, ""); printf ("%s ", $2)}}') - # Mostrar sólo la primera. (comentario para Doxygen) */ - echo ${IP%% *} + # Obtener direcciones IP. + if [ -n "$DEVICE" ]; then + IP=$(ip -o address show up dev "$DEVICE" 2>/dev/null | awk '{if ($3~/inet$/) {printf ("%s ", $4)}}') + else + IP=$(ip -o address show up | awk '$2!~/lo/ {if ($3~/inet$/) {printf ("%s ", $4)}}') + fi fi +# Mostrar solo la primera. +echo ${IP%%/*} # (comentario para Doxygen) */ } @@ -86,12 +89,19 @@ fi #@version 0.10 - Integración en OpenGnSys 0.10 #@author Ramon Gomez, ETSII Universidad de Sevilla #@date 2010-02-11 +#@version 1.0.2 - Soporte para varias tarjetas de red +#@author Ramon Gomez, ETSII Universidad de Sevilla +#@date 2011-06-17 #*/ ## function ogGetMacAddress () { local MAC # Obtener direcciones Ethernet. -MAC=$(ip address show | awk '$2!~/lo/ {readline; if ($1~/ether/) printf ("%s ", toupper($2));}') +if [ -n "$DEVICE" ]; then + MAC=$(ip -o address show up dev "$DEVICE" 2>/dev/null | awk '{sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}') +else + MAC=$(ip -o address show up | awk '$2!~/lo/ {sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}') +fi # Mostrar sólo la primera. echo ${MAC%% *} } |