Ejemplo n.º 1
0
Archivo: shell.c Proyecto: 7u83/actube
void show_aps (FILE *out)
{
	struct connlist * cl;
	mavliter_t it;
	wtplist_lock();
	
	cl = wtplist_get_connlist();
	
	
	mavliter_init (&it, cl->by_addr);
	fprintf (out, "IP\t\t\twtp-name\n");
	mavliter_foreach (&it) {
		cw_KTV_t * result;
		char addr[SOCK_ADDR_BUFSIZE];
		char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
		struct conn * conn;
		conn = mavliter_get_ptr (&it);
		
		sock_addr2str_p (&conn->addr, addr);
		
		result = cw_ktv_get (conn->remote_cfg, "wtp-name", NULL);
		
		if (result == NULL) {
			strcpy (wtp_name, "");
			
		} else {
			result->type->to_str (result, wtp_name, CAPWAP_MAX_WTP_NAME_LEN);
		}
		
		
		fprintf (out, "%s\t\t%s\n", addr, wtp_name);
	}
	wtplist_unlock();
}
Ejemplo n.º 2
0
Archivo: wtpman.c Proyecto: 7u83/actube
static void wtpman_run_discovery(void *arg)
{
	struct wtpman *wtpman = (struct wtpman *) arg;

	time_t timer = cw_timer_start(10);

	wtpman->conn->capwap_state = CAPWAP_STATE_DISCOVERY;


	while (!cw_timer_timeout(timer)
	       && wtpman->conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
		int rc;
		rc = cw_read_messages(wtpman->conn);
		if (cw_result_is_ok(rc)){
			wtpman->conn->capwap_state=CAPWAP_STATE_JOIN;
			
			cw_dbg(DBG_INFO,"Discovery has detected mods: %s %s", 
				wtpman->conn->cmod->name,wtpman->conn->bmod->name);

			wtplist_lock();
			discovery_cache_add(discovery_cache,(struct sockaddr*)&wtpman->conn->addr,
				wtpman->conn->cmod,wtpman->conn->bmod);
			wtplist_unlock();
			
		}
	}

	return;
}
Ejemplo n.º 3
0
Archivo: wtpman.c Proyecto: 7u83/actube
static void wtpman_remove(struct wtpman *wtpman)
{
	wtplist_lock();
	wtplist_remove(wtpman);
	wtplist_unlock();
	wtpman_destroy(wtpman);
}
Ejemplo n.º 4
0
Archivo: shell.c Proyecto: 7u83/actube
send_cmd(struct shelldata * sd, const char *cmd)
{
	struct conn * conn;
	wtplist_lock();
	conn = find_ap(sd->prompt);
	if (conn==NULL){
		fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
	}
	else {
		conn->update_cfg=sd->update_cfg;
	}
	wtplist_unlock();
}
Ejemplo n.º 5
0
Archivo: shell.c Proyecto: 7u83/actube
void cfg_cmd(struct shelldata *sd, const char *cmd)
{
	struct conn * conn;
	wtplist_lock();
	conn = find_ap(sd->prompt);
	if (conn==NULL){
		fprintf(sd->out,"WTP '%s' not found\n",sd->prompt);
	}
	else {
		show_cfg(sd->out,conn->remote_cfg);
	}
	wtplist_unlock();
}
Ejemplo n.º 6
0
Archivo: shell.c Proyecto: 7u83/actube
void con (FILE *out)
{
	struct connlist * cl;
	mavliter_t it;
	
	
	
	wtplist_lock();
	
	cl = wtplist_get_connlist();
	
	
	mavliter_init (&it, cl->by_addr);
	fprintf (out, "IP\t\t\twtp-name\n");
	mavliter_foreach (&it) {
		cw_KTV_t * result;
		char addr[SOCK_ADDR_BUFSIZE];
		char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
		struct conn * conn;
		conn = mavliter_get_ptr (&it);
		
		sock_addr2str_p (&conn->addr, addr);
		
		result = cw_ktv_get (conn->remote_cfg, "wtp-name", NULL);
		
		if (result == NULL) {
			strcpy (wtp_name, "");
			
		} else {
			result->type->to_str (result, wtp_name, CAPWAP_MAX_WTP_NAME_LEN);
		}
		
		
		fprintf (out, "Con!! %s\t\t%s\n", addr, wtp_name);
		
		{
			mavl_t update;
			update = cw_ktv_create();
			cw_ktv_set_byte(update,"radio.255/admin-state",1);
			conn->update_cfg=update;
		}


		fprintf(out,"\n");

	}
	wtplist_unlock();
}
Ejemplo n.º 7
0
void process_cw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer, int len)
{
	int sock = socklist[index].reply_sockfd;

	char hdrstr[1024];
	hdr_print(hdrstr,buffer,len);
	cw_log_debug2("Header for packet from %s\n%s",sock_addr2str(addr),hdrstr);
	


	/* first of all check preamble */
	int preamble = CWTH_GET_PREAMBLE(buffer);

#ifdef WITH_DTLS
	if (preamble != CAPWAP_PACKET_PREAMBLE && preamble != CAPWAP_DTLS_PACKET_PREAMBLE){
#else
	if (preamble != CAPWAP_PACKET_PREAMBLE ){
#endif
		cw_log_debug1("Discarding packet, wrong preamble, preamble = 0x%01X",preamble);
		return;
	}

	wtplist_lock();
	struct wtpman * wtpman = wtplist_get(addr);
	if (!wtpman){

		wtpman = wtpman_create(index,addr);

		if (!wtpman ){
			cw_log(LOG_ERR,"Error creating wtpman: %s",strerror(errno));
			wtplist_unlock();
			return;
		}
		

		if (!wtplist_add(wtpman)){
			cw_log(LOG_ERR,"Error adding wtpman: Too many wtp connections");
			wtpman_destroy(wtpman);
			wtplist_unlock();
			return;
		};

		wtpman_start(wtpman,preamble & 0xf);
	}


	wtpman_addpacket(wtpman,buffer,len);
	wtplist_unlock();
}



void process_lw_ctrl_packet(int index,struct sockaddr * addr, uint8_t * buffer, int len)
{
	int sock = socklist[index].reply_sockfd;

	uint8_t * m = buffer+6;
	uint32_t val = ntohl(*((uint32_t*)(m)));


	printf ("VAL: %08X\n",val);

	

	/* first of all check preamble */
	int version = LWTH_GET_VERSION(m);

	if (version != LW_VERSION){
		cw_log_debug1("Discarding LWAPP packet, wrong verson");
		return;
	}

	int l = LWTH_GET_LENGTH(m);
	printf ("LEN = %d\n",l);

	if (l+12 != len){
		cw_log_debug1("Discarding LWAPP packet, wrong length");
		return;
	}

	wtplist_lock();
	struct wtpman * wtpman = wtplist_get(addr);
	if (!wtpman){

		wtpman = wtpman_create(index,addr);

		if (!wtpman ){
			cw_log(LOG_ERR,"Error creating wtpman: %s",strerror(errno));
			wtplist_unlock();
			return;
		}
		

		if (!wtplist_add(wtpman)){
			cw_log(LOG_ERR,"Error adding wtpman: Too many wtp connections");
			wtpman_destroy(wtpman);
			wtplist_unlock();
			return;
		};

		wtpman_lw_start(wtpman);
	}

	wtpman_lw_addpacket(wtpman,buffer,len);
	wtplist_unlock();
}