Station API
Diff: Ether.h
- Revision:
- 1:a22e390c70b3
- Parent:
- 0:d81f611c59ec
- Child:
- 2:a9d1a9c92927
--- a/Ether.h Wed Nov 30 04:35:45 2011 +0000 +++ b/Ether.h Mon Dec 12 02:33:21 2011 +0000 @@ -1,30 +1,5 @@ -/* -Copyright (c) 2011, Senio Networks, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -#ifndef ETHER_H -#define ETHER_H - #include "EthernetNetIf.h" -#include "utils.h" +#include "Utils.h" class Ether { public: @@ -47,10 +22,10 @@ sprintf(path, "/local/%s", filename); if (FILE *fp = fopen(path, "r")) { char b1, b2, b3, b4; - IpAddr ip = fgetValues(fp, "ip-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); - IpAddr subnet = fgetValues(fp, "subnet-mask:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); - IpAddr gateway = fgetValues(fp, "gateway-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); - IpAddr dns = fgetValues(fp, "dns-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); + IpAddr ip = Utils::fgetValues(fp, "ip-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); + IpAddr subnet = Utils::fgetValues(fp, "subnet-mask:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); + IpAddr gateway = Utils::fgetValues(fp, "gateway-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); + IpAddr dns = Utils::fgetValues(fp, "dns-address:%hhu.%hhu.%hhu.%hhu", &b1, &b2, &b3, &b4) ? IpAddr(b1, b2, b3, b4) : IpAddr(); fclose(fp); if (verbose) { ::printf( "ip-address:%hhu.%hhu.%hhu.%hhu\n", ip[0], ip[1], ip[2], ip[3]); @@ -58,8 +33,7 @@ ::printf( "gateway-address:%hhu.%hhu.%hhu.%hhu\n", gateway[0], gateway[1], gateway[2], gateway[3]); ::printf( "dns-address:%hhu.%hhu.%hhu.%hhu\n", dns[0], dns[1], dns[2], dns[3]); } - if (!ip.isNull()) - return Ether(ip, subnet, gateway, dns, verbose); + return Ether(ip, subnet, gateway, dns, verbose); } } return Ether(); @@ -73,7 +47,7 @@ } } - operator bool() { + bool isActive() { return active; } @@ -81,6 +55,4 @@ EthernetNetIf eth; bool active; bool verbose; -}; - -#endif \ No newline at end of file +}; \ No newline at end of file