diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-05-21 21:09:54 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2019-05-27 13:02:49 +0200 |
commit | 507c75c33793ff328214c2c3e884f7860f1a16df (patch) | |
tree | 2985160aec570859f1ec48dfa80d2e9f76b4f02f /sources/ogAdmServer.cpp | |
parent | 7b6fcdbc624784cb37572030895ecc48389787a0 (diff) |
#915 Pass array of addresses to WakeUp()
To reuse this function to the REST API.
Diffstat (limited to 'sources/ogAdmServer.cpp')
-rw-r--r-- | sources/ogAdmServer.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp index 92d6f89..41400d6 100644 --- a/sources/ogAdmServer.cpp +++ b/sources/ogAdmServer.cpp @@ -1404,14 +1404,19 @@ bool respuestaConsola(int socket_c, TRAMA *ptrTrama, int res) // ________________________________________________________________________________________________________ static bool Arrancar(TRAMA* ptrTrama, struct og_client *cli) { + char *ptrIP[MAXIMOS_CLIENTES],*ptrMacs[MAXIMOS_CLIENTES]; char *iph,*mac,*mar; bool res; + int lon; iph = copiaParametro("iph",ptrTrama); // Toma dirección/es IP mac = copiaParametro("mac",ptrTrama); // Toma dirección/es MAC mar = copiaParametro("mar",ptrTrama); // Método de arranque (Broadcast o Unicast) - res=Levanta(iph,mac,mar); + lon = splitCadena(ptrIP, iph, ';'); + lon = splitCadena(ptrMacs, mac, ';'); + + res = Levanta(ptrIP, ptrMacs, lon, mar); liberaMemoria(iph); liberaMemoria(mac); @@ -1442,12 +1447,12 @@ static bool Arrancar(TRAMA* ptrTrama, struct og_client *cli) // true: Si el proceso es correcto // false: En caso de ocurrir algún error // ________________________________________________________________________________________________________ -bool Levanta(char *iph, char *mac, char *mar) + +bool Levanta(char *ptrIP[], char *ptrMacs[], int lon, char *mar) { - char *ptrIP[MAXIMOS_CLIENTES],*ptrMacs[MAXIMOS_CLIENTES]; unsigned int on = 1; sockaddr_in local; - int i, lon, res; + int i, res; int s; /* Creación de socket para envío de magig packet */ @@ -1467,8 +1472,6 @@ bool Levanta(char *iph, char *mac, char *mar) local.sin_port = htons(PUERTO_WAKEUP); local.sin_addr.s_addr = htonl(INADDR_ANY); - lon = splitCadena(ptrIP, iph, ';'); - lon = splitCadena(ptrMacs, mac, ';'); for (i = 0; i < lon; i++) { if (!WakeUp(s, ptrIP[i], ptrMacs[i], mar)) { syslog(LOG_ERR, "problem sending magic packet\n"); @@ -3329,11 +3332,12 @@ static bool recibeArchivo(TRAMA *ptrTrama, struct og_client *cli) // ________________________________________________________________________________________________________ static bool envioProgramacion(TRAMA *ptrTrama, struct og_client *cli) { + char *ptrIP[MAXIMOS_CLIENTES],*ptrMacs[MAXIMOS_CLIENTES]; char sqlstr[LONSQL], msglog[LONSTD]; char *idp,iph[LONIP],mac[LONMAC]; Database db; Table tbl; - int idx,idcomando; + int idx,idcomando,lon; if (!db.Open(usuario, pasguor, datasource, catalog)) { db.GetErrorErrStr(msglog); @@ -3387,11 +3391,14 @@ static bool envioProgramacion(TRAMA *ptrTrama, struct og_client *cli) return false; } + lon = splitCadena(ptrIP, iph, ';'); + lon = splitCadena(ptrMacs, mac, ';'); + // Se manda por broadcast y por unicast - if (!Levanta(iph, mac, (char*)"1")) + if (!Levanta(ptrIP, ptrMacs, lon, (char*)"1")) return false; - if (!Levanta(iph, mac, (char*)"2")) + if (!Levanta(ptrIP, ptrMacs, lon, (char*)"2")) return false; } |