Skip to content
Browse files

Rolling back addition of ethernet interface.

  • Loading branch information...
1 parent 5ffed3f commit ffeb258065d8ab832cab6256a354726a64ba9905 Caleb James DeLisle committed Nov 11, 2012
View
40 admin/Configurator.c
@@ -172,45 +172,6 @@ static void tunInterface(Dict* ifaceConf, struct Allocator* tempAlloc, struct Co
rpcCall0(String_CONST("Core_initTunnel"), args, ctx, tempAlloc, false);
}
-static void ethInterface(Dict* config, struct Context* ctx)
-{
- Dict* eth = Dict_getDict(config, String_CONST("ETHInterface"));
-
- if (eth) {
- // Setup the interface.
- String* deviceStr = Dict_getString(eth, String_CONST("bind"));
- Dict* d = Dict_new(ctx->alloc);
- if (deviceStr) {
- Dict_putString(d, String_CONST("bindDevice"), deviceStr, ctx->alloc);
- }
- rpcCall(String_CONST("ETHInterface_new"), d, ctx, ctx->alloc);
-
- // Make the connections.
- Dict* connectTo = Dict_getDict(eth, String_CONST("connectTo"));
- if (connectTo) {
- struct Dict_Entry* entry = *connectTo;
- while (entry != NULL) {
- String* key = (String*) entry->key;
- if (entry->val->type != Object_DICT) {
- Log_critical(ctx->logger, "interfaces.ETHInterface.connectTo: entry [%s] "
- "is not a dictionary type.", key->bytes);
- exit(-1);
- }
- Dict* value = entry->val->as.dictionary;
-
- Log_keys(ctx->logger, "Attempting to connect to node [%s].", key->bytes);
-
- struct Allocator* perCallAlloc = ctx->alloc->child(ctx->alloc);
- Dict_putString(value, String_CONST("dstMac"), key, perCallAlloc);
- rpcCall(String_CONST("ETHInterface_beginConnection"), value, ctx, perCallAlloc);
- perCallAlloc->free(perCallAlloc);
-
- entry = entry->next;
- }
- }
- }
-}
-
static void security(List* securityConf, struct Allocator* tempAlloc, struct Context* ctx)
{
bool noFiles = false;
@@ -254,7 +215,6 @@ void Configurator_config(Dict* config,
Dict* ifaces = Dict_getDict(config, String_CONST("interfaces"));
udpInterface(ifaces, &ctx);
- ethInterface(ifaces, &ctx);
Dict* routerConf = Dict_getDict(config, String_CONST("router"));
Dict* iface = Dict_getDict(routerConf, String_CONST("interface"));
View
14 admin/angel/cjdroute2.c
@@ -31,7 +31,6 @@
#include "interface/TUNInterface.h"
#include "interface/TUNConfigurator.h"
#include "interface/UDPInterface_admin.h"
-#include "interface/ETHInterface_admin.h"
#include "io/Reader.h"
#include "io/ArrayReader.h"
#include "io/ArrayWriter.h"
@@ -211,19 +210,6 @@ static int genconf(struct Random* rand)
" // Ask somebody who is already connected.\n"
" }\n"
" }\n"
- "\n"
- " /*\n"
- " \"ETHInterface\":\n"
- " {\n"
- " // Bind to this device.\n"
- " \"bind\": \"eth0\", \n"
- " // Node(s) to connect to.\n"
- " {\n"
- " // Add connection credential here to join the network\n"
- " // Ask your peer on the other side of the link.\n"
- " }\n"
- " }\n"
- " */\n"
" },\n"
"\n"
" // Configuration for the router.\n"
View
2 interface/CMakeLists.txt
@@ -21,8 +21,6 @@ endif()
add_library(interface
UDPInterface.c
UDPInterface_admin.c
- ETHInterface.c
- ETHInterface_admin.c
${tunif}
TUNConfigurator_${SYSTEM}.c
InterfaceConnector.c
View
295 interface/ETHInterface.c
@@ -1,295 +0,0 @@
-/* vim: set expandtab ts=4 sw=4: */
-/*
- * You may redistribute this program and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#define string_strncpy
-#include "exception/Except.h"
-#include "interface/Interface.h"
-#include "interface/ETHInterface.h"
-#include "memory/Allocator.h"
-#include "net/InterfaceController.h"
-#include "wire/Headers.h"
-#include "wire/Message.h"
-#include "wire/Error.h"
-#include "util/Assert.h"
-#include "util/Errno.h"
-#include "util/platform/libc/string.h"
-
-#ifdef WIN32
- #include <winsock.h>
- #undef interface
-#else
- #include <sys/socket.h>
- #include <linux/if_packet.h>
- #include <linux/if_ether.h>
- #include <linux/if_arp.h>
-#endif
-
-#include <event2/event.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#define MAX_PACKET_SIZE 1496
-#define MIN_PACKET_SIZE 46
-
-#define PADDING 512
-
-#define MAX_INTERFACES 256
-
-#define ETH_P_CJDNS 0xFC00
-
-// 2 last 0x00 of .sll_addr are removed from original size (20)
-#define SOCKADDR_LL_LEN 18
-
-struct ETHInterface
-{
- struct Interface interface;
-
- evutil_socket_t socket;
-
- /**
- * The event registered with libevent.
- * Needed only so it can be freed.
- */
- struct event* incomingMessageEvent;
-
- uint8_t messageBuff[PADDING + MAX_PACKET_SIZE];
-
- /** The unix interface index which is used to identify the eth device. */
- int ifindex;
-
- struct Log* logger;
-
- struct InterfaceController* ic;
-
- /** A base sockaddr_ll which is used to build the address to send packets to. */
- struct sockaddr_ll addrBase;
-};
-
-static inline void sockaddrForKey(struct sockaddr_ll* sockaddr,
- uint8_t key[InterfaceController_KEY_SIZE],
- struct ETHInterface* ethIf)
-{
- Assert_true(key[6] == 'e' && key[7] == 'n');
- Bits_memcpyConst(sockaddr, &ethIf->addrBase, sizeof(struct sockaddr_ll));
- Bits_memcpyConst(sockaddr->sll_addr, key, 6);
-}
-
-static inline void keyForSockaddr(uint8_t key[InterfaceController_KEY_SIZE],
- struct sockaddr_ll* sockaddr,
- struct ETHInterface* ethIf)
-{
- Bits_memcpyConst(key, sockaddr->sll_addr, 6);
- key[6] = 'e';
- key[7] = 'n';
-}
-
-static uint8_t sendMessage(struct Message* message, struct Interface* ethIf)
-{
- struct ETHInterface* context = ethIf->senderContext;
- Assert_true(&context->interface == ethIf);
-
- struct sockaddr_ll addr;
-
- sockaddrForKey(&addr, message->bytes, context);
- Bits_memcpyConst(&addr.sll_addr, message->bytes, 6);
- Message_shift(message, -InterfaceController_KEY_SIZE);
-
- if (sendto(context->socket,
- message->bytes,
- message->length,
- 0,
- (struct sockaddr*) &addr,
- sizeof(struct sockaddr_ll)) < 0)
- {
- enum Errno err = Errno_get();
- switch (err) {
- case Errno_EMSGSIZE:
- return Error_OVERSIZE_MESSAGE;
-
- case Errno_ENOBUFS:
- case Errno_EAGAIN:
- return Error_LINK_LIMIT_EXCEEDED;
-
- default:;
- Log_info(context->logger, "Got error sending to socket [%s]", Errno_strerror(err));
- }
- }
- return 0;
-}
-
-/**
- * Release the event used by this module.
- *
- * @param vevent a void pointer cast of the event structure.
- */
-static void freeEvent(void* vevent)
-{
- event_del((struct event*) vevent);
- event_free((struct event*) vevent);
-}
-
-static void handleEvent(evutil_socket_t socket, short eventType, void* vcontext)
-{
- struct ETHInterface* context = (struct ETHInterface*) vcontext;
-
- struct Message message =
- { .bytes = context->messageBuff + PADDING, .padding = PADDING, .length = MAX_PACKET_SIZE };
-
- struct sockaddr_ll addr;
- Bits_memset(&addr, 0, sizeof(struct sockaddr_ll));
- ev_socklen_t addrLen = sizeof(struct sockaddr_ll);
-
- // Start writing InterfaceController_KEY_SIZE after the beginning,
- // keyForSockaddr() will write the key there.
- int rc = recvfrom(socket,
- message.bytes + InterfaceController_KEY_SIZE,
- message.length - InterfaceController_KEY_SIZE,
- 0,
- (struct sockaddr*) &addr,
- &addrLen);
-
- Assert_true(addrLen == SOCKADDR_LL_LEN);
-
- /** "Magic" Warning!
- *
- * - smallest payload for AF_PACKET: 46 bytes
- * - smallest packet (empyrical): 40 bytes (aka "ctrl packet")
- */
-
- /* Begin of "magic" */
- if (rc == MIN_PACKET_SIZE) {
- // remove extra 0x00 from the end of the paylod
- rc = 40;
- }
- /* End of "magic" */
-
- if (rc < 0) {
- return;
- }
-
- message.length = rc + InterfaceController_KEY_SIZE;
-
- keyForSockaddr(message.bytes, &addr, context);
-
- context->interface.receiveMessage(&message, &context->interface);
-}
-
-int ETHInterface_beginConnection(const char* macAddress,
- uint8_t cryptoKey[32],
- String* password,
- struct ETHInterface* ethIf)
-{
- struct sockaddr_ll addr;
- if (AddrTools_parseMac(addr.sll_addr, (const uint8_t*)macAddress)) {
- return ETHInterface_beginConnection_BAD_MAC;
- }
-
- uint8_t key[InterfaceController_KEY_SIZE];
- keyForSockaddr(key, &addr, ethIf);
- int ret = ethIf->ic->insertEndpoint(key, cryptoKey, password, &ethIf->interface, ethIf->ic);
- switch(ret) {
- case 0:
- return 0;
-
- case InterfaceController_registerInterface_BAD_KEY:
- return ETHInterface_beginConnection_BAD_KEY;
-
- case InterfaceController_registerInterface_OUT_OF_SPACE:
- return ETHInterface_beginConnection_OUT_OF_SPACE;
-
- default:
- return ETHInterface_beginConnection_UNKNOWN_ERROR;
- }
-}
-
-struct ETHInterface* ETHInterface_new(struct event_base* base,
- const char* bindDevice,
- struct Allocator* allocator,
- struct Except* exHandler,
- struct Log* logger,
- struct InterfaceController* ic)
-{
- struct ETHInterface* context = allocator->malloc(sizeof(struct ETHInterface), allocator);
- Bits_memcpyConst(context, (&(struct ETHInterface) {
- .interface = {
- .sendMessage = sendMessage,
- .senderContext = context,
- .allocator = allocator
- },
- .logger = logger,
- .ic = ic
- }), sizeof(struct ETHInterface));
-
- struct ifreq ifr;
-
- context->socket = socket(AF_PACKET, SOCK_DGRAM, Endian_hostToBigEndian16(ETH_P_CJDNS));
- if (context->socket == -1) {
- Except_raise(exHandler, ETHInterface_new_SOCKET_FAILED,
- "call to socket() failed. [%s]", Errno_getString());
- }
- strncpy(ifr.ifr_name, bindDevice, IFNAMSIZ);
- ifr.ifr_name[sizeof(ifr.ifr_name)-1] = '\0';
-
- if (ioctl(context->socket, SIOCGIFINDEX, &ifr) == -1) {
- Except_raise(exHandler, ETHInterface_new_FAILED_FIND_IFACE,
- "failed to find interface index [%s]", Errno_getString());
- }
- context->ifindex = ifr.ifr_ifindex;
-
- if (ioctl(context->socket, SIOCGIFHWADDR, &ifr) == -1) {
- Except_raise(exHandler, ETHInterface_new_FAILED_FIND_MACADDR,
- "failed to find mac address of interface [%s]", Errno_getString());
- }
-
- uint8_t srcMac[6];
- Bits_memcpyConst(srcMac, ifr.ifr_hwaddr.sa_data, 6);
-
- // TODO: is the node's mac addr private information?
- Log_info(context->logger, "found MAC for device %s [%i]: %02x:%02x:%02x:%02x:%02x:%02x\n",
- bindDevice, context->ifindex,
- srcMac[0], srcMac[1], srcMac[2], srcMac[3], srcMac[4], srcMac[5]);
-
- context->addrBase = (struct sockaddr_ll) {
- .sll_family = AF_PACKET,
- .sll_protocol = Endian_hostToBigEndian16(ETH_P_CJDNS),
- .sll_ifindex = context->ifindex,
- .sll_hatype = ARPHRD_ETHER,
- .sll_pkttype = PACKET_OTHERHOST,
- .sll_halen = ETH_ALEN,
- .sll_addr[6] = 0x00,
- .sll_addr[7] = 0x00,
- };
-
-
- if (bind(context->socket, (struct sockaddr*) &context->addrBase, sizeof(struct sockaddr_ll))) {
- Except_raise(exHandler, ETHInterface_new_BIND_FAILED,
- "call to bind() failed [%s]", Errno_getString());
- }
-
- evutil_make_socket_nonblocking(context->socket);
-
- context->incomingMessageEvent =
- event_new(base, context->socket, EV_READ | EV_PERSIST, handleEvent, context);
-
- if (!context->incomingMessageEvent || event_add(context->incomingMessageEvent, NULL)) {
- Except_raise(exHandler, ETHInterface_new_FAILED_CREATING_EVENT,
- "failed to create ETHInterface event [%s]", Errno_getString());
- }
-
- allocator->onFree(freeEvent, context->incomingMessageEvent, allocator);
-
- ic->registerInterface(&context->interface, ic);
-
- return context;
-}
View
83 interface/ETHInterface.h
@@ -1,83 +0,0 @@
-/* vim: set expandtab ts=4 sw=4: */
-/*
- * You may redistribute this program and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef ETHInterface_H
-#define ETHInterface_H
-
-#include "util/events/EventBase.h"
-#include "interface/Interface.h"
-#include "net/InterfaceController.h"
-#include "util/log/Log.h"
-#include "memory/Allocator.h"
-
-struct ETHInterface;
-
-/**
- * @param base the LibEvent context.
- * @param bindDevice the name of the device to bind to.
- * @param allocator the memory allocator for this message.
- * @param exHandler the handler to deal with whatever exception arises.
- * Exceptions:
- * ETHInterface_new_PARSE_ADDRESS_FAILED Couldn't parse interface address as a MAC address
- * ETHInterface_new_FAILED_CREATING_EVENT Failed creating the event or registering it with
- * the libevent event base (shouldn't happen)
- * ETHInterface_new_FAILED_FIND_IFACE Failed to find a device with the given name
- * ETHInterface_new_FAILED_FIND_MACADDR Failed to find the MAC address of the interface
- * ETHInterface_new_SOCKET_FAILED Failed calling socket(), check EVUTIL_SOCKET_ERROR()
- * ETHInterface_new_BIND_FAILED Failed calling bind(), check EVUTIL_SOCKET_ERROR()
- *
- * @param logger
- * @param ic the controller which this interface should register with
- * and use when starting connections.
- * @return a new ETHInterface.
- */
-#define ETHInterface_new_PARSE_ADDRESS_FAILED -1
-#define ETHInterface_new_FAILED_CREATING_EVENT -2
-#define ETHInterface_new_FAILED_FIND_IFACE -3
-#define ETHInterface_new_FAILED_FIND_MACADDR -4
-#define ETHInterface_new_SOCKET_FAILED -5
-#define ETHInterface_new_BIND_FAILED -6
-struct ETHInterface* ETHInterface_new(struct event_base* base,
- const char* bindDevice,
- struct Allocator* allocator,
- struct Except* exHandler,
- struct Log* logger,
- struct InterfaceController* ic);
-
-
-/**
- * Begin an outgoing connection.
- *
- * @param macAddress the MAC address of the ethernet card to connect to.
- * @param cryptoKey the node's public key, this is required to send it traffic.
- * @param password if specified, the password for authenticating with the other node.
- * @param ethIf the Ether interface.
- * @return 0 on success
- * ETHInterface_beginConnection_OUT_OF_SPACE if there is no space to store the entry.
- * ETHInterface_beginConnection_BAD_KEY invalid (non-cjdns) cryptoKey
- * ETHInterface_beginConnection_BAD_IFACE failed to parse interface name.
- * ETHInterface_beginConnection_UNKNOWN_ERROR something failed in InterfaceController.
- * ETHInterface_beginConnection_BAD_MAC malformed MAC address.
- */
-#define ETHInterface_beginConnection_OUT_OF_SPACE -1
-#define ETHInterface_beginConnection_BAD_KEY -2
-#define ETHInterface_beginConnection_BAD_IFACE -3
-#define ETHInterface_beginConnection_UNKNOWN_ERROR -4
-#define ETHInterface_beginConnection_BAD_MAC -5
-int ETHInterface_beginConnection(const char* macAddress,
- uint8_t cryptoKey[32],
- String* password,
- struct ETHInterface* ethIf);
-
-#endif
View
161 interface/ETHInterface_admin.c
@@ -1,161 +0,0 @@
-/* vim: set expandtab ts=4 sw=4: */
-/*
- * You may redistribute this program and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "benc/Int.h"
-#include "admin/Admin.h"
-#include "exception/Jmp.h"
-#include "interface/ETHInterface.h"
-#include "memory/Allocator.h"
-#include "net/InterfaceController.h"
-#include "util/Base32.h"
-#include "util/Errno.h"
-
-struct Context
-{
- struct event_base* eventBase;
- struct Allocator* allocator;
- struct Log* logger;
- struct Admin* admin;
- struct InterfaceController* ic;
-
- uint32_t ifCount;
- struct ETHInterface** ifaces;
-};
-
-static void beginConnection(Dict* args, void* vcontext, String* txid)
-{
- struct Context* ctx = vcontext;
-
- String* password = Dict_getString(args, String_CONST("password"));
- String* publicKey = Dict_getString(args, String_CONST("publicKey"));
- String* dstMac = Dict_getString(args, String_CONST("macAddress"));
- int64_t* interfaceNumber = Dict_getInt(args, String_CONST("interfaceNumber"));
- uint32_t ifNum = (interfaceNumber) ? ((uint32_t) *interfaceNumber) : 0;
- String* error = NULL;
-
- uint8_t pkBytes[32];
-
- if (ctx->ifCount == 0) {
- error = String_CONST("no interfaces are setup, call ETHInterface_new() first");
-
- } else if (interfaceNumber && (*interfaceNumber >= ctx->ifCount || *interfaceNumber < 1)) {
- error = String_CONST("invalid interfaceNumber");
-
- } else if (!publicKey
- || publicKey->len < 52
- || (publicKey->len > 52 && publicKey->bytes[52] != '.'))
- {
- error = String_CONST("publicKey must be 52 characters long.");
-
- } else if (Base32_decode(pkBytes, 32, (uint8_t*)publicKey->bytes, 52) != 32) {
- error = String_CONST("failed to parse publicKey.");
-
- } else {
- struct ETHInterface* ethif = ctx->ifaces[ifNum];
- switch (ETHInterface_beginConnection(dstMac->bytes, pkBytes, password, ethif)) {
- case ETHInterface_beginConnection_OUT_OF_SPACE:
- error = String_CONST("no more space to register with the switch.");
- break;
- case ETHInterface_beginConnection_BAD_KEY:
- error = String_CONST("invalid cjdns public key.");
- break;
- case ETHInterface_beginConnection_BAD_IFACE:
- error = String_CONST("unable to parse device name.");
- break;
- case 0:
- error = String_CONST("none");
- break;
- default:
- error = String_CONST("unknown error");
- }
- }
-
- Dict out = Dict_CONST(String_CONST("error"), String_OBJ(error), NULL);
- Admin_sendMessage(&out, txid, ctx->admin);
-}
-
-static void newInterface(Dict* args, void* vcontext, String* txid)
-{
- struct Context* const ctx = vcontext;
- String* const bindDevice = Dict_getString(args, String_CONST("bindDevice"));
- struct Allocator* const alloc = ctx->allocator->child(ctx->allocator);
-
- struct ETHInterface* ethIf = NULL;
- struct Jmp jmp;
- Jmp_try(jmp) {
- char* const bindBytes = (bindDevice) ? bindDevice->bytes : NULL;
- ethIf = ETHInterface_new(
- ctx->eventBase, bindBytes, alloc, &jmp.handler, ctx->logger, ctx->ic);
- } Jmp_catch {
- String* errStr = String_CONST(jmp.message);
- Dict out = Dict_CONST(String_CONST("error"), String_OBJ(errStr), NULL);
-
- if (jmp.code == ETHInterface_new_SOCKET_FAILED
- || jmp.code == ETHInterface_new_BIND_FAILED)
- {
- char* err = Errno_getString();
- Dict out2 = Dict_CONST(String_CONST("cause"), String_OBJ(String_CONST(err)), out);
- Admin_sendMessage(&out2, txid, ctx->admin);
- } else {
- Admin_sendMessage(&out, txid, ctx->admin);
- }
-
- alloc->free(alloc);
- return;
- }
-
- // sizeof(struct ETHInterface*) the size of a pointer.
- ctx->ifaces = ctx->allocator->realloc(ctx->ifaces,
- sizeof(struct ETHInterface*) * (ctx->ifCount + 1),
- ctx->allocator);
- ctx->ifaces[ctx->ifCount] = ethIf;
-
- Dict out = Dict_CONST(
- String_CONST("error"), String_OBJ(String_CONST("none")), Dict_CONST(
- String_CONST("interfaceNumber"), Int_OBJ(ctx->ifCount), NULL
- ));
-
- Admin_sendMessage(&out, txid, ctx->admin);
- ctx->ifCount++;
-}
-
-void ETHInterface_admin_register(struct event_base* base,
- struct Allocator* allocator,
- struct Log* logger,
- struct Admin* admin,
- struct InterfaceController* ic)
-{
- struct Context* ctx = allocator->clone(
- sizeof(struct Context), allocator, &(struct Context) {
- .eventBase = base,
- .allocator = allocator,
- .logger = logger,
- .admin = admin,
- .ic = ic
- });
-
- struct Admin_FunctionArg adma[1] = {
- { .name = "bindDevice", .required = 0, .type = "String" }
- };
- Admin_registerFunction("ETHInterface_new", newInterface, ctx, true, adma, admin);
-
- struct Admin_FunctionArg adma2[4] = {
- { .name = "interfaceNumber", .required = 0, .type = "Int" },
- { .name = "password", .required = 0, .type = "String" },
- { .name = "publicKey", .required = 1, .type = "String" },
- { .name = "macAddress", .required = 1, .type = "String" }
- };
- Admin_registerFunction("ETHInterface_beginConnection",
- beginConnection, ctx, true, adma2, admin);
-}
View
31 interface/ETHInterface_admin.h
@@ -1,31 +0,0 @@
-/* vim: set expandtab ts=4 sw=4: */
-/*
- * You may redistribute this program and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef ETHInterface_admin_H
-#define ETHInterface_admin_H
-
-#include "admin/Admin.h"
-#include "memory/Allocator.h"
-#include "net/InterfaceController.h"
-#include "util/log/Log.h"
-
-#include <event2/event.h>
-
-void ETHInterface_admin_register(struct event_base* base,
- struct Allocator* allocator,
- struct Log* logger,
- struct Admin* admin,
- struct InterfaceController* ic);
-
-#endif
View
55 util/AddrTools.h
@@ -174,59 +174,4 @@ static inline int AddrTools_parseIp(uint8_t out[16], const uint8_t hexAddr[40])
return 0;
}
-/**
- * Parse out an ethernet MAC address.
- *
- * @param out a pointer to a byte array which will be set to the bytes of the MAC address.
- * @param hexAddr a string representation of an ethernet MAC address such as:
- * "00:11:22:33:44:55"
- * @return 0 if successful, -1 if the hexAddr is malformed.
- */
-static inline int AddrTools_parseMac(uint8_t out[6], const uint8_t hexAddr[17])
-{
- for (int i = 2; i < 15; i += 3) {
- if (hexAddr[i] != ':') {
- return -1;
- }
- }
-
- uint8_t hex[12];
- int j = 0;
- for (int i = 0; i < 18; i++) {
- hex[j++] = hexAddr[i++];
- hex[j++] = hexAddr[i++];
- }
-
- if (Hex_decode(out, 6, hex, 12) != 6) {
- return -1;
- }
-
- return 0;
-}
-
-static inline void AddrTools_printMac(uint8_t output[18], const uint8_t binMac[6])
-{
- uint8_t hex[12];
- Hex_encode(hex, 12, binMac, 6);
-
- output[ 0] = hex[ 0];
- output[ 1] = hex[ 1];
- output[ 2] = ':';
- output[ 3] = hex[ 2];
- output[ 4] = hex[ 3];
- output[ 5] = ':';
- output[ 6] = hex[ 4];
- output[ 7] = hex[ 5];
- output[ 8] = ':';
- output[ 9] = hex[ 6];
- output[10] = hex[ 7];
- output[11] = ':';
- output[12] = hex[ 8];
- output[13] = hex[ 9];
- output[14] = ':';
- output[15] = hex[10];
- output[16] = hex[11];
- output[17] = '\0';
-}
-
#endif

0 comments on commit ffeb258

Please sign in to comment.
Something went wrong with that request. Please try again.