/* This file is part of actube. actube 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. libcapwap 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 Foobar. If not, see . */ #include #include #include #include #include #include #include #include #include "actube.h" #include "wtplist.h" #include "capwap/dtls.h" #include "capwap/log.h" #include "capwap/dbg.h" #include "conf.h" #include "capwap/sock.h" #include "socklist.h" #include "db.h" #include "capwap/capwap_items.h" #include "capwap/capwap_cisco.h" #include "capwap/capwap_80211.h" #include "capwap/action.h" #include "capwap/capwap_crypto.h" #include "capwap/mbag.h" #include "ac.h" #include "capwap/format.h" int ac_run(); static void * alive_thread(void *data) { /* Ping the database every 5 seconds */ while(1){ sleep(5); db_ping(); } } int main (int argc, const char * argv[]) { int rc =0; /* int n; cw_itemdefheap_t h=cw_itemdefheap_create(); n=cw_itemdefheap_register(h,capwap_itemdefs); printf("Registered: %d\n",n); const cw_itemdef_t * id = cw_itemdef_get(h,"wtp_name",NULL); if (id) { printf("Found %s is of type %s\n",id->id,id->type->name); } else{ printf("Not found, why?\n"); } mavl_destroy(h); exit(0); */ cw_log_name="AC-Tube"; read_config("ac.conf"); /* Show debug options if there are any set */ if(cw_dbg_opt_level) cw_log(LOG_INFO,"Debug Options: %08X",cw_dbg_opt_level); /* XXX Hard coded debug settigns, set it by config in the future */ cw_dbg_opt_display=DBG_DISP_ASC_DMP | DBG_DISP_COLORS; /* Warn, if the "secret" debugging feature for developers is turned on ;)*/ DBGX("Attention! %s","DBGX is ON!"); /* Initialize the database */ if (!db_init()) goto errX; if (!db_start()) goto errX; db_ping(); /* Start a database "pinger thread", which inserts every xx seconds a timestamp into the DB */ pthread_t alth; pthread_create (&alth, NULL, alive_thread, NULL); /* Init DTLS library */ dtls_init(); int regn; /* Load CAPWAP base protocol */ if (conf_capwap_mode==CW_MODE_CIPWAP){ cw_dbg(DBG_INFO,"Loading CIPWAP Actions ..."); regn = cw_register_actions_cipwap_ac(&capwap_actions); } else { cw_dbg(DBG_INFO,"Loading standard CAPWAP Actions ..."); regn = cw_register_actions_capwap_ac(&capwap_actions); } /* Load bindings */ cw_dbg(DBG_INFO,"Loading 802.11 Bindings ..."); // regn += cw_register_actions_capwap_80211_ac(&capwap_actions); cw_dbg(DBG_INFO,"Registered %d protocol actions and strings.",regn); ac_global_init(); if (!socklist_init()) goto errX; if (!wtplist_init()) goto errX; cw_log(LOG_INFO,"Starting AC-Tube, Name=%s, ID=%s",conf_acname,conf_acid); rc = ac_run(); errX: /* XXX There is more cleanup to do */ wtplist_destroy(); socklist_destroy(); return rc; } void process_ctrl_packet(int index, struct sockaddr * addr, uint8_t * buffer, int len); #define AC_PROTO_CAPWAP 0 #define AC_PROTO_LWAPP 1 int ac_run() { if (!conf_listen_addrs_len){ cw_log(LOG_ERR,"Fatal error: No listen addresses found."); return 1; } /* it is important to create the unicast sockets first, * because when we create the mcast an bcast sockets next * we will look for already created sockets to find a * good unicast reply socket */ int i; for(i=0; imax) max=socklist[i].sockfd; } /* wait for an event */ int n; while((n=select(max+1, &fset, NULL, NULL, NULL)) < 0) { if (errno != EINTR) return n; } /* process the received packet */ for( i=0; i