/* * bridge.c * * Copyright (c) 2009 Ismael Gomez-Miguelez, UPC . All rights reserved. * * * This file is part of ALOE. * * ALOE is free software: you can redistribute it 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. * * ALOE 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 ALOE. If not, see . * */ /* standard libraries */ #include #include #include "phal_hw_api.h" #include "phal_daemons.h" #include "phid.h" #include "pkt.h" #include "set.h" #include "daemon.h" #include "bridge.h" #include "bridge_cmds.h" void bridge_run(); void bridge_alloc(); int bridge_init(daemon_o daemon); int bridge_background(); #ifdef RUN_AS_PROC int main() { bridge_run(); return 1; } #endif static cmd_t cmds[] = {{ BRIDGE_IDENT, bridge_incmd_ident, "Ident neighbours", "Error identifying neighbours"}, { BRIDGE_RMITF, bridge_incmd_rmitf, "Remove interface", "Error removing interface"}, { BRIDGE_ADDITF, bridge_incmd_additf, "Add interface", "Error adding interface"}, { 0, NULL, NULL, NULL}}; void bridge_run() { daemon_o daemon; time_t tdata; int n; if (!hwapi_init ()) { printf("Error initiating api\n"); exit(-1); } bridge_alloc(); daemon = daemon_new(DAEMON_BRIDGE, cmds); if (!daemon) { xprintf ("swman: Error creating daemon\n"); exit(-1); } n=bridge_init(daemon); if (n<0) { xprintf("BRIDGE: Error initiating external itf\n"); exit(-1); } xprintf ("BRIDGE: Init ok\n"); while (1) { do { n = daemon_rcvpkt(daemon); if (n > 0) { daemon_processcmd(daemon); } if (n<0) { exit(-1); } } while (n); if (n < 0) { break; } bridge_background(); hwapi_relinquish_daemon(); } daemon_delete(&daemon); exit(-1); }