Compare commits
	
		
			39 Commits
		
	
	
		
			e39f4eb097
			...
			cisco
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5423709dda | |||
| e974b3ae2d | |||
| 07257f51fe | |||
| dec1cf2003 | |||
| 40427b3816 | |||
| 435b3f823e | |||
| ae686f4634 | |||
| b292b88d49 | |||
| 97533f67cc | |||
| 259c6c5e66 | |||
| bc5dea6016 | |||
| ec6809b552 | |||
| 1297c46a15 | |||
| cc257ed27f | |||
| 059c0e542e | |||
| 9d3fa452aa | |||
| 300b737efd | |||
| 085e657c76 | |||
| f62b1c56e1 | |||
| acc7b692ee | |||
| 8a8381731f | |||
| 6f4ba62080 | |||
| 0eb3e16932 | |||
| ca4a6b9996 | |||
| 66db979fdb | |||
| 0078c07e58 | |||
| 20bd835f63 | |||
| 1e8b52fd03 | |||
| 2f1985b821 | |||
| 27506fa788 | |||
| 5ed35979cd | |||
| 2064f7dba1 | |||
| 190c94ded4 | |||
| 4fe2bae7f7 | |||
| 89e7e61e1d | |||
| 2b055175c7 | |||
| 0ebac6c98e | |||
| 15e363f34e | |||
| 2b6dc68ee5 | 
							
								
								
									
										58
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								README.md
									
									
									
									
									
								
							@ -2,6 +2,62 @@ AC-Tube
 | 
				
			|||||||
=======
 | 
					=======
 | 
				
			||||||
Open Source CAPWAP WLC + WTP
 | 
					Open Source CAPWAP WLC + WTP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Current status: early development.
 | 
					Current status: development.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
See also http://7u83.cauwersin.com/?cat=28
 | 
					See also http://7u83.cauwersin.com/?cat=28
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					What you can do so far ...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Read INSTALL and compile actube.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Then ...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Create certificates:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     cd ssl
 | 
				
			||||||
 | 
					     sh all.sh
 | 
				
			||||||
 | 
					     cd ..
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Edit src/actube/config.ckv and set your IP in
 | 
				
			||||||
 | 
					capwap/control-ip-address/address.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Start actube with some debug options:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     cd src/ac
 | 
				
			||||||
 | 
					     ./actube -d std -d mod -d elem\_detail -d elem\_dmp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you have an AP with IOS 7.3x it should connect. Others
 | 
				
			||||||
 | 
					might connect, too.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Make sure on the AP you heve made
 | 
				
			||||||
 | 
					clear capwap private-config.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					In another terminal window connect to the RPC interface:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     cd src/ac
 | 
				
			||||||
 | 
					     ./act -s 127.0.0.1:5000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Send some commands to bring up a WLAN:
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					     list                # list all connected APs
 | 
				
			||||||
 | 
					     select <apname>     # set <apname> to the name of AP you want to select
 | 
				
			||||||
 | 
					     status 		# show status of selected AP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     # the following sequence activates a WLAN called actube on AP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     load wlan1
 | 
				
			||||||
 | 
					     send
 | 
				
			||||||
 | 
					     clear
 | 
				
			||||||
 | 
					     load activate
 | 
				
			||||||
 | 
					     send
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					     status		# This should display now oper status for 
 | 
				
			||||||
 | 
								    # interface 0 enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CWAPWAP data layer is still not finished, so you can't use the WLAN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,35 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					 | 
				
			||||||
<CodeLite_Workspace Name="actube" Database="">
 | 
					 | 
				
			||||||
  <Project Name="ac" Path="ac.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="wtp" Path="wtp.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
 | 
					 | 
				
			||||||
  <Project Name="libcw" Path="libcw.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
 | 
					 | 
				
			||||||
  <Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
 | 
					 | 
				
			||||||
  <BuildMatrix>
 | 
					 | 
				
			||||||
    <WorkspaceConfiguration Name="Debug" Selected="yes">
 | 
					 | 
				
			||||||
      <Environment/>
 | 
					 | 
				
			||||||
      <Project Name="ac" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="wtp" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cipwap" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cisco" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="libcw" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap80211" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_fortinet" ConfigName="Debug"/>
 | 
					 | 
				
			||||||
    </WorkspaceConfiguration>
 | 
					 | 
				
			||||||
    <WorkspaceConfiguration Name="Release" Selected="yes">
 | 
					 | 
				
			||||||
      <Environment/>
 | 
					 | 
				
			||||||
      <Project Name="ac" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="wtp" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cipwap" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_cisco" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="libcw" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_capwap80211" ConfigName="Release"/>
 | 
					 | 
				
			||||||
      <Project Name="mod_fortinet" ConfigName="Release"/>
 | 
					 | 
				
			||||||
    </WorkspaceConfiguration>
 | 
					 | 
				
			||||||
  </BuildMatrix>
 | 
					 | 
				
			||||||
</CodeLite_Workspace>
 | 
					 | 
				
			||||||
@ -9,6 +9,7 @@ OBJS = \
 | 
				
			|||||||
	discovery_cache.o\
 | 
						discovery_cache.o\
 | 
				
			||||||
	rpc.o\
 | 
						rpc.o\
 | 
				
			||||||
	statemachine.o\
 | 
						statemachine.o\
 | 
				
			||||||
 | 
						#hapd.o
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ACTOBJS = \
 | 
					ACTOBJS = \
 | 
				
			||||||
	act.o 
 | 
						act.o 
 | 
				
			||||||
@ -26,11 +27,16 @@ LIBS+=-lnettle
 | 
				
			|||||||
LIBS+=-lssl
 | 
					LIBS+=-lssl
 | 
				
			||||||
LIBS+=-lcrypto
 | 
					LIBS+=-lcrypto
 | 
				
			||||||
LIBS+=-ledit
 | 
					LIBS+=-ledit
 | 
				
			||||||
 | 
					#LIBS+=-l:libhapd.a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INCL_DIRS=-I../ -I/usr/local/include -I./ -I../../include
 | 
					INCL_DIRS=-I../ -I/usr/local/include -I./ -I../../include -I../../include/hostapd -I../../include/hostapd/utils
 | 
				
			||||||
#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
 | 
					#FLAGS=-DWITH_IPV6 -DWITH_OPENSSL -DSYS_ARCH="$(ARCH)" -DSYS_ARCH="XXX"
 | 
				
			||||||
FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(KERNEL)/$(ARCH)"'
 | 
					FLAGS=-DWITH_IPV6 -DUSE_OPENSSL -DSYS_ARCH='"$(KERNEL)/$(ARCH)"'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: act actube
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					act: act.c
 | 
				
			||||||
 | 
						$(CC) act.c $(INCL_DIRS) $(LIBPATH) -DSYS_ARCH='"$(KERNEL)/$(ARCH)"' -o act -l:libcw.a -lasan -lcrypto -ledit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -43,8 +49,9 @@ all: $(PRG) $(ACTPRG)
 | 
				
			|||||||
$(PRG): $(OBJS) 
 | 
					$(PRG): $(OBJS) 
 | 
				
			||||||
	$(CC) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS) 
 | 
						$(CC) $(OBJS) -o $(PRG) $(LIBPATH) $(LDFLAGS) $(LIBS) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$(ACTPRG): $(ACTOBJS)
 | 
					#$(ACTPRG): $(ACTOBJS)
 | 
				
			||||||
	$(CC) $(ACTOBJS) -o $(ACTPRG) $(LIBPATH) $(LDFLAGS) $(LIBS) -ledit 
 | 
					#	$(CC) $(ACTOBJS) -o $(ACTPRG) $(LIBPATH) $(LIBS) -ledit  
 | 
				
			||||||
 | 
						#$(CC) $(ACTOBJS) $(ACTPRG) $(LIBPATH) $(LDFLAGS) $(LIBS) -ledit  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ enum {
 | 
				
			|||||||
int start_rpc(cw_Cfg_t *global_cfg);
 | 
					int start_rpc(cw_Cfg_t *global_cfg);
 | 
				
			||||||
int test_shell();
 | 
					int test_shell();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void hapd_run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -125,11 +125,22 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
 | 
				
			|||||||
				exit(EXIT_FAILURE);
 | 
									exit(EXIT_FAILURE);
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
			case 'h': 
 | 
								case 'h': 
 | 
				
			||||||
				printf("%s: -vcmh\n",argv[0]);
 | 
								{
 | 
				
			||||||
 | 
									FILE *out = stdout;
 | 
				
			||||||
 | 
									fprintf(out, "Usage:");
 | 
				
			||||||
 | 
									fprintf(out, "%s [ options ] ",argv[0]);
 | 
				
			||||||
 | 
									fprintf(out, "\nOptions are:\n");
 | 
				
			||||||
 | 
									fprintf(out, "  -c <file>:  specify a config file\n");
 | 
				
			||||||
 | 
									fprintf(out, "  -p <path>:  specify a path where to search for modules\n");
 | 
				
			||||||
 | 
									fprintf(out, "  -v:         print version information\n");
 | 
				
			||||||
 | 
									fprintf(out, "  -d <level>: set debug level, multiple -d's are possible\n"); 
 | 
				
			||||||
 | 
									fprintf(out, "    <level> can be one of these:\n");
 | 
				
			||||||
 | 
									cw_dbg_print_help(out,"    ");
 | 
				
			||||||
				exit(EXIT_SUCCESS);
 | 
									exit(EXIT_SUCCESS);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -200,6 +211,7 @@ return 0;
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cw_Cfg_t * global_cfg = NULL;
 | 
					static cw_Cfg_t * global_cfg = NULL;
 | 
				
			||||||
 | 
					void process_wtp_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len, int dta);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main (int argc, char *argv[])
 | 
					int main (int argc, char *argv[])
 | 
				
			||||||
@ -225,6 +237,12 @@ int main (int argc, char *argv[])
 | 
				
			|||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//hapd_run(); // init
 | 
				
			||||||
 | 
					//stop();
 | 
				
			||||||
 | 
					//const char *ttt = cw_cfg_get(global_cfg,"cisco/ssl-cipher",NULL);
 | 
				
			||||||
 | 
					//printf("CFG: %s\n",ttt);
 | 
				
			||||||
 | 
					//stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_log_name = "AC-Tube";
 | 
						cw_log_name = "AC-Tube";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@ -440,7 +458,7 @@ int ac_run(cw_Cfg_t * cfg)
 | 
				
			|||||||
				                        (struct sockaddr *) &srcaddr,
 | 
									                        (struct sockaddr *) &srcaddr,
 | 
				
			||||||
				                        &srcaddrlen);
 | 
									                        &srcaddrlen);
 | 
				
			||||||
				                        
 | 
									                        
 | 
				
			||||||
				process_cw_data_packet (i, (struct sockaddr *) &srcaddr, buffer, len);
 | 
									process_wtp_packet (i, (struct sockaddr *) &srcaddr, buffer, len,1);
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
@ -453,7 +471,7 @@ int ac_run(cw_Cfg_t * cfg)
 | 
				
			|||||||
				                        (struct sockaddr *) &srcaddr,
 | 
									                        (struct sockaddr *) &srcaddr,
 | 
				
			||||||
				                        &srcaddrlen);
 | 
									                        &srcaddrlen);
 | 
				
			||||||
				                        
 | 
									                        
 | 
				
			||||||
				process_ctrl_packet (i, (struct sockaddr *) &srcaddr, buffer, len);
 | 
									process_wtp_packet (i, (struct sockaddr *) &srcaddr, buffer, len,0);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -467,14 +485,14 @@ int ac_run(cw_Cfg_t * cfg)
 | 
				
			|||||||
void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len)
 | 
					void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
						char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
				
			||||||
	cw_dbg (DBG_X, "There is a data packet now");
 | 
					//	cw_dbg (DBG_X, "There is a data packet now");
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	dataman_list_lock();
 | 
						dataman_list_lock();
 | 
				
			||||||
	cw_dbg (DBG_X, "Dataman list locked, now getting");
 | 
					//	cw_dbg (DBG_X, "Dataman list locked, now getting");
 | 
				
			||||||
	struct dataman * dm = dataman_list_get (socklist[index].data_sockfd, addr);
 | 
						struct dataman * dm = dataman_list_get (socklist[index].data_sockfd, addr);
 | 
				
			||||||
	cw_dbg (DBG_X, "Dataman list locked, now gotted");
 | 
					//	cw_dbg (DBG_X, "Dataman list locked, now gotted");
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	cw_dbg (DBG_INFO, "Packet for dataman %s,%d", sock_addr2str_p (addr, sock_buf), socklist[index].data_sockfd);
 | 
					//	cw_dbg (DBG_INFO, "Packet for dataman %s,%d", sock_addr2str_p (addr, sock_buf), socklist[index].data_sockfd);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (!dm) {
 | 
						if (!dm) {
 | 
				
			||||||
		cw_dbg (DBG_INFO, "No dataman %s,%d", sock_addr2str_p (addr, sock_buf), socklist[index].data_sockfd);
 | 
							cw_dbg (DBG_INFO, "No dataman %s,%d", sock_addr2str_p (addr, sock_buf), socklist[index].data_sockfd);
 | 
				
			||||||
@ -486,15 +504,12 @@ void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		dataman_list_add (dm);
 | 
							dataman_list_add (dm);
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		dataman_start (dm);
 | 
							dataman_start (dm);
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	dataman_list_unlock();
 | 
						dataman_list_unlock();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//dataman_add_packet (dm, buffer, len);
 | 
						dataman_add_packet (dm, buffer, len);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -517,7 +532,7 @@ void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len)
 | 
					void process_wtp_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len, int dta)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
						char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@ -537,6 +552,10 @@ void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!wtpman) {
 | 
						if (!wtpman) {
 | 
				
			||||||
 | 
							if (dta){
 | 
				
			||||||
 | 
								cw_dbg(DBG_PKT_ERR,"Data packet w/o wtpman received, ignoring");
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		wtpman = wtpman_create (index, addr, preamble & 0xf, global_cfg);
 | 
							wtpman = wtpman_create (index, addr, preamble & 0xf, global_cfg);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@ -558,9 +577,12 @@ void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
 | 
				
			|||||||
		wtpman_start (wtpman, preamble & 0xf);
 | 
							wtpman_start (wtpman, preamble & 0xf);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//printf("Got Packet with len: %d\n",len);
 | 
						if(!dta)
 | 
				
			||||||
 | 
					 | 
				
			||||||
		wtpman_addpacket (wtpman, buffer, len);
 | 
							wtpman_addpacket (wtpman, buffer, len);
 | 
				
			||||||
 | 
						else{
 | 
				
			||||||
 | 
					//		cw_dbg(DBG_X,"Data packet received");
 | 
				
			||||||
 | 
							wtpman_datapacket (wtpman, buffer, len);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	wtplist_unlock();
 | 
						wtplist_unlock();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -631,7 +653,7 @@ void process_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, in
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	switch (socklist[index].ac_proto) {
 | 
						switch (socklist[index].ac_proto) {
 | 
				
			||||||
		case AC_PROTO_CAPWAP:
 | 
							case AC_PROTO_CAPWAP:
 | 
				
			||||||
			process_cw_ctrl_packet (index, addr, buffer, len);
 | 
					//			process_cw_ctrl_packet (index, addr, buffer, len);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		/*case AC_PROTO_LWAPP:
 | 
							/*case AC_PROTO_LWAPP:
 | 
				
			||||||
 | 
				
			|||||||
@ -15,10 +15,15 @@ capwap/ssl-dhbits: 1024
 | 
				
			|||||||
capwap/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
					capwap/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
				
			||||||
capwap/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
					capwap/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cisco/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
					#mod/cisco/ssl-keyfile:  "../../ssl/intermediate-ca/int-ca.key"
 | 
				
			||||||
cisco/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
					#mod/cisco/ssl-certfile: "../../ssl/intermediate-ca/int-ca.crt"
 | 
				
			||||||
cisco/ssl-cipher: DEFAULT
 | 
					#
 | 
				
			||||||
cisco/ssl-dhbits: 2048
 | 
					mod/cisco/ssl-keyfile:  "../../ssl/certs/ac-cisco.key"
 | 
				
			||||||
 | 
					mod/cisco/ssl-certfile: "../../ssl/certs/ac-cisco.pem"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#cisco/ssl-cipher: DEFAULT
 | 
				
			||||||
 | 
					mod/cisco/ssl-cipher: RSA
 | 
				
			||||||
 | 
					mod/cisco/ssl-dhbits: 2048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -48,6 +53,13 @@ actube/rpc/listen: tcp:127.0.0.1:5000
 | 
				
			|||||||
actube/rpc/enable: true
 | 
					actube/rpc/enable: true
 | 
				
			||||||
actube/rpc/macros-dir: ./rpc-macros
 | 
					actube/rpc/macros-dir: ./rpc-macros
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					# This catches the initial config af a connecting WTP
 | 
				
			||||||
 | 
					# From Discovery to CFG Update
 | 
				
			||||||
 | 
					# The config is saved to a file named
 | 
				
			||||||
 | 
					# wtp-<wtpname-or-ip>.cfg
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					actube/save-initial-wtp-config: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
capwap/ac-descriptor/dtls-policy:  1
 | 
					capwap/ac-descriptor/dtls-policy:  1
 | 
				
			||||||
capwap/ac-descriptor/hardware/vendor: 4232704
 | 
					capwap/ac-descriptor/hardware/vendor: 4232704
 | 
				
			||||||
@ -66,6 +78,18 @@ capwap/ac-descriptor/stations: 0
 | 
				
			|||||||
capwap/control-ip-address/address.0: 192.168.0.14
 | 
					capwap/control-ip-address/address.0: 192.168.0.14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wlan.0/capwap80211/capability: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key-index: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key-status: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/key: 1234
 | 
				
			||||||
 | 
					wlan.0/capwap80211/group-tcs: 123
 | 
				
			||||||
 | 
					wlan.0/capwap80211/qos: 0
 | 
				
			||||||
 | 
					wlan.0/capwap80211/auth-type: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/mac-mode: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/tunnel-mode: 1
 | 
				
			||||||
 | 
					wlan.0/capwap80211/suppress-ssid: false
 | 
				
			||||||
 | 
					wlan.0/capwap80211/ssid: ssid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# CAPWAP Timers
 | 
					# CAPWAP Timers
 | 
				
			||||||
@ -77,3 +101,74 @@ capwap/timers/max-discovery-interval: 10
 | 
				
			|||||||
capwap/decryption-error-report-period: 120
 | 
					capwap/decryption-error-report-period: 120
 | 
				
			||||||
capwap/idle-timeout: 300
 | 
					capwap/idle-timeout: 300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/current-cca-mode: 0
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/current-channel: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/direct-sequence-control/energy-detect-threshold: -50
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#mode-802.11g support
 | 
				
			||||||
 | 
					#radio-cfg-a/cisco/direct-sequence-control/unknown: 1     
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/fragmentation-threshold: 2346
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/long-retry: 4
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/reserved: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/rts-threshold: 2347
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/rx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/short-retry: 7
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/mac-operation/tx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/first-channel: 1
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/number-of-channels: 13
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/multi-domain-capability/reserved: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/capwap80211/rate-set: .x82848b960c1218243048606c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/802-11n-rx-antennas: 3
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/802-11n-tx-antennas: 7
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna-cnt: 2
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna-mode: 3
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna.0: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/antenna.1: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/diversity-selection: 255
 | 
				
			||||||
 | 
					radio-cfg-a/cisco/antenna-payload/unknown: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio-cfg-b/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										103
									
								
								src/ac/dataman.c
									
									
									
									
									
								
							
							
						
						
									
										103
									
								
								src/ac/dataman.c
									
									
									
									
									
								
							@ -5,10 +5,12 @@
 | 
				
			|||||||
#include "cw/timer.h"
 | 
					#include "cw/timer.h"
 | 
				
			||||||
#include "cw/cw.h"
 | 
					#include "cw/cw.h"
 | 
				
			||||||
#include "cw/format.h"
 | 
					#include "cw/format.h"
 | 
				
			||||||
#include "cw/netconn.h"
 | 
					#include "cw/conn.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/log.h"
 | 
					#include "cw/log.h"
 | 
				
			||||||
#include "cw/dbg.h"
 | 
					#include "cw/dbg.h"
 | 
				
			||||||
 | 
					#include "cw/file.h"
 | 
				
			||||||
 | 
					#include "cw/dot11.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "wtplist.h"
 | 
					#include "wtplist.h"
 | 
				
			||||||
#include "dataman.h"
 | 
					#include "dataman.h"
 | 
				
			||||||
@ -19,8 +21,8 @@ pthread_mutex_t dataman_list_mutex;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int cmp(const void *d1, const void *d2)
 | 
					static int cmp(const void *d1, const void *d2)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct netconn *nc1 = ((struct dataman *) d1)->nc;
 | 
						struct cw_Conn *nc1 = ((struct dataman *) d1)->nc;
 | 
				
			||||||
	struct netconn *nc2 = ((struct dataman *) d1)->nc;
 | 
						struct cw_Conn *nc2 = ((struct dataman *) d1)->nc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int r = nc1->sock - nc2->sock;
 | 
						int r = nc1->sock - nc2->sock;
 | 
				
			||||||
	if (r != 0)
 | 
						if (r != 0)
 | 
				
			||||||
@ -52,7 +54,7 @@ void dataman_destroy(struct dataman *dm)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	if (!dm)
 | 
						if (!dm)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	netconn_destroy(dm->nc);
 | 
						conn_destroy(dm->nc);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dataman *dataman_create(int sock, struct sockaddr *addr)
 | 
					struct dataman *dataman_create(int sock, struct sockaddr *addr)
 | 
				
			||||||
@ -60,15 +62,15 @@ struct dataman *dataman_create(int sock, struct sockaddr *addr)
 | 
				
			|||||||
	struct dataman *dm = malloc(sizeof(struct dataman));
 | 
						struct dataman *dm = malloc(sizeof(struct dataman));
 | 
				
			||||||
	if (!dm)
 | 
						if (!dm)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
						memset(dm,0,sizeof(struct dataman));
 | 
				
			||||||
	dm->nc = netconn_create(sock, addr, 100);
 | 
						dm->nc = cw_conn_create(sock, addr, 100);
 | 
				
			||||||
	return dm;
 | 
						return dm;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dataman *dataman_list_get(int sock, struct sockaddr *addr)
 | 
					struct dataman *dataman_list_get(int sock, struct sockaddr *addr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct netconn search_nc;
 | 
						struct cw_Conn search_nc;
 | 
				
			||||||
	struct dataman search_dm;
 | 
						struct dataman search_dm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	search_nc.sock = sock;
 | 
						search_nc.sock = sock;
 | 
				
			||||||
@ -78,7 +80,7 @@ struct dataman *dataman_list_get(int sock, struct sockaddr *addr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	struct dataman *dm = mavl_get(dataman_list, &search_dm);
 | 
						struct dataman *dm = mavl_get(dataman_list, &search_dm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"Getting dataman %p",dm); 
 | 
					//	cw_dbg(DBG_X,"Getting dataman %p",dm); 
 | 
				
			||||||
	return dm;
 | 
						return dm;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -91,7 +93,7 @@ struct dataman *dataman_list_add(struct dataman *dm)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
 | 
					int dataman_process_keep_alive(struct cw_Conn *nc, uint8_t *rawmsg, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct dataman * dm = (struct dataman *)(nc->data);
 | 
						struct dataman * dm = (struct dataman *)(nc->data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -133,7 +135,7 @@ int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
 | 
				
			|||||||
				printf("len len %d\n",l);
 | 
									printf("len len %d\n",l);
 | 
				
			||||||
				printf("Total len = %d\n",total_len);
 | 
									printf("Total len = %d\n",total_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				netconn_send_capwap_msg(nc,buffer,total_len);
 | 
									cw_send_msg(nc,buffer,total_len);
 | 
				
			||||||
				return len;
 | 
									return len;
 | 
				
			||||||
					
 | 
										
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -167,26 +169,87 @@ int dataman_process_keep_alive(struct netconn *nc, uint8_t *rawmsg, int len)
 | 
				
			|||||||
	return -1;	
 | 
						return -1;	
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dataman_process_message0(struct netconn *nc, uint8_t * rawmsg, int len,
 | 
					
 | 
				
			||||||
 | 
					int dataman_process_message0(struct cw_Conn *nc, uint8_t * rawmsg, int len,
 | 
				
			||||||
			struct sockaddr *from)
 | 
								struct sockaddr *from)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static int c=0;
 | 
				
			||||||
 | 
						char fn[100];
 | 
				
			||||||
 | 
						sprintf(fn,"wificap-%03d",c++);
 | 
				
			||||||
 | 
					///	cw_save_file(fn,(char*)rawmsg,len);
 | 
				
			||||||
 | 
					///	cw_dbg(DBG_X,"saving %d bytes",len);
 | 
				
			||||||
 | 
						int offs =  cw_get_hdr_msg_offset(rawmsg);
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
						uint8_t * dot11frame = rawmsg + offs;
 | 
				
			||||||
 | 
						int dot11len = len-offs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"802.11 - %s",dot11_get_frame_name(dot11frame));
 | 
				
			||||||
 | 
					//	extern void ppacket(uint8_t * p, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					//	ppacket (dot11frame,len-cw_get_hdr_msg_offset(rawmsg));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"802.11 - %s",dot11_get_frame_name(dot11frame));
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"802.11 - T&S: %d %d",dot11_get_type(dot11frame),dot11_get_subtype(dot11frame));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"Frame CTL:%d,%d",frame.frame_control.type, frame.frame_control.subtype);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"CMP???CTL:%d,%d (%d,%d)",frame.frame_control.type, frame.frame_control.subtype,
 | 
				
			||||||
 | 
					//			TYPE_MANAGEMENT,SUBTYPE_ASSOC_REQ);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					//	char ffr[1024];
 | 
				
			||||||
 | 
					//	cw_format_dot11_hdr(ffr,dot11frame,dot11len);	
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,ffr);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	/* The very first data message MUST be a keep-alive message */
 | 
						/* The very first data message MUST be a keep-alive message */
 | 
				
			||||||
	if (!cw_get_hdr_flag_k(rawmsg)){
 | 
						if (!cw_get_hdr_flag_k(rawmsg)){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//		cw_dbg(DBG_X,"No K Flag founde");
 | 
				
			||||||
		errno = EAGAIN;
 | 
							errno = EAGAIN;
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X, "Goto Keep Alive Pack");
 | 
				
			||||||
	return dataman_process_keep_alive(nc,rawmsg,len);
 | 
						return dataman_process_keep_alive(nc,rawmsg,len);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dataman_process_message(struct netconn *nc, uint8_t * rawmsg, int len,
 | 
					int dataman_process_message(struct cw_Conn *nc, uint8_t * rawmsg, int len,
 | 
				
			||||||
			struct sockaddr *from)
 | 
								struct sockaddr *from)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (cw_get_hdr_flag_k(rawmsg)){
 | 
						if (cw_get_hdr_flag_k(rawmsg)){
 | 
				
			||||||
		return dataman_process_keep_alive(nc,rawmsg,len);
 | 
							return dataman_process_keep_alive(nc,rawmsg,len);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						static int c=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						char fn[100];
 | 
				
			||||||
 | 
						sprintf(fn,"wificap-%03d",c++);
 | 
				
			||||||
 | 
						cw_save_file(fn,(char*)rawmsg,len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						extern void ppacket(uint8_t * p, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	ppacket (rawmsg,len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"There was someting else than dataman");
 | 
						cw_dbg(DBG_X,"There was someting else than dataman");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -195,12 +258,22 @@ void dataman_run(struct dataman *dm)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	time_t timer = cw_timer_start(2);
 | 
						time_t timer = cw_timer_start(2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dm->nc->process_packet=netconn_process_packet;
 | 
						dm->nc->process_packet=conn_process_packet;
 | 
				
			||||||
	dm->nc->process_message=dataman_process_message0;
 | 
						dm->nc->process_message=dataman_process_message0;
 | 
				
			||||||
	dm->nc->data = dm;
 | 
						dm->nc->data = dm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (1){
 | 
				
			||||||
 | 
							time_t timer = cw_timer_start(2);
 | 
				
			||||||
		while (!cw_timer_timeout(timer)){
 | 
							while (!cw_timer_timeout(timer)){
 | 
				
			||||||
		netconn_read_messages(dm->nc);
 | 
								cw_read_messages(dm->nc);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (!cw_timer_timeout(timer)){
 | 
				
			||||||
 | 
							cw_read_messages(dm->nc);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!dm->wtpman){
 | 
						if (!dm->wtpman){
 | 
				
			||||||
@ -215,7 +288,7 @@ void dataman_run(struct dataman *dm)
 | 
				
			|||||||
	while (1){
 | 
						while (1){
 | 
				
			||||||
		time_t timer = cw_timer_start(2);
 | 
							time_t timer = cw_timer_start(2);
 | 
				
			||||||
		while (!cw_timer_timeout(timer)){
 | 
							while (!cw_timer_timeout(timer)){
 | 
				
			||||||
			netconn_read_messages(dm->nc);
 | 
								cw_read_messages(dm->nc);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,12 +3,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <pthread.h>
 | 
					#include <pthread.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*#include "cw/netconn.h"*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "wtpman.h"
 | 
					#include "wtpman.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dataman {
 | 
					struct dataman {
 | 
				
			||||||
	struct netconn *nc;
 | 
						struct cw_Conn *nc;
 | 
				
			||||||
	pthread_t thread;
 | 
						pthread_t thread;
 | 
				
			||||||
	struct wtpman * wtpman;
 | 
						struct wtpman * wtpman;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -28,6 +27,6 @@ extern pthread_mutex_t dataman_list_mutex;
 | 
				
			|||||||
#define dataman_list_lock() pthread_mutex_lock(&dataman_list_mutex)
 | 
					#define dataman_list_lock() pthread_mutex_lock(&dataman_list_mutex)
 | 
				
			||||||
#define dataman_list_unlock() pthread_mutex_unlock(&dataman_list_mutex)
 | 
					#define dataman_list_unlock() pthread_mutex_unlock(&dataman_list_mutex)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define dataman_add_packet(dm,data,len) (netconn_q_add_packet(dm->nc,data,len))
 | 
					#define dataman_add_packet(dm,data,len) (conn_q_add_packet(dm->nc,data,len))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/activate.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/activate.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					radio.255/capwap/operational-state/state: enabled
 | 
				
			||||||
 | 
					radio.255/capwap/admin-state: 1
 | 
				
			||||||
 | 
					radio.0/capwap/operational-state/state: enabled
 | 
				
			||||||
 | 
					radio.0/capwap/admin-state: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/admin-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/admin-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap/admin-state: 1
 | 
				
			||||||
							
								
								
									
										60
									
								
								src/ac/rpc-macros/all.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								src/ac/rpc-macros/all.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,60 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/air-space-capability: 0
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-rx-antennas: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-tx-antennas: 7
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-cnt: 2
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-mode: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.0: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.1: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/diversity-selection: 255
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/unknown: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/channel-power: .x08080d0108221c16100a04fefe0208221c16100a04fefe0308221c16100a04fefe0408221c16100a04fefe0508221c16100a04fefe0608221c16100a04fefe0708221c16100a04fefe0808221c16100a04fefe0908221c16100a04fefe0a08221c16100a04fefe0b08221c16100a04fefe0c08221c16100a04fefe0d08221c16100a04fefe
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap80211/rate-set: .x82848b960c1218243048606c
 | 
				
			||||||
 | 
					radio.0/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.0/capwap80211/tx-power/current-tx-power: 1
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/bssid: .x04fe7f499b90
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-information: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/long-retry: 4
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/reserved: 1
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rts-threshold: 2347
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/short-retry: 7
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/tx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/first-channel: 1
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/number-of-channels: 13
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/reserved: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/asel-cap: 0
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/extended-ht-cap-info: .x0000
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/ht-cap-info: 6
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/mcsrates-1: .x00000000
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/mcsrates-2: .x00000000
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/mcsrates-3: .x00000000
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/mcsrates-4: .x0000ffff
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-cap/tx-bf-cap: .x00000000
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/channel-width: 20
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/cur-freq-is-dfs-channel: 0
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/current-freq: 1
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/enable-ht: 3
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/ext-channel: 0
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/flash-commit: 0
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/frequency-bands-support: 206
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/rest: .x00ffffff
 | 
				
			||||||
 | 
					radio.0/cisco/phy-ht-control/ti-threshold: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								src/ac/rpc-macros/antenna.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/ac/rpc-macros/antenna.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					radio.0/cisco/air-space-capability: 0
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-rx-antennas: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-tx-antennas: 7
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-cnt: 2
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-mode: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.0: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.1: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/diversity-selection: 255
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/unknown: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/led-off.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/led-off.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-led-state-config/led-state: 0
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/led-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/led-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-led-state-config/led-state: 1
 | 
				
			||||||
							
								
								
									
										8
									
								
								src/ac/rpc-macros/macopts.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/ac/rpc-macros/macopts.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					radio.0/cisco/mac-operation/fragmentation-threshold: 2346
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/long-retry: 4
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/reserved: 1
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rts-threshold: 2347
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/short-retry: 7
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/tx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/oper-off.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/oper-off.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap/operational-state/state: disabled
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/oper-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/oper-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap/operational-state/state: enabled
 | 
				
			||||||
							
								
								
									
										13
									
								
								src/ac/rpc-macros/radio.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/ac/rpc-macros/radio.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					radio.0/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.0/capwap80211/tx-power/current-tx-power: 1
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/bssid: .x04fe7f499b90
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-information: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										89
									
								
								src/ac/rpc-macros/sr.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								src/ac/rpc-macros/sr.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,89 @@
 | 
				
			|||||||
 | 
					capwap/timers/echo-interval: 30
 | 
				
			||||||
 | 
					capwap/timers/max-discovery-interval: 10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.255/capwap/admin-state: 1 - enabled
 | 
				
			||||||
 | 
					radio.0/capwap/admin-state: 1 - enabled
 | 
				
			||||||
 | 
					radio.1/capwap/admin-state: 1 - enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap/decryption-error-report-period: 120
 | 
				
			||||||
 | 
					radio.1/capwap/decryption-error-report-period: 120
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					capwap/idle-timeout: 300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					capwap/wtp-fallback: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/spam-domain-secret: .xe1ffd18a8f15b3b59c0a47a7f17a96e7cb36174f00
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/beacon-period: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-period: 4
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfg-type: 1
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str1: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/country-str2: "DE "
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/occupancy-limit: 100
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-config/reg: 167772416
 | 
				
			||||||
 | 
					radio.0/capwap80211/wtp-radio-information: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap80211/rate-set: .x82848b960c1218243048606c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/first-channel: 1
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/number-of-channels: 13
 | 
				
			||||||
 | 
					radio.0/cisco/multi-domain-capability/reserved: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/fragmentation-threshold: 2346
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/long-retry: 4
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/reserved: 1
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rts-threshold: 2347
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/rx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/short-retry: 7
 | 
				
			||||||
 | 
					radio.0/cisco/mac-operation/tx-msdu-lifetime: 512
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.1/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.1/capwap80211/tx-power/current-tx-power: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/direct-sequence-control/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.0/cisco/direct-sequence-control/current-cca-mode: 0
 | 
				
			||||||
 | 
					radio.0/cisco/direct-sequence-control/current-channel: 1
 | 
				
			||||||
 | 
					radio.0/cisco/direct-sequence-control/energy-detect-threshold: -50
 | 
				
			||||||
 | 
					radio.0/cisco/direct-sequence-control/unknown: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-rx-antennas: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/802-11n-tx-antennas: 7
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-cnt: 2
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna-mode: 3
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.0: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/antenna.1: 1 - Internal Antenna
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/diversity-selection: 255
 | 
				
			||||||
 | 
					radio.0/cisco/antenna-payload/unknown: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/air-space-capability: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/capwap/operational-state/cause: Normal
 | 
				
			||||||
 | 
					radio.0/capwap/operational-state/state: enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/80211h/count: 0
 | 
				
			||||||
 | 
					radio.0/cisco/80211h/enable: 0
 | 
				
			||||||
 | 
					radio.0/cisco/80211h/mode: 0
 | 
				
			||||||
 | 
					radio.0/cisco/80211h/power: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.0/cisco/elem153: .x00
 | 
				
			||||||
 | 
					radio.0/cisco/elem156: .x020100
 | 
				
			||||||
 | 
					radio.0/cisco/lwelem48: .x01055a0101a6c405b06432b03232
 | 
				
			||||||
 | 
					radio.1/cisco/lwelem33: .x00
 | 
				
			||||||
 | 
					radio.0/cisco/elem146: .x690f
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					radio.255/capwap/operational-state/cause: Normal
 | 
				
			||||||
 | 
					radio.255/capwap/operational-state/state: enabled
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/bcast-ssid-mode: 1
 | 
				
			||||||
 | 
					capwap/timers/max-discovery-interval: 10
 | 
				
			||||||
 | 
					capwap/timers/echo-interval: 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/client-auto-handoff: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/lwelem14: .x000001000000000000000000000000000000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/telnet-off.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/telnet-off.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-telnet-ssh/telnet: false
 | 
				
			||||||
							
								
								
									
										5
									
								
								src/ac/rpc-macros/telnet-on.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/ac/rpc-macros/telnet-on.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#
 | 
				
			||||||
 | 
					# Managed by acTube
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cisco/ap-telnet-ssh/telnet: true
 | 
				
			||||||
							
								
								
									
										3
									
								
								src/ac/rpc-macros/txp.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/ac/rpc-macros/txp.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					radio.0/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
				
			||||||
 | 
					radio.0/capwap80211/tx-power/current-tx-power: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										17
									
								
								src/ac/rpc-macros/wlan.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/ac/rpc-macros/wlan.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
				
			|||||||
 | 
					radio.0/wlan.1/capwap80211/capability: 1073
 | 
				
			||||||
 | 
					radio.0/wlan.1/capwap80211/qos: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/capwap80211/ssid: tubeC
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/aironet-ie: true
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/broadcast-ssid: true
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/dtim-period: 1
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/encryption-policy: 4
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/hreap-local-switch: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/profile-name: tubeC
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/scan-defer-period: 28784
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/scan-defer-time: 100
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/session-timout: 1800
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/wep-encryption: false
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/wep-key: .xc3e9d4b1360d7cf5bcfc759753
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/wep-key-index: 1
 | 
				
			||||||
 | 
					radio.0/wlan.1/radio-id: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/wlan-id: 1
 | 
				
			||||||
							
								
								
									
										14
									
								
								src/ac/rpc-macros/wlan1.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/ac/rpc-macros/wlan1.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					radio.0/wlan.1/capwap80211/capability: 1057
 | 
				
			||||||
 | 
					radio.0/wlan.1/capwap80211/ssid: actube
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/allow-aaa-override: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/broadcast-ssid: true
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/dtim-period: 1
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/encryption-policy: 16777216
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/max-stations: 200
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/profile-name: ACTUBE
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/session-timout: 1800
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/wep-encryption: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/cisco/wep-key: .x00000000000000000000000000
 | 
				
			||||||
 | 
					radio.0/wlan.1/radio-id: 0
 | 
				
			||||||
 | 
					radio.0/wlan.1/wlan-id: 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										18
									
								
								src/ac/rpc-macros/wlan13.ckv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/ac/rpc-macros/wlan13.ckv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					radio.0/wlan.13/capwap80211/capability: 1057
 | 
				
			||||||
 | 
					radio.0/wlan.13/capwap80211/qos: 0
 | 
				
			||||||
 | 
					radio.0/wlan.13/capwap80211/ssid: SuperSSID
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/aironet-ie: true
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/broadcast-ssid: true
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/dtim-period: 19
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/encryption-policy: 1
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/hreap-local-switch: 16
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/profile-name: SuerWLAN
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/scan-defer-period: 15420
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/scan-defer-time: 100
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/session-timout: 1800
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-encryption: false
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-key: .x55d80f0e2bf5223dd10f82407b
 | 
				
			||||||
 | 
					radio.0/wlan.13/cisco/wep-key-index: 1
 | 
				
			||||||
 | 
					radio.0/wlan.13/radio-id: 0
 | 
				
			||||||
 | 
					radio.0/wlan.13/wlan-id: 13
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										162
									
								
								src/ac/rpc.c
									
									
									
									
									
								
							
							
						
						
									
										162
									
								
								src/ac/rpc.c
									
									
									
									
									
								
							@ -159,10 +159,6 @@ int list_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int exit_cmd(struct rpcdata *sd, const char *cmd)
 | 
					int exit_cmd(struct rpcdata *sd, const char *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
		//fprintf(sd->out,"Unknown command: '%s'\n\r\n\r",cmd);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	printf("Exitcmd %s\n",cmd);
 | 
					 | 
				
			||||||
	//fprintf(sd->out,"END: %s\n\r",cmd);
 | 
					 | 
				
			||||||
	finish_cmd(sd->out);
 | 
						finish_cmd(sd->out);
 | 
				
			||||||
	fflush(sd->out);
 | 
						fflush(sd->out);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
@ -290,7 +286,6 @@ send_cmd(struct rpcdata * sd, const char *cmd)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		fprintf(sd->out, "Sending update cmd\n");
 | 
							fprintf(sd->out, "Sending update cmd\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//		conn->update_cfg=sd->update_cfg;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
errX:	
 | 
					errX:	
 | 
				
			||||||
	wtplist_unlock();
 | 
						wtplist_unlock();
 | 
				
			||||||
@ -311,8 +306,6 @@ wlan0_cmd(struct rpcdata * sd, const char *cmd)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
		FILE *f=fopen("wlan0.ktv","r");
 | 
							FILE *f=fopen("wlan0.ktv","r");
 | 
				
			||||||
//		cw_ktv_read_file(f,sd->update_cfg,conn->msgset->types_tree);
 | 
					 | 
				
			||||||
		//conn->update_cfg=sd->update_cfg;
 | 
					 | 
				
			||||||
		fclose(f);
 | 
							fclose(f);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	wtplist_unlock();
 | 
						wtplist_unlock();
 | 
				
			||||||
@ -395,31 +388,6 @@ int del_cmd(struct rpcdata *sd, const char *str)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
void show_cfg (FILE *out, mavl_t ktv)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char value[500];
 | 
					 | 
				
			||||||
	struct cw_Val * data;
 | 
					 | 
				
			||||||
	mavliter_t it;
 | 
					 | 
				
			||||||
	const struct cw_Type * type;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	mavliter_init(&it,ktv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	mavliter_foreach(&it){
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		data = mavliter_get(&it);
 | 
					 | 
				
			||||||
		type = data->type;
 | 
					 | 
				
			||||||
		type->to_str(data,value,0);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		fprintf(out,"%s :%s: %s\n",data->key,type->get_type_name(data), value);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void print_mw(FILE *f, int w, const char * str)
 | 
					void print_mw(FILE *f, int w, const char * str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int n,i;
 | 
						int n,i;
 | 
				
			||||||
@ -505,62 +473,6 @@ struct cw_Conn * find_ap(const char *name)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void con (FILE *out)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	
 | 
					 | 
				
			||||||
	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_Val_t * result;
 | 
					 | 
				
			||||||
		char addr[SOCK_ADDR_BUFSIZE];
 | 
					 | 
				
			||||||
		char wtp_name[CAPWAP_MAX_WTP_NAME_LEN];
 | 
					 | 
				
			||||||
		struct cw_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);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			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();
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct command * find_cmd(const char *cmd)
 | 
					struct command * find_cmd(const char *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct command * search,*result;
 | 
						struct command * search,*result;
 | 
				
			||||||
@ -585,7 +497,6 @@ int execute_cmd (struct rpcdata * sd, const char *str)
 | 
				
			|||||||
	char cmd[1024];
 | 
						char cmd[1024];
 | 
				
			||||||
	char args[1024];
 | 
						char args[1024];
 | 
				
			||||||
	int n;
 | 
						int n;
 | 
				
			||||||
	struct cw_Val_Reader reader;
 | 
					 | 
				
			||||||
	struct command * searchcmd;
 | 
						struct command * searchcmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	args[0]=0;
 | 
						args[0]=0;
 | 
				
			||||||
@ -619,72 +530,7 @@ int execute_cmd (struct rpcdata * sd, const char *str)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	char type[128];
 | 
					 | 
				
			||||||
	char val[2048];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	key[0]=0;
 | 
					 | 
				
			||||||
	type[0]=0;
 | 
					 | 
				
			||||||
	val[0]=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	stop();
 | 
					 | 
				
			||||||
//	cw_ktv_init_str_reader(&reader,str, strlen(str));
 | 
					 | 
				
			||||||
//	n = cw_ktv_parse_string(&reader, key,type,val);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (n==-1){
 | 
					 | 
				
			||||||
		int i;
 | 
					 | 
				
			||||||
		fprintf(sd->out,"Error on pos %d\n",reader.pos);
 | 
					 | 
				
			||||||
		fprintf(sd->out,"%s",str);
 | 
					 | 
				
			||||||
		for(i=0;i<reader.pos;i++){
 | 
					 | 
				
			||||||
			fprintf(sd->out," ");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		fprintf(sd->out,"^\n");
 | 
					 | 
				
			||||||
		fprintf(sd->out,"%s\n",reader.error);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		fprintf(sd->out,"%s :%s: %s\n", key,type,val);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	n = sscanf (str, "%s%s", cmd, args);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (n<=0)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	/*printf("CMD: %s, ARGS:\n",cmd);*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (strcmp (cmd, "s") == 0) {
 | 
					 | 
				
			||||||
		show_aps (sd->out);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (strcmp (cmd, "con")==0){
 | 
					 | 
				
			||||||
		con(sd->out);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct esc_strings {
 | 
					 | 
				
			||||||
	char *str;
 | 
					 | 
				
			||||||
	char * result;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct esc_strings estr[] = {
 | 
					 | 
				
			||||||
	{"\x1b[H", "home"},
 | 
					 | 
				
			||||||
	{"\x1b[F", "end"},
 | 
					 | 
				
			||||||
	{"\x1b[A", "up"},
 | 
					 | 
				
			||||||
	{"\x1b[B", "donw"},
 | 
					 | 
				
			||||||
	{"\x1b[D", "left"},
 | 
					 | 
				
			||||||
	{"\x1b[C", "right"},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{NULL,NULL}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -751,9 +597,6 @@ void * run_rpc_server (void * arg)
 | 
				
			|||||||
			close (clientsock);
 | 
								close (clientsock);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		//cw_dbg (DBG_INFO,"Accepting shell session %i, %s", rc, strerror (errno));
 | 
					 | 
				
			||||||
	}	
 | 
						}	
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
@ -793,8 +636,6 @@ int create_tcp_fd(const char *name)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
static int create_unix_fd(const char *name)
 | 
					static int create_unix_fd(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        //struct sockaddr_storage client;
 | 
					 | 
				
			||||||
	//socklen_t client_size;
 | 
					 | 
				
			||||||
	struct sockaddr_un addr;
 | 
						struct sockaddr_un addr;
 | 
				
			||||||
	int rc,fd;
 | 
						int rc,fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -808,7 +649,6 @@ static int create_unix_fd(const char *name)
 | 
				
			|||||||
		cw_log (LOG_ERR, "Can't bind socket 'unix:%s', %s", name, strerror (errno));
 | 
							cw_log (LOG_ERR, "Can't bind socket 'unix:%s', %s", name, strerror (errno));
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	//int clientsock = accept (fd, (struct sockaddr*) &client, &client_size);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return fd;
 | 
						return fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -817,7 +657,7 @@ int start_rpc(cw_Cfg_t *global_cfg)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct sockdata * sockdata;
 | 
						struct sockdata * sockdata;
 | 
				
			||||||
	const char *sockname;
 | 
						const char *sockname;
 | 
				
			||||||
	int rc; //, type;
 | 
						int rc; 
 | 
				
			||||||
	int fd;
 | 
						int fd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = cw_cfg_get_bool(global_cfg,"actube/rpc/enable",1);
 | 
						rc = cw_cfg_get_bool(global_cfg,"actube/rpc/enable",1);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										257
									
								
								src/ac/wtpman.c
									
									
									
									
									
								
							
							
						
						
									
										257
									
								
								src/ac/wtpman.c
									
									
									
									
									
								
							@ -44,6 +44,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "actube.h"
 | 
					#include "actube.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cw/dot11.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void wtpman_remove(struct wtpman *wtpman)
 | 
					static void wtpman_remove(struct wtpman *wtpman)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -310,6 +312,79 @@ int run_update(struct wtpman *wtpman)
 | 
				
			|||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int dataman_process_msg(struct cw_Conn *nc, uint8_t * rawmsg, int len,
 | 
				
			||||||
 | 
								struct sockaddr *from)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char rframe[1000];
 | 
				
			||||||
 | 
						int offs =  cw_get_hdr_msg_offset(rawmsg);
 | 
				
			||||||
 | 
						uint8_t * frame = rawmsg + offs;
 | 
				
			||||||
 | 
						int frame_len = len-offs;
 | 
				
			||||||
 | 
						cw_dbg_dot11_frame(frame,frame_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*	dot11_init_assoc_resp(frame);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dot11_copy_mac(dot11_get_sa(dot11frame),dot11_get_da(frame));
 | 
				
			||||||
 | 
						dot11_copy_mac(dot11_get_bssid(dot11frame),dot11_get_bssid(frame));
 | 
				
			||||||
 | 
						dot11_copy_mac(dot11_get_da(dot11frame),dot11_get_sa(frame));
 | 
				
			||||||
 | 
						dot11_set_seq(frame,0);
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
						if ( dot11_get_type_and_subtype(frame) == DOT11_ASSOC_REQ){
 | 
				
			||||||
 | 
							int l;
 | 
				
			||||||
 | 
							uint8_t rates[] = {
 | 
				
			||||||
 | 
								12,0x82,0x84,0x8b,0x96,0x0c,0x12,0x18,0x24,0x30,0x48,0x60,0x6c	
 | 
				
			||||||
 | 
							}; 
 | 
				
			||||||
 | 
							cw_dbg(DBG_X, "there is an assoc request!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							uint8_t  rframe[1000];
 | 
				
			||||||
 | 
							nc->mtu=800;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        	dot11_init_assoc_resp(rframe);
 | 
				
			||||||
 | 
							dot11_set_duration(rframe,100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							dot11_copy_mac(dot11_get_sa(frame),dot11_get_da(rframe));
 | 
				
			||||||
 | 
							dot11_copy_mac(dot11_get_bssid(frame),dot11_get_bssid(rframe));
 | 
				
			||||||
 | 
							dot11_copy_mac(dot11_get_da(frame),dot11_get_sa(rframe));
 | 
				
			||||||
 | 
							dot11_set_seq(rframe,dot11_get_seq(frame));
 | 
				
			||||||
 | 
							dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame));
 | 
				
			||||||
 | 
							dot11_assoc_resp_set_status_code(rframe,0);
 | 
				
			||||||
 | 
							dot11_assoc_resp_set_assoc_id(rframe,17);
 | 
				
			||||||
 | 
							l=24+6;
 | 
				
			||||||
 | 
							l+=dot11_put_supported_rates(rframe+l,rates);
 | 
				
			||||||
 | 
							cw_dbg_dot11_frame(rframe,l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							uint8_t buf[1024];
 | 
				
			||||||
 | 
							int hlen;
 | 
				
			||||||
 | 
							hlen = cw_init_capwap_packet(buf,1,0,NULL,NULL);
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf, CAPWAP_FLAG_HDR_T, 1);
 | 
				
			||||||
 | 
							cw_send_capwap_packet(nc,buf,hlen,rframe,l);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void *wtpman_data_main(void *arg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct wtpman * wtpman = arg;
 | 
				
			||||||
 | 
						struct cw_Conn * nc = wtpman->dconn;
 | 
				
			||||||
 | 
						nc->process_packet=conn_process_packet;
 | 
				
			||||||
 | 
						nc->process_message=dataman_process_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while (1){
 | 
				
			||||||
 | 
							time_t timer = cw_timer_start(2);
 | 
				
			||||||
 | 
							while (!cw_timer_timeout(timer)){
 | 
				
			||||||
 | 
								cw_read_messages(nc);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void *wtpman_main(void *arg)
 | 
					static void *wtpman_main(void *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	//mavl_t r;
 | 
						//mavl_t r;
 | 
				
			||||||
@ -415,54 +490,107 @@ static void copy(struct cw_ElemHandlerParams * params)
 | 
				
			|||||||
        cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
 | 
					        cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static void catch_cfg(struct cw_ElemHandlerParams * params, int create, const char *format, ...)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						const char *wtpname;
 | 
				
			||||||
	char filename[200];
 | 
						char filename[200];
 | 
				
			||||||
 | 
						FILE *f;
 | 
				
			||||||
 | 
						cw_Cfg_t * cfg_list[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!cw_cfg_get_bool(params->conn->global_cfg,"actube/save-initial-wtp-config",0))
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cfg_list[0]=params->cfg;
 | 
				
			||||||
 | 
						cfg_list[1]=params->conn->remote_cfg;
 | 
				
			||||||
 | 
						cfg_list[2]=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wtpname = cw_cfg_get_l(cfg_list,"capwap/wtp-name","default");
 | 
				
			||||||
 | 
						sprintf(filename,"wtp-initial-%s.ckv",wtpname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (create)		
 | 
				
			||||||
 | 
							f = fopen(filename,"w");
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							f = fopen(filename,"a");
 | 
				
			||||||
 | 
						if (f==NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (create)
 | 
				
			||||||
 | 
							fprintf(f,"#\n# Initial config for WTP '%s' - catched by ACTube\n#\n\n",wtpname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (format !=NULL){
 | 
				
			||||||
 | 
					                va_list args;
 | 
				
			||||||
 | 
					                va_start(args,format);
 | 
				
			||||||
 | 
					                vfprintf(f,format,args);
 | 
				
			||||||
 | 
					                va_end(args);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
						cw_cfg_write_to_file(f, params->cfg);
 | 
				
			||||||
 | 
						fclose(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data * d)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"DISCOVERY Callback");
 | 
						cw_dbg(DBG_X,"DISCOVERY Callback");
 | 
				
			||||||
	copy(params);
 | 
						copy(params);
 | 
				
			||||||
 | 
						catch_cfg(params,1,"\n#\n# Discovery Request\n#\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
					 | 
				
			||||||
	sprintf(filename,"wtp-discovery-%s.ckv",wtpname);
 | 
					 | 
				
			||||||
	cw_cfg_save(filename,params->cfg,NULL);
 | 
					 | 
				
			||||||
	cw_cfg_clear(params->cfg);
 | 
						cw_cfg_clear(params->cfg);
 | 
				
			||||||
 | 
						if (d->parent)
 | 
				
			||||||
 | 
							return d->parent->fun(params,d->parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int join_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						catch_cfg(params,0,"\n#\n# Join Request\n#\n");
 | 
				
			||||||
	char filename[200];
 | 
						if (d->parent)
 | 
				
			||||||
 | 
							return d->parent->fun(params,d->parent);
 | 
				
			||||||
	cw_dbg(DBG_X,"JOIN Callback");
 | 
					 | 
				
			||||||
	copy(params);
 | 
					 | 
				
			||||||
	const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
					 | 
				
			||||||
	sprintf(filename,"wtp-join-%s.ckv",wtpname);
 | 
					 | 
				
			||||||
	cw_cfg_save(filename,params->cfg,NULL);
 | 
					 | 
				
			||||||
	cw_cfg_clear(params->cfg);
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					static int fill_update_cfg(struct cw_Conn * conn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Cfg_iter cfi;
 | 
				
			||||||
	char filename[200];
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
 | 
						cw_Cfg_t * u;
 | 
				
			||||||
 | 
						u=cw_cfg_create();
 | 
				
			||||||
 | 
						if( cw_cfg_load("status_response.ckv",u)){
 | 
				
			||||||
 | 
							cw_log(LOG_ERR,"Cant load file");
 | 
				
			||||||
 | 
							stop();
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						cw_cfg_dump(conn->remote_cfg);
 | 
				
			||||||
 | 
					        cw_cfg_iter_init(u, &cfi, NULL);
 | 
				
			||||||
 | 
						while ((e = cw_cfg_iter_next(&cfi, NULL))!=NULL){
 | 
				
			||||||
 | 
							const char * r;
 | 
				
			||||||
 | 
							r = cw_cfg_get(conn->remote_cfg, e->key, "[]");
 | 
				
			||||||
 | 
						//	cw_dbg(DBG_CFG_UPDATES,"check: %s: %s",e->key,e->val);
 | 
				
			||||||
 | 
							if (strcmp(r,e->val)==0)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_dbg(DBG_CFG_UPDATES,"Status reps: %s: %s -> %s",e->key,r,e->val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"UPDATE Callback");
 | 
					static int cfg_status_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
	copy(params);
 | 
					{
 | 
				
			||||||
 | 
						catch_cfg(params,0,"\n#\n# Configuration Status Request\n#\n");
 | 
				
			||||||
	const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
 | 
						if (d->parent)
 | 
				
			||||||
	sprintf(filename,"wtp-status-%s.ckv",wtpname);
 | 
							return d->parent->fun(params,d->parent);
 | 
				
			||||||
	cw_cfg_save(filename,params->cfg,NULL);
 | 
					 | 
				
			||||||
//stop();	
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int event_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
	struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
						struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
				
			||||||
@ -480,7 +608,7 @@ static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, i
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int change_state_event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int change_state_event_cb(struct cw_ElemHandlerParams * params,struct cw_MsgCb_data * d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
						struct cw_Conn * conn = (struct cw_Conn*)params->conn;
 | 
				
			||||||
	struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
						struct wtpman * wtpman = (struct wtpman *)conn->data;
 | 
				
			||||||
@ -507,7 +635,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct sockaddr dbgaddr;
 | 
						struct sockaddr dbgaddr;
 | 
				
			||||||
	socklen_t dbgaddrl;
 | 
						socklen_t dbgaddrl;
 | 
				
			||||||
	int sockfd, replyfd;
 | 
						int sockfd, replyfd, data_sockfd,data_replyfd;
 | 
				
			||||||
	char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
						char sock_buf[SOCK_ADDR_BUFSIZE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wtpman *wtpman;
 | 
						struct wtpman *wtpman;
 | 
				
			||||||
@ -521,6 +649,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		int port = sock_getport(&socklist[socklistindex].addr);
 | 
							int port = sock_getport(&socklist[socklistindex].addr);
 | 
				
			||||||
		replyfd = socklist_find_reply_socket(srcaddr, port);
 | 
							replyfd = socklist_find_reply_socket(srcaddr, port);
 | 
				
			||||||
 | 
							data_replyfd=replyfd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (replyfd == -1) {
 | 
							if (replyfd == -1) {
 | 
				
			||||||
			cw_log(LOG_ERR,
 | 
								cw_log(LOG_ERR,
 | 
				
			||||||
@ -531,10 +660,11 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		replyfd = socklist[socklistindex].sockfd;
 | 
							replyfd = socklist[socklistindex].sockfd;
 | 
				
			||||||
 | 
							data_replyfd = socklist[socklistindex].data_sockfd;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sockfd = replyfd;	/*//socklist[socklistindex].reply_sockfd; */
 | 
						sockfd = replyfd;	/*//socklist[socklistindex].reply_sockfd; */
 | 
				
			||||||
 | 
						data_sockfd = data_replyfd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dbgaddrl = sizeof(dbgaddr);
 | 
						dbgaddrl = sizeof(dbgaddr);
 | 
				
			||||||
	getsockname(sockfd, &dbgaddr, &dbgaddrl);
 | 
						getsockname(sockfd, &dbgaddr, &dbgaddrl);
 | 
				
			||||||
@ -552,6 +682,21 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
		wtpman_destroy(wtpman);
 | 
							wtpman_destroy(wtpman);
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						wtpman->dconn = cw_conn_create(data_sockfd, srcaddr, 100);
 | 
				
			||||||
 | 
						if (!wtpman->dconn) {
 | 
				
			||||||
 | 
							wtpman_destroy(wtpman);
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
							CAPWAP_MSG_DISCOVERY_REQUEST,
 | 
				
			||||||
 | 
							discovery_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wtpman->conn->global_cfg = global_cfg;
 | 
						wtpman->conn->global_cfg = global_cfg;
 | 
				
			||||||
	wtpman->conn->local_cfg = cw_cfg_create();
 | 
						wtpman->conn->local_cfg = cw_cfg_create();
 | 
				
			||||||
	wtpman->wtp_cfg = cw_cfg_create();
 | 
						wtpman->wtp_cfg = cw_cfg_create();
 | 
				
			||||||
@ -559,6 +704,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	wtpman->conn->role = CW_ROLE_AC;
 | 
						wtpman->conn->role = CW_ROLE_AC;
 | 
				
			||||||
	wtpman->conn->data=wtpman;
 | 
						wtpman->conn->data=wtpman;
 | 
				
			||||||
 | 
						wtpman->dconn->data=wtpman;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wtpman->conn->cfg_list[0]=wtpman->conn->update_cfg;
 | 
						wtpman->conn->cfg_list[0]=wtpman->conn->update_cfg;
 | 
				
			||||||
	wtpman->conn->cfg_list[1]=wtpman->conn->remote_cfg;
 | 
						wtpman->conn->cfg_list[1]=wtpman->conn->remote_cfg;
 | 
				
			||||||
@ -571,27 +717,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
	sock_copyaddr(&wtpman->conn->data_addr,
 | 
						sock_copyaddr(&wtpman->conn->data_addr,
 | 
				
			||||||
		      (struct sockaddr *) &wtpman->conn->addr);
 | 
							      (struct sockaddr *) &wtpman->conn->addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_DISCOVERY_REQUEST,
 | 
					 | 
				
			||||||
			discovery_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_JOIN_REQUEST,
 | 
					 | 
				
			||||||
			join_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
 | 
					 | 
				
			||||||
			update_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_WTP_EVENT_REQUEST,
 | 
					 | 
				
			||||||
			event_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_conn_set_msg_cb(wtpman->conn,
 | 
					 | 
				
			||||||
			CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST,
 | 
					 | 
				
			||||||
			change_state_event_cb);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	wtpman->conn->mods = conf_mods;
 | 
					//	wtpman->conn->mods = conf_mods;
 | 
				
			||||||
@ -625,15 +750,37 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
			       cmod->name, bmod->name);
 | 
								       cmod->name, bmod->name);
 | 
				
			||||||
			wtpman->conn->msgset =
 | 
								wtpman->conn->msgset =
 | 
				
			||||||
			    cw_mod_get_msg_set(wtpman->conn, cmod, bmod);
 | 
								    cw_mod_get_msg_set(wtpman->conn, cmod, bmod);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								wtpman->dconn->msgset=wtpman->conn->msgset;
 | 
				
			||||||
			wtpman->conn->detected = 1;
 | 
								wtpman->conn->detected = 1;
 | 
				
			||||||
			cmod->setup_cfg(wtpman->conn);
 | 
								cmod->setup_cfg(wtpman->conn);
 | 
				
			||||||
//	               if (wtpman->conn->setup_complete)
 | 
					//	               if (wtpman->conn->setup_complete)
 | 
				
			||||||
//        	                wtpman->conn->setup_complete(wtpman->conn);
 | 
					//        	                wtpman->conn->setup_complete(wtpman->conn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_JOIN_REQUEST,
 | 
				
			||||||
 | 
									join_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
 | 
				
			||||||
 | 
									cfg_status_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_WTP_EVENT_REQUEST,
 | 
				
			||||||
 | 
									event_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*		cw_conn_register_msg_cb(wtpman->conn,
 | 
				
			||||||
 | 
									CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST,
 | 
				
			||||||
 | 
									change_state_event_cb);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
 | 
						cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return wtpman;
 | 
						return wtpman;
 | 
				
			||||||
@ -642,7 +789,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
 | 
					void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
//	cw_dbg(DBG_X,"ADD PACKET DETECTED %d",wtpman->conn->detected);
 | 
					 | 
				
			||||||
	conn_q_add_packet(wtpman->conn, packet, len);
 | 
						conn_q_add_packet(wtpman->conn, packet, len);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -651,5 +797,14 @@ void wtpman_start(struct wtpman *wtpman, int dtlsmode)
 | 
				
			|||||||
	cw_dbg(DBG_INFO, "Starting wtpman, DTLS mode = %d", dtlsmode);
 | 
						cw_dbg(DBG_INFO, "Starting wtpman, DTLS mode = %d", dtlsmode);
 | 
				
			||||||
	wtpman->dtlsmode = dtlsmode;
 | 
						wtpman->dtlsmode = dtlsmode;
 | 
				
			||||||
	pthread_create(&wtpman->thread, NULL, wtpman_main, (void *) wtpman);
 | 
						pthread_create(&wtpman->thread, NULL, wtpman_main, (void *) wtpman);
 | 
				
			||||||
 | 
						pthread_create(&wtpman->thread, NULL, wtpman_data_main, (void *) wtpman);
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void wtpman_datapacket(struct wtpman *wtpman, uint8_t * packet, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						conn_q_add_packet(wtpman->dconn, packet, len);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -17,6 +17,7 @@ struct wtpman {
 | 
				
			|||||||
	pthread_t thread;
 | 
						pthread_t thread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct cw_Conn *conn;
 | 
						struct cw_Conn *conn;
 | 
				
			||||||
 | 
						struct cw_Conn *dconn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* wtp data */
 | 
						/* wtp data */
 | 
				
			||||||
@ -40,6 +41,11 @@ struct wtpman {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * wtp_cfg;
 | 
						cw_Cfg_t * wtp_cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_Cfg_t * discovery_cfg;
 | 
				
			||||||
 | 
						cw_Cfg_t * join_cfg;
 | 
				
			||||||
 | 
						cw_Cfg_t * config_status_cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int update;	
 | 
						int update;	
 | 
				
			||||||
	int ctr;
 | 
						int ctr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@ -62,6 +68,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
 | 
				
			|||||||
extern void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len);
 | 
					extern void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len);
 | 
				
			||||||
extern void wtpman_destroy(struct wtpman *wtpman);
 | 
					extern void wtpman_destroy(struct wtpman *wtpman);
 | 
				
			||||||
extern void wtpman_start(struct wtpman *wtpman, int dtlsmode);
 | 
					extern void wtpman_start(struct wtpman *wtpman, int dtlsmode);
 | 
				
			||||||
 | 
					void wtpman_datapacket(struct wtpman *wtpman, uint8_t * packet, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								src/contrib/install_hostapd.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/contrib/install_hostapd.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wget https://w1.fi/releases/hostapd-2.10.tar.gz
 | 
				
			||||||
 | 
					tar xzvf hostapd-2.10.tar.gz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -6,9 +6,6 @@ CWSRC=\
 | 
				
			|||||||
	cw.c\
 | 
						cw.c\
 | 
				
			||||||
	cw_check_missing_mand.c\
 | 
						cw_check_missing_mand.c\
 | 
				
			||||||
	cw_clock_lap.c\
 | 
						cw_clock_lap.c\
 | 
				
			||||||
	cw_dbg_elem.c\
 | 
					 | 
				
			||||||
	cw_dbg_set_level.c\
 | 
					 | 
				
			||||||
	cw_dbg_set_level_from_str.c\
 | 
					 | 
				
			||||||
	cw_filename.c\
 | 
						cw_filename.c\
 | 
				
			||||||
	cw_format_dump.c\
 | 
						cw_format_dump.c\
 | 
				
			||||||
	cw_format_pkt_hdr.c\
 | 
						cw_format_pkt_hdr.c\
 | 
				
			||||||
@ -60,6 +57,7 @@ CWSRC=\
 | 
				
			|||||||
	cw_type_word.c\
 | 
						cw_type_word.c\
 | 
				
			||||||
	cw_type_sysptr.c\
 | 
						cw_type_sysptr.c\
 | 
				
			||||||
	cw_type_array.c\
 | 
						cw_type_array.c\
 | 
				
			||||||
 | 
						cw_type_bits.c\
 | 
				
			||||||
	cw_write_descriptor_subelem.c\
 | 
						cw_write_descriptor_subelem.c\
 | 
				
			||||||
	cw_write_radio_element.c\
 | 
						cw_write_radio_element.c\
 | 
				
			||||||
	cw_detect_nat.c\
 | 
						cw_detect_nat.c\
 | 
				
			||||||
@ -78,6 +76,7 @@ CWSRC=\
 | 
				
			|||||||
	cw_in_radio_generic_struct.c\
 | 
						cw_in_radio_generic_struct.c\
 | 
				
			||||||
	cw_in_generic_struct.c\
 | 
						cw_in_generic_struct.c\
 | 
				
			||||||
	cw_radio_set_admin_state.c\
 | 
						cw_radio_set_admin_state.c\
 | 
				
			||||||
 | 
						cw_dbg_elem.c\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
KTVSRC=\
 | 
					KTVSRC=\
 | 
				
			||||||
	cfg.c\
 | 
						cfg.c\
 | 
				
			||||||
@ -135,7 +134,8 @@ LOGSRC=\
 | 
				
			|||||||
	log_errno.c\
 | 
						log_errno.c\
 | 
				
			||||||
	log_syslog.c\
 | 
						log_syslog.c\
 | 
				
			||||||
	dbg.c\
 | 
						dbg.c\
 | 
				
			||||||
	dbg_strings.c\
 | 
					
 | 
				
			||||||
 | 
					#	dbg_strings.c\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MISCSRC=\
 | 
					MISCSRC=\
 | 
				
			||||||
	bstr16_create.c\
 | 
						bstr16_create.c\
 | 
				
			||||||
@ -171,7 +171,6 @@ MISCSRC=\
 | 
				
			|||||||
	msgset.c\
 | 
						msgset.c\
 | 
				
			||||||
	send.c\
 | 
						send.c\
 | 
				
			||||||
	strheap.c\
 | 
						strheap.c\
 | 
				
			||||||
	netconn.c\
 | 
					 | 
				
			||||||
	conn.c \
 | 
						conn.c \
 | 
				
			||||||
	val.c \
 | 
						val.c \
 | 
				
			||||||
	discovery.c\
 | 
						discovery.c\
 | 
				
			||||||
@ -188,6 +187,7 @@ MISCSRC=\
 | 
				
			|||||||
#	cw_put_msg.c\
 | 
					#	cw_put_msg.c\
 | 
				
			||||||
#	conn_process_packet.c\
 | 
					#	conn_process_packet.c\
 | 
				
			||||||
#	conn_destroy.c\
 | 
					#	conn_destroy.c\
 | 
				
			||||||
 | 
						netconn.c\
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DTLSSRC+=\
 | 
					DTLSSRC+=\
 | 
				
			||||||
	dtls_bio.c\
 | 
						dtls_bio.c\
 | 
				
			||||||
 | 
				
			|||||||
@ -467,7 +467,7 @@ enum cw_reboot_failure_types {
 | 
				
			|||||||
 * WTP to the AC when the AC List is missing */
 | 
					 * WTP to the AC when the AC List is missing */
 | 
				
			||||||
#define CW_RESULT_MISSING_AC_LIST					1
 | 
					#define CW_RESULT_MISSING_AC_LIST					1
 | 
				
			||||||
#define CAPWAP_RESULT_SUCCESS_NAT					2
 | 
					#define CAPWAP_RESULT_SUCCESS_NAT					2
 | 
				
			||||||
#define CW_RESULT_JOIN_FAILURE					3
 | 
					#define CAPWAP_RESULT_JOIN_FAILURE					3
 | 
				
			||||||
#define CW_RESULT_JOIN_RESOURCE_DEPLETION			4
 | 
					#define CW_RESULT_JOIN_RESOURCE_DEPLETION			4
 | 
				
			||||||
#define CW_RESULT_JOIN_UNKNOWN_SOURCE				5
 | 
					#define CW_RESULT_JOIN_UNKNOWN_SOURCE				5
 | 
				
			||||||
#define CW_RESULT_JOIN_INCORRECT_DATA				6
 | 
					#define CW_RESULT_JOIN_INCORRECT_DATA				6
 | 
				
			||||||
@ -491,7 +491,7 @@ enum cw_reboot_failure_types {
 | 
				
			|||||||
      13 Configuration Failure (Unable to Apply Requested Configuration
 | 
					      13 Configuration Failure (Unable to Apply Requested Configuration
 | 
				
			||||||
         - Service Not Provided)
 | 
					         - Service Not Provided)
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT PROVIDED	13
 | 
					#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT_PROVIDED	13
 | 
				
			||||||
/** 
 | 
					/** 
 | 
				
			||||||
 * Image Data Error (Invalid Checksum)
 | 
					 * Image Data Error (Invalid Checksum)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
				
			|||||||
@ -86,6 +86,9 @@ enum radioelems {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** IEEE 802.11 Add WLAN Message element */
 | 
				
			||||||
 | 
					#define	CAPWAP80211_ELEM_ADD_WLAN			1024
 | 
				
			||||||
/** IEEE 802.11 Antenna Message element */
 | 
					/** IEEE 802.11 Antenna Message element */
 | 
				
			||||||
#define CAPWAP80211_ELEM_ANTENNA			1025
 | 
					#define CAPWAP80211_ELEM_ANTENNA			1025
 | 
				
			||||||
/** IEEE 802.11 WTP Radio Configuration */
 | 
					/** IEEE 802.11 WTP Radio Configuration */
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										65
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							
							
						
						
									
										65
									
								
								src/cw/cfg.c
									
									
									
									
									
								
							@ -154,7 +154,6 @@ const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def)
 | 
				
			|||||||
	int i;
 | 
						int i;
 | 
				
			||||||
	struct cw_Cfg_entry e, *r;
 | 
						struct cw_Cfg_entry e, *r;
 | 
				
			||||||
	for(i=0; cfg[i]!=NULL; i++){
 | 
						for(i=0; cfg[i]!=NULL; i++){
 | 
				
			||||||
//		cw_dbg(DBG_X,"GET_L IN: %p",cfg[i]);
 | 
					 | 
				
			||||||
		e.key = key;
 | 
							e.key = key;
 | 
				
			||||||
		r = mavl_get(cfg[i]->cfg, &e);
 | 
							r = mavl_get(cfg[i]->cfg, &e);
 | 
				
			||||||
		if (r!=NULL)
 | 
							if (r!=NULL)
 | 
				
			||||||
@ -176,12 +175,30 @@ bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def)
 | 
				
			|||||||
	const char *s;
 | 
						const char *s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s = cw_cfg_get(cfg,key,def);
 | 
						s = cw_cfg_get(cfg,key,def);
 | 
				
			||||||
 | 
						if(s==NULL)
 | 
				
			||||||
 | 
							s=def;
 | 
				
			||||||
	if (s==NULL)
 | 
						if (s==NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return bstr16_create_from_str(s);
 | 
						return bstr16_create_from_str(s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						bstr16_t s;
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(i=0; cfgs[i]!=NULL; i++){
 | 
				
			||||||
 | 
							s = cw_cfg_get_bstr16(cfgs[i],key,NULL);
 | 
				
			||||||
 | 
							if (s!=NULL)
 | 
				
			||||||
 | 
								return s;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (def == NULL)
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
						return bstr16_create_from_str(def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str)
 | 
					int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL);
 | 
						CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL);
 | 
				
			||||||
@ -584,6 +601,11 @@ void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base)
 | 
				
			|||||||
	search.key = base;
 | 
						search.key = base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mavliter_init(&(cfi->it), cfg->cfg);
 | 
						mavliter_init(&(cfi->it), cfg->cfg);
 | 
				
			||||||
 | 
						if (base == NULL){
 | 
				
			||||||
 | 
							mavliter_seek_set(&(cfi->it));
 | 
				
			||||||
 | 
							mavliter_next(&(cfi->it));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
		mavliter_seek(&(cfi->it), &search, 0);
 | 
							mavliter_seek(&(cfi->it), &search, 0);
 | 
				
			||||||
	cfi->base = base;
 | 
						cfi->base = base;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -593,13 +615,13 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Cfg_entry *e;
 | 
						struct cw_Cfg_entry *e;
 | 
				
			||||||
	int bl, kl;
 | 
						int bl, kl;
 | 
				
			||||||
	const char *d;
 | 
					//	const char *d;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	e = mavliter_get(&(cfi->it));
 | 
						e = mavliter_get(&(cfi->it));
 | 
				
			||||||
	if (e == NULL){
 | 
						if (e == NULL){
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if (cfi->base ==NULL)
 | 
				
			||||||
 | 
							goto eeX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bl = strlen(cfi->base);
 | 
						bl = strlen(cfi->base);
 | 
				
			||||||
	kl = strlen(e->key);
 | 
						kl = strlen(e->key);
 | 
				
			||||||
@ -615,15 +637,19 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	d = strchr(e->key, '.');
 | 
					
 | 
				
			||||||
 | 
						if (e->key[bl]!='.' && e->key[bl]!='/')
 | 
				
			||||||
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*	d = strchr(e->key, '.');
 | 
				
			||||||
	if (d == NULL)
 | 
						if (d == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	if (d - e->key != bl)
 | 
						if (d - e->key != bl)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (strncmp(cfi->base, e->key, bl) != 0)
 | 
						if (strncmp(cfi->base, e->key, bl) != 0)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					eeX:
 | 
				
			||||||
	mavliter_next(&(cfi->it));
 | 
						mavliter_next(&(cfi->it));
 | 
				
			||||||
	return e;
 | 
						return e;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -639,7 +665,13 @@ int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, int def)
 | 
				
			|||||||
	return v.val.boolean;
 | 
						return v.val.boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					int cw_cfg_set_bool(cw_Cfg_t * cfg, const char * key, int val)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_cfg_set(cfg,key,val ? "true":"false");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def)
 | 
					uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Val v;
 | 
						struct cw_Val v;
 | 
				
			||||||
@ -662,6 +694,14 @@ uint8_t cw_cfg_get_byte_l(cw_Cfg_t ** cfgs, char *key, uint8_t def)
 | 
				
			|||||||
	return v.val.byte;
 | 
						return v.val.byte;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						const char *s = cw_cfg_get(cfg,key,NULL);
 | 
				
			||||||
 | 
						if (s==NULL)
 | 
				
			||||||
 | 
							return def;
 | 
				
			||||||
 | 
						return atoi(s);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
 | 
					uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
 | 
				
			||||||
@ -686,7 +726,6 @@ uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, const char *key, uint16_t def)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
 | 
					int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -739,9 +778,9 @@ int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n)
 | 
				
			|||||||
	char ikey[CW_CFG_MAX_KEY_LEN];
 | 
						char ikey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	struct cw_Cfg_entry search, * result;
 | 
						struct cw_Cfg_entry search, * result;
 | 
				
			||||||
	char *d;
 | 
						char *d;
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	sprintf(ikey,"%s.%d",key,n);
 | 
						sprintf(ikey,"%s.%d",key,n);
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	search.key=ikey;
 | 
						search.key=ikey;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	result = mavl_get_first(cfg->cfg,&search);
 | 
						result = mavl_get_first(cfg->cfg,&search);
 | 
				
			||||||
@ -749,15 +788,15 @@ int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n)
 | 
				
			|||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d = strrchr(result->key,'.');
 | 
						d = strrchr(ikey,'.');
 | 
				
			||||||
	if (d==NULL){
 | 
						if (d==NULL){
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						l = d-ikey;
 | 
				
			||||||
	if (strncmp(result->key,ikey,d-result->key)!=0)
 | 
						if (strncmp(result->key,ikey,l)!=0)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return atoi(d+1);
 | 
						return atoi(result->key+l+1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n)
 | 
					int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n)
 | 
				
			||||||
 | 
				
			|||||||
@ -89,10 +89,15 @@ void cw_cfg_del(cw_Cfg_t * cfg, const char *key);
 | 
				
			|||||||
int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
 | 
					int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
 | 
				
			||||||
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
 | 
					int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def);
 | 
				
			||||||
 | 
					int cw_cfg_write_to_file(FILE *f, cw_Cfg_t * cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define cw_cfg_set_bool(cfg,key,val) \
 | 
				
			||||||
 | 
							cw_cfg_set(cfg,key,(val) ? "true":"false")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
 | 
					int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
 | 
				
			||||||
 | 
					bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define cw_cfg_get_word2(cfg1,cfg2,key,def) \
 | 
					#define cw_cfg_get_word2(cfg1,cfg2,key,def) \
 | 
				
			||||||
	cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def))
 | 
						cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def))
 | 
				
			||||||
 | 
				
			|||||||
@ -24,11 +24,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "dtls.h"
 | 
					#include "dtls.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define MAX_MSG_CBS 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct msg_callback{
 | 
					struct msg_callback{
 | 
				
			||||||
	int type; 			/**< message type */
 | 
						int type; 			/**< message type */
 | 
				
			||||||
	cw_MsgCallbackFun fun;
 | 
						struct cw_MsgCb_data data[MAX_MSG_CBS];
 | 
				
			||||||
 | 
						int count;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int msg_callback_cmp(const void *v1,const void *v2)
 | 
					int msg_callback_cmp(const void *v1,const void *v2)
 | 
				
			||||||
@ -62,19 +63,55 @@ void cw_conn_init(struct cw_Conn * conn)
 | 
				
			|||||||
	conn->remote_cfg = cw_cfg_create();
 | 
						conn->remote_cfg = cw_cfg_create();
 | 
				
			||||||
	conn->local_cfg = cw_cfg_create();
 | 
						conn->local_cfg = cw_cfg_create();
 | 
				
			||||||
	conn->cfg_list[0]=NULL;
 | 
						conn->cfg_list[0]=NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						conn->remote_addr[0]=0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Register a message callback function. 
 | 
				
			||||||
 | 
					 * @param conn the connection the registered cb functions belongs to
 | 
				
			||||||
 | 
					 * @param type The associated msg type. Whenever a message of this type is 
 | 
				
			||||||
 | 
					 *             received, the callback function will be called
 | 
				
			||||||
 | 
					 * @param fun  A pinter to the callback function          
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct msg_callback cb;
 | 
						struct msg_callback cb, *result;
 | 
				
			||||||
	int exists;
 | 
						int exists;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cb.type = type;
 | 
						cb.type = type;
 | 
				
			||||||
	cb.fun = fun;
 | 
						cb.data[0].fun = fun;
 | 
				
			||||||
	mavl_insert(conn->msg_callbacks,&cb,&exists);
 | 
						cb.data[0].parent = NULL;
 | 
				
			||||||
 | 
						cb.count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						result = mavl_insert(conn->msg_callbacks,&cb,&exists);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_X, "Registering msg callback: %d %p",type,result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (result==NULL)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (exists){
 | 
				
			||||||
 | 
							if (result->count>=MAX_MSG_CBS){
 | 
				
			||||||
 | 
								cw_log(LOG_ERROR,"Too many msg callback registrations for msg id %d",type);
 | 
				
			||||||
 | 
								return 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							result->count++;
 | 
				
			||||||
 | 
							result->data[result->count].fun=fun;
 | 
				
			||||||
 | 
							result->data[result->count].parent=&(result->data[result->count-1]);
 | 
				
			||||||
 | 
							cw_dbg(DBG_X,"The result exists: %p %p %d %p",result,&cb,result->count,
 | 
				
			||||||
 | 
									result->data[result->count].parent
 | 
				
			||||||
 | 
									);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
					cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct msg_callback cb,*result;
 | 
						struct msg_callback cb,*result;
 | 
				
			||||||
@ -83,8 +120,22 @@ cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
 | 
				
			|||||||
	if (result == NULL)
 | 
						if (result == NULL)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	return result->fun;
 | 
						return result->fun;
 | 
				
			||||||
 | 
					}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_conn_run_msg_cbs(struct cw_Conn * conn, int type, struct cw_ElemHandlerParams *params)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct msg_callback cb,*result;
 | 
				
			||||||
 | 
						cb.type=type;
 | 
				
			||||||
 | 
						result = mavl_get(conn->msg_callbacks,&cb);
 | 
				
			||||||
 | 
						if (result == NULL)
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
 | 
						return result->data[result->count].fun(params,&(result->data[result->count]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Create a conn object
 | 
					 * Create a conn object
 | 
				
			||||||
 * @param sock a socket
 | 
					 * @param sock a socket
 | 
				
			||||||
@ -106,8 +157,10 @@ struct cw_Conn * cw_conn_create(int sock, struct sockaddr * addr, int qsize)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	conn->sock=sock;
 | 
						conn->sock=sock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (addr)
 | 
						if (addr){
 | 
				
			||||||
		sock_copyaddr(&conn->addr,addr);
 | 
							sock_copyaddr(&conn->addr,addr);
 | 
				
			||||||
 | 
							sock_addr2str_p(addr, conn->remote_addr);	
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conn->fragman = fragman_create();
 | 
						conn->fragman = fragman_create();
 | 
				
			||||||
@ -516,12 +569,12 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
 | 
				
			|||||||
		message->postprocess(¶ms,elems_ptr, elems_len);
 | 
							message->postprocess(¶ms,elems_ptr, elems_len);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
 | 
						result_code = cw_conn_run_msg_cbs(conn,message->type,¶ms);
 | 
				
			||||||
	if (cb_fun != NULL){
 | 
					
 | 
				
			||||||
		result_code = cb_fun(¶ms,elems_ptr, elems_len);
 | 
					//	cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
 | 
				
			||||||
	}
 | 
						if (result_code==-1){
 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		cw_cfg_clear(conn->update_cfg);
 | 
							cw_cfg_clear(conn->update_cfg);
 | 
				
			||||||
 | 
							result_code=0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	conn->remote_cfg=params.cfg;
 | 
					//	conn->remote_cfg=params.cfg;
 | 
				
			||||||
@ -554,7 +607,6 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
 | 
				
			|||||||
		 * Put further actions here, if needed.
 | 
							 * Put further actions here, if needed.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (params.unrecognized)
 | 
						if (params.unrecognized)
 | 
				
			||||||
		mlist_destroy(params.unrecognized);
 | 
							mlist_destroy(params.unrecognized);
 | 
				
			||||||
	cw_cfg_destroy(params.cfg);
 | 
						cw_cfg_destroy(params.cfg);
 | 
				
			||||||
@ -713,24 +765,22 @@ int conn_process_packet2(struct cw_Conn *conn, uint8_t * packet, int len,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (cw_get_hdr_flag_f(packet)) {
 | 
						if (cw_get_hdr_flag_f(packet)) {
 | 
				
			||||||
		/* fragmented, add the packet to fragman */
 | 
							/* fragmented, add the packet to fragman */
 | 
				
			||||||
		uint8_t *f;
 | 
							uint8_t *f,*fp;
 | 
				
			||||||
		int rc;
 | 
							int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		f = fragman_add(conn->fragman, packet, offs, payloadlen);
 | 
							fp = fragman_add(conn->fragman, packet, offs, payloadlen);
 | 
				
			||||||
		if (f == NULL) {
 | 
							if (fp == NULL) {
 | 
				
			||||||
			errno = EAGAIN;
 | 
								errno = EAGAIN;
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							f =fp+MAX_PKT_HDR_LEN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		cw_dbg_pkt(DBG_PKT_IN, conn, f + 4, *(uint32_t *) f, from);
 | 
							cw_dbg_pkt(DBG_PKT_IN, conn, fp, *(uint32_t *) f+MAX_PKT_HDR_LEN, from);
 | 
				
			||||||
/*//		cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from);*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*		// XXX: Modify fragman to not throw away CAPWAP headers*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rc = conn->process_message(conn, f + 4, *(uint32_t *) f, from);
 | 
							rc = conn->process_message(conn, f + 4, *(uint32_t *) f, from);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		free(f);
 | 
							free(fp);
 | 
				
			||||||
		return rc;
 | 
							return rc;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -58,6 +58,8 @@ struct cw_action_in;
 | 
				
			|||||||
struct cw_Conn {
 | 
					struct cw_Conn {
 | 
				
			||||||
	int sock;
 | 
						int sock;
 | 
				
			||||||
	struct sockaddr_storage addr;
 | 
						struct sockaddr_storage addr;
 | 
				
			||||||
 | 
						char remote_addr[64];	/* Contains a printfable string, of the connections
 | 
				
			||||||
 | 
									   peer address */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct connlist * connlist;
 | 
						struct connlist * connlist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -71,19 +73,19 @@ struct cw_Conn {
 | 
				
			|||||||
	int recv_timeout;
 | 
						int recv_timeout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * global_cfg;	/**< This should set the global cfg of the program
 | 
						cw_Cfg_t * global_cfg;	/**< This should set to the global cfg of the program
 | 
				
			||||||
				     which is using this conn object.
 | 
									     which is using this conn object.
 | 
				
			||||||
				     Teh global_cfg has to be treated read-only. */
 | 
									     Teh global_cfg has to be treated read-only. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * local_cfg;	/**< local_cfg contains overrides for global_cfg 
 | 
						cw_Cfg_t * local_cfg;	/**< local_cfg contains overrides for global_cfg 
 | 
				
			||||||
				     wich are related to this conn object. */
 | 
									     wich are related to this conniection. */
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	cw_Cfg_t * remote_cfg;	/**< contains the configuration we now from the 
 | 
						cw_Cfg_t * remote_cfg;	/**< contains the configuration we now from the 
 | 
				
			||||||
				     device this conn object ist connected to.
 | 
									     device this conn object ist connected to.
 | 
				
			||||||
				     Typically this is what we have got from discovery
 | 
									     Typically this is what we have got from discovery
 | 
				
			||||||
				     response or join response in WTP mode. 
 | 
									     response or join response in WTP mode. 
 | 
				
			||||||
				     And in AC mode this contains date receive from 
 | 
									     And in AC mode this contains datia received by 
 | 
				
			||||||
				     configuration status request.  */
 | 
									     configuration status and join request.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_Cfg_t * update_cfg;
 | 
						cw_Cfg_t * update_cfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -311,7 +313,18 @@ int conn_send_msg(struct cw_Conn *conn, uint8_t * rawmsg);
 | 
				
			|||||||
void conn_clear_upd(struct cw_Conn*conn, int merge);
 | 
					void conn_clear_upd(struct cw_Conn*conn, int merge);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
 | 
					
 | 
				
			||||||
 | 
					struct cw_MsgCb_data;
 | 
				
			||||||
 | 
					//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len, 
 | 
				
			||||||
 | 
					//		struct cw_MsgCb_data *d);
 | 
				
			||||||
 | 
					typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_MsgCb_data{
 | 
				
			||||||
 | 
						cw_MsgCallbackFun fun;
 | 
				
			||||||
 | 
						struct cw_MsgCb_data * parent;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
 | 
				
			||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
 | 
					cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
					int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
 | 
				
			||||||
 | 
				
			|||||||
@ -53,10 +53,10 @@ int conn_send_msg(struct cw_Conn * conn, uint8_t *rawmsg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Zyxel doesn't count msg element length from
 | 
						//  Zyxel doesn't count msg element length from
 | 
				
			||||||
	   behind seqnum */
 | 
					//	   behind seqnum * /
 | 
				
			||||||
//	if (conn->capwap_mode == CW_MODE_ZYXEL){
 | 
					//	if (conn->capwap_mode == CW_MODE_ZYXEL){
 | 
				
			||||||
/*		// XXX val-=3; */
 | 
					// *		// XXX val-=3; * /
 | 
				
			||||||
//	}
 | 
					//	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -75,7 +75,7 @@ mtu = 9440;
 | 
				
			|||||||
	 int offset = cw_get_hdr_msg_offset(rawmsg);
 | 
						 int offset = cw_get_hdr_msg_offset(rawmsg);
 | 
				
			||||||
	return cw_send_msg(conn,rawmsg+offset);
 | 
						return cw_send_msg(conn,rawmsg+offset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
	if (packetlen>mtu){
 | 
						if (packetlen>mtu){
 | 
				
			||||||
		cw_set_hdr_flags(ptr,CAPWAP_FLAG_HDR_F,1);
 | 
							cw_set_hdr_flags(ptr,CAPWAP_FLAG_HDR_F,1);
 | 
				
			||||||
		cw_set_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
 | 
							cw_set_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
 | 
				
			||||||
@ -122,6 +122,6 @@ mtu = 9440;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
 | 
						cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return conn->write(conn,ptr,packetlen-0);
 | 
						return conn->write(conn,ptr,packetlen-0); */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										181
									
								
								src/cw/cw.c
									
									
									
									
									
								
							
							
						
						
									
										181
									
								
								src/cw/cw.c
									
									
									
									
									
								
							@ -11,7 +11,7 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
 | 
				
			|||||||
	char mkey[CW_CFG_MAX_KEY_LEN];
 | 
						char mkey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	const char *key;
 | 
						const char *key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"HK: %s",handler->key,);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!type){
 | 
						if (!type){
 | 
				
			||||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
							cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
				
			||||||
@ -25,21 +25,16 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
 | 
				
			|||||||
	else{
 | 
						else{
 | 
				
			||||||
		key = handler->key;
 | 
							key = handler->key;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X, "READ: %s / %s",type->name,key);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	cw_dbg(DBG_X, "READ: %s / %s",type->name,key);*/
 | 
					 | 
				
			||||||
	type->read(params->cfg, key,elem_data,elem_len,handler->param);
 | 
						type->read(params->cfg, key,elem_data,elem_len,handler->param);
 | 
				
			||||||
	return CAPWAP_RESULT_SUCCESS;
 | 
						return CAPWAP_RESULT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					int cw_out_generic0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
			, uint8_t * dst)
 | 
								, uint8_t * dst,const char *key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
	int start, len, l;
 | 
						int start, len, l;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
//	cw_dbg(DBG_X,"cw_out_generic (%s)%s",((struct cw_Type*)handler->type)->name,handler->key);
 | 
					//	cw_dbg(DBG_X,"cw_out_generic (%s)%s",((struct cw_Type*)handler->type)->name,handler->key);
 | 
				
			||||||
@ -49,19 +44,21 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
 | 
					//	cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
	if (!cw_cfg_base_exists(params->cfg_list[0],handler->key)){
 | 
						if (!params->elemdata->mand){
 | 
				
			||||||
			cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s %s - (skip)", 
 | 
							if (!cw_cfg_base_exists(params->cfg_list[0],key)){
 | 
				
			||||||
 | 
								cw_dbg(DBG_MSG_COMPOSE,"    Add Elem: %d %d %d %s %s - (bskip)", 
 | 
				
			||||||
				params->elemdata->proto, 
 | 
									params->elemdata->proto, 
 | 
				
			||||||
				params->elemdata->vendor, 
 | 
									params->elemdata->vendor, 
 | 
				
			||||||
				params->elemdata->id, 
 | 
									params->elemdata->id, 
 | 
				
			||||||
					handler->name, handler->key);
 | 
									handler->name, key);
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	start = params->msgset->header_len(handler);
 | 
						start = params->msgset->header_len(handler);
 | 
				
			||||||
	len = ((const cw_Type_t*)(handler->type))->
 | 
						len = ((const cw_Type_t*)(handler->type))->
 | 
				
			||||||
		write(params->cfg_list,handler->key,dst+start,handler->param);
 | 
							write(params->cfg_list,key,dst+start,handler->param);
 | 
				
			||||||
//	cw_dbg(DBG_X, "Type result is %d",len);
 | 
					//	cw_dbg(DBG_X, "Type result is %d",len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len == -1) {
 | 
						if (len == -1) {
 | 
				
			||||||
@ -73,7 +70,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
			cw_log(LOG_ERR,
 | 
								cw_log(LOG_ERR,
 | 
				
			||||||
			       "Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
 | 
								       "Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
 | 
				
			||||||
				vendor, handler->id, handler->name, params->msgdata->name
 | 
									vendor, handler->id, handler->name, params->msgdata->name
 | 
				
			||||||
			       , handler->key
 | 
								       , key
 | 
				
			||||||
			    );
 | 
								    );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
@ -90,6 +87,15 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
 | 
				
			|||||||
	l = params->msgset->write_header(handler,dst,len);
 | 
						l = params->msgset->write_header(handler,dst,len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return l;
 | 
						return l;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_out_generic0(handler,params,dst,handler->key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -145,8 +151,6 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
 | 
				
			|||||||
		type = (struct cw_Type*)handler->type;
 | 
							type = (struct cw_Type*)handler->type;
 | 
				
			||||||
		start = params->msgset->header_len(handler)+len;
 | 
							start = params->msgset->header_len(handler)+len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		l = type->write(params->cfg_list, key,dst+start+1,handler->param);
 | 
							l = type->write(params->cfg_list, key,dst+start+1,handler->param);
 | 
				
			||||||
		if (l==-1)
 | 
							if (l==-1)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
@ -316,3 +320,148 @@ cw_put_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	return d-dst;
 | 
						return d-dst;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst, int i, const char *current, const char * next, 
 | 
				
			||||||
 | 
								int * stack)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *sl;
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int len;
 | 
				
			||||||
 | 
						len = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf("Next: %s\n", next);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						sl = strchr(next,'/');
 | 
				
			||||||
 | 
						if (sl==NULL){
 | 
				
			||||||
 | 
							cw_Val_t * result;
 | 
				
			||||||
 | 
							sprintf(key,"%s/%s",current,next);
 | 
				
			||||||
 | 
							result = cw_ktv_base_exists(params->cfg,key);
 | 
				
			||||||
 | 
							if (result != NULL){
 | 
				
			||||||
 | 
								int offset;
 | 
				
			||||||
 | 
								int i,l;
 | 
				
			||||||
 | 
								offset = params->msgset->header_len(handler);
 | 
				
			||||||
 | 
								printf("Yea! We can do it: %s\n",result->key);
 | 
				
			||||||
 | 
								for (i=0;i<stack[0];i++){
 | 
				
			||||||
 | 
									printf("I=%i\n",stack[i+1]);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								l= cw_ktv_write_struct(params->cfg,params->cfg, 
 | 
				
			||||||
 | 
									handler->type,key,dst+offset);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								printf("Write struct len %i\n",l);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								l=params->msgset->write_header(handler,dst,l);
 | 
				
			||||||
 | 
								printf("header wr len %d\n",l);
 | 
				
			||||||
 | 
								if (handler->patch){
 | 
				
			||||||
 | 
									handler->patch(dst+offset,stack);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								return l;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						strcpy(key,current);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					printf("current is %s\n", current);	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (key[0!=0])
 | 
				
			||||||
 | 
							strcat(key,"/");
 | 
				
			||||||
 | 
						l = sl - next;
 | 
				
			||||||
 | 
						strncat(key,next,l);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						printf("Here we are %s\n",key);
 | 
				
			||||||
 | 
						cw_dbg_ktv_dump(params->cfg,DBG_INFO,"start"," ", "end" );
 | 
				
			||||||
 | 
						i=-1;
 | 
				
			||||||
 | 
						while(1){
 | 
				
			||||||
 | 
							char basekey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
							cw_Val_t * result;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							i = cw_ktv_idx_get_next(params->cfg,key,i+1);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (i==-1)
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							sprintf(basekey,"%s.%d",key,i);
 | 
				
			||||||
 | 
							printf("Our basekey is %s\n",basekey);
 | 
				
			||||||
 | 
							result = cw_ktv_base_exists(params->cfg,basekey);
 | 
				
			||||||
 | 
							if (result == NULL){
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							stack[0]++;
 | 
				
			||||||
 | 
							stack[stack[0]]=i;
 | 
				
			||||||
 | 
							len += cw_out_traverse0(handler,params,dst+len,-1,basekey,next+l+1, stack);
 | 
				
			||||||
 | 
							printf("Len is now %d\n", len);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return len;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					/*	char current[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						int stack[10];
 | 
				
			||||||
 | 
						stack[0]=0;
 | 
				
			||||||
 | 
						current[0]=0;
 | 
				
			||||||
 | 
					//	return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);*/
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int walk0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
							, uint8_t * dst, const char *current, const char * next)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					        const char *sl;
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					        int len=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Is this the last key ? */
 | 
				
			||||||
 | 
					        sl = strchr(next,'/');
 | 
				
			||||||
 | 
					        if (sl){
 | 
				
			||||||
 | 
					                char basekey[CW_CFG_MAX_KEY_LEN+13];
 | 
				
			||||||
 | 
					                int i,l;
 | 
				
			||||||
 | 
					                strcpy(key,current);
 | 
				
			||||||
 | 
					                l = sl - next;
 | 
				
			||||||
 | 
					                strncat(key,next,l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                for (i=0; (i=cw_cfg_get_first_index_l(params->cfg_list,key,i))!=-1; i++){
 | 
				
			||||||
 | 
					                        sprintf(basekey,"%s.%d%c",key,i, *(sl+1) ?'/':'\0');
 | 
				
			||||||
 | 
					                        rc = walk0(handler,params,dst,basekey,next+l+1);
 | 
				
			||||||
 | 
								if (rc>0)
 | 
				
			||||||
 | 
									len+=rc;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        printf("Final %s [%s]\n",current,next);
 | 
				
			||||||
 | 
						return cw_out_generic0(handler,params,dst,current);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_out_generic_walk(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					        char current[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
					//        int stack[10];
 | 
				
			||||||
 | 
					 //       stack[0]=0;
 | 
				
			||||||
 | 
					        current[0]=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return walk0(handler,params,dst,current,handler->key);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								src/cw/cw.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/cw/cw.h
									
									
									
									
									
								
							@ -146,8 +146,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_get_hdr_ws_len(uint8_t * th);
 | 
					int cw_get_hdr_ws_len(uint8_t * th);
 | 
				
			||||||
uint8_t *cw_get_hdr_ws_data(uint8_t * th);
 | 
					int cw_get_hdr_ws_len_7(uint8_t * th);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint8_t *cw_get_hdr_ws_data(uint8_t * th);
 | 
				
			||||||
 | 
					#define cw_get_hdr_ws_data_7(th) (cw_get_hdr_ws_data(th)+1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define cw_get_hdr_msg_offset(th) (4*cw_get_hdr_hlen(th))
 | 
					#define cw_get_hdr_msg_offset(th) (4*cw_get_hdr_hlen(th))
 | 
				
			||||||
@ -217,7 +219,7 @@ void cw_set_hdr_rid(uint8_t * th, int rid);
 | 
				
			|||||||
 * @see #cw_is_request
 | 
					 * @see #cw_is_request
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define cw_is_response(msg_id) (!is_response(msg_id))
 | 
					#define cw_is_response(msg_id) (!cw_is_resquest(msg_id))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint8_t *cw_get_hdr_msg_elems_ptr(uint8_t * m);
 | 
					uint8_t *cw_get_hdr_msg_elems_ptr(uint8_t * m);
 | 
				
			||||||
@ -558,6 +560,18 @@ int cw_put_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_send_request(struct cw_Conn *conn,int msg_id);
 | 
					int cw_send_request(struct cw_Conn *conn,int msg_id);
 | 
				
			||||||
 | 
					int cw_out_generic_walk(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst);
 | 
				
			||||||
 | 
					int cw_out_generic0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
 | 
								, uint8_t * dst,const char *key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_init_capwap_packet( uint8_t * buf, int wbid ,int rid, bstr_t rmac, bstr_t wd);
 | 
				
			||||||
 | 
					int cw_send_capwap_packet(struct cw_Conn * conn, uint8_t * buf, int hlen, uint8_t * data, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *@}
 | 
					 *@}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,12 +0,0 @@
 | 
				
			|||||||
#ifndef __CW_80211_H
 | 
					 | 
				
			||||||
#define __CW_80211_H
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_80211_mac_operation(struct conn *conn, struct cw_action_in *a, uint8_t * data,
 | 
					 | 
				
			||||||
			 int len, struct sockaddr *from);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_read_80211_mac_operation(uint8_t *data,mbag_t r);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
@ -1,26 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
  * Set debug level
 | 
					 | 
				
			||||||
  * @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure.
 | 
					 | 
				
			||||||
  * @param on 1: turns the specified debug level on, 0: turns the specified debug level off.
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void cw_dbg_set_level (int level, int on)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	switch (level) {
 | 
					 | 
				
			||||||
		case DBG_ALL:
 | 
					 | 
				
			||||||
			if (on)
 | 
					 | 
				
			||||||
				cw_dbg_opt_level = 0xffffffff;
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				cw_dbg_opt_level = 0;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			if (on)
 | 
					 | 
				
			||||||
				cw_dbg_opt_level |= (level);
 | 
					 | 
				
			||||||
			else 
 | 
					 | 
				
			||||||
				cw_dbg_opt_level &= (0xffffffff) ^ (level);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,31 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_dbg_set_level_from_str(const char *level)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int blevel,on;
 | 
					 | 
				
			||||||
	const char *slevel;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	switch(*level){
 | 
					 | 
				
			||||||
		case '-':
 | 
					 | 
				
			||||||
		case '!':
 | 
					 | 
				
			||||||
		case '~':
 | 
					 | 
				
			||||||
			on =0;
 | 
					 | 
				
			||||||
			slevel=level+1;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case '+':
 | 
					 | 
				
			||||||
			slevel=level+1;
 | 
					 | 
				
			||||||
			on=1;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			slevel=level;
 | 
					 | 
				
			||||||
			on=1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	blevel = cw_strlist_get_id(cw_dbg_strings, slevel);
 | 
					 | 
				
			||||||
	if (blevel==-1)
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	cw_dbg_set_level(blevel,on);
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -3,9 +3,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "dbg.h"
 | 
					#include "dbg.h"
 | 
				
			||||||
#include "cw.h"
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					#include "cfg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @brief Detect NAT after a join/discovery request
 | 
					 * @brief Detect NAT after a Join Request
 | 
				
			||||||
 * @param conn Connection object
 | 
					 * @param conn Connection object
 | 
				
			||||||
 * @retval 1 NAT detected
 | 
					 * @retval 1 NAT detected
 | 
				
			||||||
 * @retval 0 no NAT was detected
 | 
					 * @retval 0 no NAT was detected
 | 
				
			||||||
@ -15,7 +16,8 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
 | 
				
			|||||||
	const char  * remote_str;
 | 
						const char  * remote_str;
 | 
				
			||||||
	char local_str[128];
 | 
						char local_str[128];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	remote_str = cw_cfg_get(params->cfg,"capwap-local-ip-address",NULL);
 | 
						remote_str = cw_cfg_get(params->cfg,"capwap/local-ip-address",NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (remote_str == NULL){
 | 
						if (remote_str == NULL){
 | 
				
			||||||
		cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
 | 
							cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
@ -29,9 +31,12 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	/* if connected and sent address is the same, there is 
 | 
						/* if connected and sent address is the same, there is 
 | 
				
			||||||
	 * no NAT */
 | 
						 * no NAT */
 | 
				
			||||||
	if (strcmp(remote_str,local_str)==0)
 | 
						if (strcmp(remote_str,local_str)==0){
 | 
				
			||||||
 | 
							cw_dbg(DBG_INFO,"Connection from %s: no NAT detected.",local_str);
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
						}		
 | 
				
			||||||
	/* otherwise ther must be something between AC and WTP */
 | 
						/* otherwise ther must be something between AC and WTP */
 | 
				
			||||||
 | 
						cw_dbg(DBG_INFO,"Connection from %s: NAT detected.",local_str);
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,105 +3,104 @@
 | 
				
			|||||||
#include "conn.h"
 | 
					#include "conn.h"
 | 
				
			||||||
#include "cw.h"
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					#include "dot11.h"
 | 
				
			||||||
 * @brief Format a packet header for debugging purposes
 | 
					
 | 
				
			||||||
 * @param dst Destination buffer
 | 
					int cw_format_dot11_fc_flags(char *dst, uint8_t *frame){
 | 
				
			||||||
 * @param incomming True if the packet is an incomming packet, otherweise 0
 | 
						char *s = dst;
 | 
				
			||||||
 * @param packet packet data
 | 
						uint8_t f = frame[0];
 | 
				
			||||||
 * @param len length of packet data
 | 
						s+=sprintf(s,"ToDS:%d ", f&1 ? 1:0);
 | 
				
			||||||
 * @param from Address from where the packet was received
 | 
						s+=sprintf(s,"FromDS:%d ", f&2 ? 1:0);
 | 
				
			||||||
 * @return Number of bytes written
 | 
						s+=sprintf(s,"More Frgs:%d ", f&4 ? 1:0);
 | 
				
			||||||
 */
 | 
						s+=sprintf(s,"Retry:%d ", f&8 ? 1:0);
 | 
				
			||||||
int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
						s+=sprintf(s,"PwrMgmt:%d ", f&16 ? 1:0);
 | 
				
			||||||
		      struct sockaddr *from)
 | 
						s+=sprintf(s,"More Dta:%d ", f&32 ? 1:0);
 | 
				
			||||||
 | 
						s+=sprintf(s,"Protec:%d ", f&64 ? 1:0);
 | 
				
			||||||
 | 
						s+=sprintf(s,"+HTC/:%d ", f&128 ? 1:0);
 | 
				
			||||||
 | 
						return s-dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_format_dot11_rates(char *dst, const uint8_t *src, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
						char * k="";
 | 
				
			||||||
 | 
						char *s=dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(i=0; i<len; i++){
 | 
				
			||||||
 | 
							int rate = src[i] &0x7f;
 | 
				
			||||||
 | 
							s+=sprintf(s,"%s%0.1f",k,dot11_rate2float(rate));
 | 
				
			||||||
 | 
							k=", ";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return s-dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_format_dot11_elem(char *dst, uint8_t id, const uint8_t *src, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *s = dst;
 | 
				
			||||||
 | 
						s += sprintf(s,"elem(id=%d) ",id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch(id){
 | 
				
			||||||
 | 
							case DOT11_ELEM_SSID:
 | 
				
			||||||
 | 
								s+=sprintf(s," ssid: %.*s",len,src);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_SUPPORTED_RATES:
 | 
				
			||||||
 | 
								s+=sprintf(s," Supported Rates:");
 | 
				
			||||||
 | 
								s+=cw_format_dot11_rates(s,src,len);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_EXTENDED_SUPPORTED_RATES:
 | 
				
			||||||
 | 
								s+=sprintf(s," Extended Supported Rates");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_POWER_CAPABILITY:
 | 
				
			||||||
 | 
								s+=sprintf(s," Power Capability");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_SUPPORTED_CHANNELS:
 | 
				
			||||||
 | 
								s+=sprintf(s," Supported Channels");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_SUPPORTED_OPERATING_CLASSES:
 | 
				
			||||||
 | 
								s+=sprintf(s," Supported Operating Classes");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ELEM_VENDOR_SPECIFIC:
 | 
				
			||||||
 | 
								s+=sprintf(s," Vendor Specific");
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
						default:
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						s+=sprintf(s,", len=%d",len);
 | 
				
			||||||
 | 
						return s-dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_format_dot11_hdr(char * dst, uint8_t * packet, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char sock_buf[SOCK_ADDR_BUFSIZE]; 
 | 
					 | 
				
			||||||
	int preamble;
 | 
					 | 
				
			||||||
	char *s;
 | 
						char *s;
 | 
				
			||||||
	int hlen, rid, wbid;
 | 
						int type = dot11_get_type_and_subtype(packet);
 | 
				
			||||||
	int frag_id,frag_offs;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s=dst;
 | 
						s=dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (incomming){
 | 
						s+=sprintf(s,"IEEE 802.11 - %s",dot11_get_frame_name(packet));
 | 
				
			||||||
		if (cw_get_hdr_flag_f(packet)) {
 | 
						s+=sprintf(s," da:");
 | 
				
			||||||
			s += sprintf(s, "Fragment from %s",
 | 
						s+=format_mac(s,dot11_get_da(packet),6);	
 | 
				
			||||||
				     sock_addr2str_p(from,sock_buf));
 | 
						s+=sprintf(s," sa:");
 | 
				
			||||||
		} else {
 | 
						s+=format_mac(s,dot11_get_sa(packet),6);	
 | 
				
			||||||
			s += sprintf(s, "From %s", sock_addr2str_p(from,sock_buf));
 | 
						s+=sprintf(s," bssid:");
 | 
				
			||||||
		}
 | 
						s+=format_mac(s,dot11_get_bssid(packet),6);
 | 
				
			||||||
	}
 | 
						s+=sprintf(s," seq: %d\n",dot11_get_seq(packet));
 | 
				
			||||||
	else{
 | 
						s+=cw_format_dot11_fc_flags(s,packet);
 | 
				
			||||||
		if (cw_get_hdr_flag_f(packet)) {
 | 
						s+=sprintf(s,"\nDuration: %d",dot11_get_duration(packet));
 | 
				
			||||||
			s += sprintf(s, "Fragment to %s", sock_addr2str(from,sock_buf));
 | 
					//
 | 
				
			||||||
		} else {
 | 
					/*	switch (type){
 | 
				
			||||||
			s += sprintf(s, "To %s", sock_addr2str(from,sock_buf));
 | 
							case DOT11_ASSOC_REQ:
 | 
				
			||||||
		}
 | 
								s+=sprintf(s,"\n   ssid: %.*s",dot11_assoc_req_get_ssid_len(packet),
 | 
				
			||||||
	}
 | 
										dot11_assoc_req_get_ssid(packet)
 | 
				
			||||||
	s += sprintf(s, " l=%d: ", len);
 | 
								);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
	preamble = cw_get_hdr_preamble(packet);
 | 
						}*/
 | 
				
			||||||
	if (preamble == 01) {
 | 
					 | 
				
			||||||
		s += sprintf(s, " (encrypted)");
 | 
					 | 
				
			||||||
		return s - dst;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len < 4)
 | 
					 | 
				
			||||||
		goto abort;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*		
 | 
					 | 
				
			||||||
	if (cw_get_hdr_flag_f(packet)){
 | 
					 | 
				
			||||||
		s+=sprintf(s," (fragmented)");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	hlen = cw_get_hdr_hlen(packet);
 | 
					 | 
				
			||||||
	rid = cw_get_hdr_rid(packet);
 | 
					 | 
				
			||||||
	wbid = cw_get_hdr_wbid(packet);
 | 
					 | 
				
			||||||
	s += sprintf(s, " H:%d R:%02d W:%02d", hlen, rid, wbid);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	s += sprintf(s, " Flgs:");
 | 
					 | 
				
			||||||
	s += format_hdr_flags(s, packet);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (len < 8)
 | 
					 | 
				
			||||||
		goto abort;
 | 
					 | 
				
			||||||
	frag_id = cw_get_hdr_fragid(packet);
 | 
					 | 
				
			||||||
	frag_offs = cw_get_hdr_fragoffset(packet);
 | 
					 | 
				
			||||||
	s += sprintf(s, " Frag/Offs:%d/%d", frag_id, frag_offs);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (cw_get_hdr_flag_m(packet)) {
 | 
					 | 
				
			||||||
		/* rmac is present, print the rmac */
 | 
					 | 
				
			||||||
		int rmac_len = cw_get_hdr_rmac_len(packet);
 | 
					 | 
				
			||||||
		int plen = rmac_len;
 | 
					 | 
				
			||||||
		if (rmac_len + 8 > len)
 | 
					 | 
				
			||||||
			plen = len - 8;
 | 
					 | 
				
			||||||
		if (rmac_len > 10)
 | 
					 | 
				
			||||||
			plen = 10;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		s += sprintf(s, " R-MAC:");
 | 
					 | 
				
			||||||
		s += format_mac(s, cw_get_hdr_rmac_data(packet), plen);
 | 
					 | 
				
			||||||
		if (rmac_len > 10) {
 | 
					 | 
				
			||||||
			s += sprintf(s, " ... (len=%d)", rmac_len);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (cw_get_hdr_flag_w(packet)) {
 | 
					 | 
				
			||||||
		/* print wireless specific info */
 | 
					 | 
				
			||||||
		int ws_len = cw_get_hdr_ws_len(packet);
 | 
					 | 
				
			||||||
		int plen = ws_len > 20 ? 20 : ws_len;
 | 
					 | 
				
			||||||
		s += sprintf(s, " WS:");
 | 
					 | 
				
			||||||
		s += format_hexu(s, cw_get_hdr_ws_data(packet), plen);
 | 
					 | 
				
			||||||
		if (ws_len > 20) {
 | 
					 | 
				
			||||||
			s += sprintf(s, " ... (len=%d)", ws_len);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return s - dst;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      abort:
 | 
					 | 
				
			||||||
	s += sprintf(s, " Incomplete...");
 | 
					 | 
				
			||||||
	return s - dst;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,37 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "capwap.h"
 | 
					 | 
				
			||||||
#include "msgset.h"
 | 
					 | 
				
			||||||
#include "val.h"
 | 
					 | 
				
			||||||
#include "log.h"
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
 | 
					 | 
				
			||||||
		uint8_t * elem_data, int elem_len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_Type_t * type;
 | 
					 | 
				
			||||||
	type = (cw_Type_t*)handler->type;
 | 
					 | 
				
			||||||
	char mkey[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	const char *key;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!type){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
 | 
					 | 
				
			||||||
		return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (handler->mkkey != NULL){
 | 
					 | 
				
			||||||
		handler->mkkey(handler->key,elem_data,elem_len, mkey);
 | 
					 | 
				
			||||||
		key = mkey;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else{
 | 
					 | 
				
			||||||
		key = handler->key;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	cw_dbg(DBG_X, "READ: %s / %s",type->name,key);*/
 | 
					 | 
				
			||||||
	type->read(params->cfg, key,elem_data,elem_len,handler->param);
 | 
					 | 
				
			||||||
	return CAPWAP_RESULT_SUCCESS;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -15,6 +15,25 @@ int cw_get_hdr_ws_len(uint8_t * th)
 | 
				
			|||||||
	return *(th + 9 + cw_get_hdr_rmac_len(th));
 | 
						return *(th + 9 + cw_get_hdr_rmac_len(th));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** 
 | 
				
			||||||
 | 
					 * Get length of wireless specific data for CAPWAP packet draft 7
 | 
				
			||||||
 | 
					 * @param th Pointer to packet
 | 
				
			||||||
 | 
					 * @return length of wireless specific data
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Call this function only if the W flag is set
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int cw_get_hdr_ws_len_7(uint8_t * th)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!cw_get_hdr_flag_m(th)){
 | 
				
			||||||
 | 
							return *(th + 9);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return *(th + 10 + cw_get_hdr_rmac_len(th));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** 
 | 
					/** 
 | 
				
			||||||
 * Get pointer to wireless specific data
 | 
					 * Get pointer to wireless specific data
 | 
				
			||||||
 * @param th Pointer to packet
 | 
					 * @param th Pointer to packet
 | 
				
			||||||
@ -117,7 +136,7 @@ int cw_set_hdr_rmac(uint8_t * th, bstr_t rmac)
 | 
				
			|||||||
		hlen++;
 | 
							hlen++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cw_set_hdr_hlen(th, hlen);
 | 
						cw_set_hdr_hlen(th, hlen);
 | 
				
			||||||
	return 1;
 | 
						return rmac_len;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,6 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
 | 
				
			|||||||
		int b;
 | 
							int b;
 | 
				
			||||||
		sprintf(key,"%s/%s",handler->key,e[i].name);
 | 
							sprintf(key,"%s/%s",handler->key,e[i].name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		b = cw_cfg_base_exists(params->cfg_list[0],handler->key);
 | 
							b = cw_cfg_base_exists(params->cfg_list[0],handler->key);
 | 
				
			||||||
		if (!b){
 | 
							if (!b){
 | 
				
			||||||
 | 
				
			|||||||
@ -42,106 +42,8 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		cdst+=params->msgset->write_header(handler,cdst,l);
 | 
							cdst+=params->msgset->write_header(handler,cdst,l);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return cdst-dst;
 | 
						return cdst-dst;*/
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					 | 
				
			||||||
			, uint8_t * dst, int i, const char *current, const char * next, 
 | 
					 | 
				
			||||||
			int * stack)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *sl;
 | 
					 | 
				
			||||||
	int l;
 | 
					 | 
				
			||||||
	char key[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	int len;
 | 
					 | 
				
			||||||
	len = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("Next: %s\n", next);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sl = strchr(next,'/');
 | 
					 | 
				
			||||||
	if (sl==NULL){
 | 
					 | 
				
			||||||
		cw_Val_t * result;
 | 
					 | 
				
			||||||
		sprintf(key,"%s/%s",current,next);
 | 
					 | 
				
			||||||
		result = cw_ktv_base_exists(params->cfg,key);
 | 
					 | 
				
			||||||
		if (result != NULL){
 | 
					 | 
				
			||||||
			int offset;
 | 
					 | 
				
			||||||
			int i,l;
 | 
					 | 
				
			||||||
			offset = params->msgset->header_len(handler);
 | 
					 | 
				
			||||||
			printf("Yea! We can do it: %s\n",result->key);
 | 
					 | 
				
			||||||
			for (i=0;i<stack[0];i++){
 | 
					 | 
				
			||||||
				printf("I=%i\n",stack[i+1]);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			l= cw_ktv_write_struct(params->cfg,params->cfg, 
 | 
					 | 
				
			||||||
				handler->type,key,dst+offset);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			printf("Write struct len %i\n",l);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			l=params->msgset->write_header(handler,dst,l);
 | 
					 | 
				
			||||||
			printf("header wr len %d\n",l);
 | 
					 | 
				
			||||||
			if (handler->patch){
 | 
					 | 
				
			||||||
				handler->patch(dst+offset,stack);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			return l;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	strcpy(key,current);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf("current is %s\n", current);	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (key[0!=0])
 | 
					 | 
				
			||||||
		strcat(key,"/");
 | 
					 | 
				
			||||||
	l = sl - next;
 | 
					 | 
				
			||||||
	strncat(key,next,l);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	printf("Here we are %s\n",key);
 | 
					 | 
				
			||||||
	cw_dbg_ktv_dump(params->cfg,DBG_INFO,"start"," ", "end" );
 | 
					 | 
				
			||||||
	i=-1;
 | 
					 | 
				
			||||||
	while(1){
 | 
					 | 
				
			||||||
		char basekey[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
		cw_Val_t * result;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		i = cw_ktv_idx_get_next(params->cfg,key,i+1);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (i==-1)
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		sprintf(basekey,"%s.%d",key,i);
 | 
					 | 
				
			||||||
		printf("Our basekey is %s\n",basekey);
 | 
					 | 
				
			||||||
		result = cw_ktv_base_exists(params->cfg,basekey);
 | 
					 | 
				
			||||||
		if (result == NULL){
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		stack[0]++;
 | 
					 | 
				
			||||||
		stack[stack[0]]=i;
 | 
					 | 
				
			||||||
		len += cw_out_traverse0(handler,params,dst+len,-1,basekey,next+l+1, stack);
 | 
					 | 
				
			||||||
		printf("Len is now %d\n", len);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return len;
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					 | 
				
			||||||
			, uint8_t * dst)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//char current[CW_CFG_MAX_KEY_LEN];
 | 
					 | 
				
			||||||
	//int stack[10];
 | 
					 | 
				
			||||||
	//stack[0]=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//current[0]=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	//stop();
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	return cw_out_traverse0(handler,params,dst,-1,current,handler->key, stack);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -49,6 +49,8 @@ int cw_setup_dtls(struct cw_Conn *conn, cw_Cfg_t * cfg, const char *prefix,
 | 
				
			|||||||
	sprintf(key, "%s/%s", prefix, "ssl-cipher");
 | 
						sprintf(key, "%s/%s", prefix, "ssl-cipher");
 | 
				
			||||||
	conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
 | 
						conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_DTLS,"Using cipher: %s",conn->dtls_cipher);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(key, "%s/%s", prefix, "ssl-psk");
 | 
						sprintf(key, "%s/%s", prefix, "ssl-psk");
 | 
				
			||||||
	conn->dtls_psk = (bstr16_t)cw_cfg_get(cfg, key, NULL);
 | 
						conn->dtls_psk = (bstr16_t)cw_cfg_get(cfg, key, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -158,6 +158,7 @@ static 	int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void *
 | 
				
			|||||||
	i=0,l=0;
 | 
						i=0,l=0;
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		sprintf(skey,"%s.%d",key,i);
 | 
							sprintf(skey,"%s.%d",key,i);
 | 
				
			||||||
 | 
					//		printf("iSKEY %s\n",skey);
 | 
				
			||||||
		i++;
 | 
							i++;
 | 
				
			||||||
		if (cw_cfg_get_l(cfgs,skey,NULL)==NULL){
 | 
							if (cw_cfg_get_l(cfgs,skey,NULL)==NULL){
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
@ -165,7 +166,7 @@ static 	int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void *
 | 
				
			|||||||
		l+=def->type->write(cfgs,skey,dst,def->param);
 | 
							l+=def->type->write(cfgs,skey,dst,def->param);
 | 
				
			||||||
	}while(1);
 | 
						}while(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	printf("LEN: %d pl: %d\n",l,n);
 | 
					//	printf("LEN: %d (K: %s)\n",l,key);
 | 
				
			||||||
	fun(cfgs,key,dst,param,l);
 | 
						fun(cfgs,key,dst,param,l);
 | 
				
			||||||
	return l;
 | 
						return l;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										84
									
								
								src/cw/cw_type_bits.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								src/cw/cw_type_bits.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,84 @@
 | 
				
			|||||||
 | 
					#include "val.h"
 | 
				
			||||||
 | 
					#include "cfg.h"
 | 
				
			||||||
 | 
					#include "dbg.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int get_len(const struct cw_ValBit *bits)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int i;
 | 
				
			||||||
 | 
						for (i=0;bits[i].key!=NULL;i++);
 | 
				
			||||||
 | 
						return bits[i].bit; 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int get_bit(const uint8_t * src,int pos, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int b;
 | 
				
			||||||
 | 
						uint8_t m;
 | 
				
			||||||
 | 
					       	b = len-1-pos/8;
 | 
				
			||||||
 | 
						m = 1<<(pos%8);
 | 
				
			||||||
 | 
						return src[b]&m ? 1:0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void set_bit(uint8_t * dst,int pos, int len,int val)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int b;
 | 
				
			||||||
 | 
						uint8_t m;
 | 
				
			||||||
 | 
						cw_dbg(DBG_X,"set bit val %d",val);
 | 
				
			||||||
 | 
						if (!val)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					       	b = len-1-pos/8;
 | 
				
			||||||
 | 
						m = 1<<(pos%8);
 | 
				
			||||||
 | 
						dst[b]|=m;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char skey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						const struct cw_ValBit * bits=param;
 | 
				
			||||||
 | 
						int l,i;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						l = get_len(bits);
 | 
				
			||||||
 | 
						for(i=0;bits[i].key!=NULL;i++){
 | 
				
			||||||
 | 
							sprintf(skey,"%s/%s",key,bits[i].key);
 | 
				
			||||||
 | 
							cw_cfg_set_bool(cfg,skey,get_bit(src,bits[i].bit,l));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static 	int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void * param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int l,i;
 | 
				
			||||||
 | 
						char skey[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
 | 
						const struct cw_ValBit * bits=param;
 | 
				
			||||||
 | 
						l = get_len(bits);
 | 
				
			||||||
 | 
						memset(dst,0,l);
 | 
				
			||||||
 | 
						for(i=0;bits[i].key!=NULL;i++){
 | 
				
			||||||
 | 
							uint8_t val;
 | 
				
			||||||
 | 
							int rc;
 | 
				
			||||||
 | 
							val=0;
 | 
				
			||||||
 | 
							sprintf(skey,"%s/%s",key,bits[i].key);
 | 
				
			||||||
 | 
							rc = CW_TYPE_BOOL->write(cfgs, skey, &val, NULL);
 | 
				
			||||||
 | 
							if (rc<0)
 | 
				
			||||||
 | 
								val=0;
 | 
				
			||||||
 | 
							cw_dbg(DBG_X,"%s (rc: %d)",skey,rc);
 | 
				
			||||||
 | 
							set_bit(dst,bits[i].bit,l,val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return l;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct cw_Type cw_type_bits = {
 | 
				
			||||||
 | 
						"Bits",			/* name */
 | 
				
			||||||
 | 
						NULL,			/* del */
 | 
				
			||||||
 | 
						NULL,			/* put */
 | 
				
			||||||
 | 
						NULL,			/* get */
 | 
				
			||||||
 | 
						NULL,			/* to_str */
 | 
				
			||||||
 | 
						NULL,		/* from_str */ 
 | 
				
			||||||
 | 
						NULL,			/* len */
 | 
				
			||||||
 | 
						NULL,			/* data */
 | 
				
			||||||
 | 
						NULL,		/* get_type_name */
 | 
				
			||||||
 | 
						NULL,
 | 
				
			||||||
 | 
						bread,
 | 
				
			||||||
 | 
						bwrite
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -38,14 +38,12 @@ static int read_struct(cw_Cfg_t * cfg,const cw_ValStruct_t * stru, const char *p
 | 
				
			|||||||
			default:
 | 
								default:
 | 
				
			||||||
				l = stru[i].len;
 | 
									l = stru[i].len;
 | 
				
			||||||
				if (pos+l > len){
 | 
									if (pos+l > len){
 | 
				
			||||||
					l = len-pos;
 | 
										l = pos<len ? len-pos : 0 ;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		l=stru[i].type->read(cfg,key,data+pos,l,stru[i].valguard);
 | 
							l=stru[i].type->read(cfg,key,data+pos,l,stru[i].valguard);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
//		printf("READ STRUCT (%d): %s: %s\n",pos,key,dbstr);
 | 
					//		printf("READ STRUCT (%d): %s: %s\n",pos,key,dbstr);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (stru[i].len==-1){
 | 
							if (stru[i].len==-1){
 | 
				
			||||||
@ -102,8 +100,9 @@ static int write_struct(cw_Cfg_t ** cfgs,  const cw_ValStruct_t * stru, const ch
 | 
				
			|||||||
			sprintf(key,"%s",pkey);
 | 
								sprintf(key,"%s",pkey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//	result = cw_cfg_get_l(cfgs,key,NULL);
 | 
						//	result = cw_cfg_get_l(cfgs,key,NULL);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
		rc = cw_cfg_base_exists_l(cfgs,key);
 | 
							rc = cw_cfg_base_exists_l(cfgs,key);
 | 
				
			||||||
//		printf("Base? :%s, %d\n",key,rc);
 | 
					//		cw_dbg(DBG_X,"Base? :'%s', %d\n",key,rc);
 | 
				
			||||||
		if(result) {
 | 
							if(result) {
 | 
				
			||||||
//			char s[2048];
 | 
					//			char s[2048];
 | 
				
			||||||
//			result->type->to_str(result,s,2048);
 | 
					//			result->type->to_str(result,s,2048);
 | 
				
			||||||
@ -113,12 +112,13 @@ static int write_struct(cw_Cfg_t ** cfgs,  const cw_ValStruct_t * stru, const ch
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		if (!rc){
 | 
							if (!rc){
 | 
				
			||||||
			int l;
 | 
								int l;
 | 
				
			||||||
			cw_log(LOG_ERR,"Can't put %s, no value found, filling wth zeros.",key);
 | 
								cw_log(LOG_ERR,"Can't put %s, no value found, filling with zeros.",key);
 | 
				
			||||||
			l = stru[i].len;
 | 
								l = stru[i].len;
 | 
				
			||||||
			if (l==-1)
 | 
								if (l==-1)
 | 
				
			||||||
				l = 0;
 | 
									l = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			memset(dst+pos,0,l);
 | 
								memset(dst+pos,0,l);
 | 
				
			||||||
 | 
								wrlen=l;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			struct cw_Type * type;
 | 
								struct cw_Type * type;
 | 
				
			||||||
 | 
				
			|||||||
@ -8,55 +8,38 @@
 | 
				
			|||||||
int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
					int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
 | 
				
			||||||
                                 int subelem_id, const char * parent_key )
 | 
					                                 int subelem_id, const char * parent_key )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char key[256];
 | 
						char key[CW_CFG_MAX_KEY_LEN];
 | 
				
			||||||
	uint32_t vendor;
 | 
						uint32_t vendor;
 | 
				
			||||||
	//bstr16_t version;
 | 
						bstr16_t version;
 | 
				
			||||||
	const char *vendor_s;
 | 
						const char *vendor_s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint8_t *d;
 | 
						uint8_t *d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*        d += cw_put_dword(d, bstrv_get_vendor_id(v));
 | 
					 | 
				
			||||||
	d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
 | 
					 | 
				
			||||||
	d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
 | 
						sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
 | 
				
			||||||
	vendor_s = cw_cfg_get_l (cfg_list, key, NULL);
 | 
						vendor_s = cw_cfg_get_l (cfg_list, key, NULL);
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (vendor_s == NULL) {
 | 
						if (vendor_s == NULL) {
 | 
				
			||||||
		cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key);
 | 
							cw_log (LOG_ERR, "Can't put subelem %s, no value found. Setting zero.", key);
 | 
				
			||||||
		return 0;
 | 
							vendor_s = "0";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vendor = atoi(vendor_s);	
 | 
						vendor = atoi(vendor_s);	
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
 | 
						sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
 | 
				
			||||||
	cw_Val_t * val = cw_cfg_get_val_l(cfg_list, key, CW_TYPE_BSTR16);
 | 
						version = cw_cfg_get_bstr16_l(cfg_list,key,NULL);
 | 
				
			||||||
 | 
						if (version == NULL) {
 | 
				
			||||||
	//version = cw_cfg_get_bstr16 (cfg, key, NULL);
 | 
							cw_log (LOG_ERR, "Can't put subelem %s, no value found. Setting zero.", key);
 | 
				
			||||||
 | 
							version = bstr16_create_from_str("0.0.0.0");
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (val == NULL) {
 | 
					 | 
				
			||||||
		cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	d = dst;
 | 
						d = dst;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* put vendor */
 | 
						/* put vendor */
 | 
				
			||||||
	d += cw_put_dword(d, vendor); //->type->put (vendor, d);
 | 
						d += cw_put_dword(d, vendor); 
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* put version */
 | 
						/* put version */
 | 
				
			||||||
 | 
						d += cw_put_dword (d, (subelem_id << 16) | bstr16_len(version));
 | 
				
			||||||
 | 
						d += cw_put_bstr16(d, version);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d += cw_put_dword (d, (subelem_id << 16) | val->type->len(val));
 | 
						free(version);
 | 
				
			||||||
//	d += cw_put_bstr16(d, version);
 | 
					 | 
				
			||||||
	d += val->type->put(val,d);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_val_destroy(val);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//	free(version);
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	return d-dst;
 | 
						return d-dst;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										341
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							
							
						
						
									
										341
									
								
								src/cw/dbg.c
									
									
									
									
									
								
							@ -31,27 +31,121 @@
 | 
				
			|||||||
#include "format.h"
 | 
					#include "format.h"
 | 
				
			||||||
#include "ansi_colors.h"
 | 
					#include "ansi_colors.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "dot11.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *@addtogroup DBG
 | 
					 *@addtogroup DBG
 | 
				
			||||||
 *@{
 | 
					 *@{
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 /*
 | 
					 | 
				
			||||||
  * @defgroup DebugFunctions Debug Functions
 | 
					 | 
				
			||||||
  * @{
 | 
					 | 
				
			||||||
  */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
 | 
					uint32_t cw_dbg_opt_display = DBG_DISP_COLORS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Current debug level
 | 
					 * Contains all debuglevels currently set
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
uint32_t cw_dbg_opt_level = 0;
 | 
					static struct mavl * cw_dbg_opt_level = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int dbg_cmp(const void *a, const void*b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (*((int*)a)-*((int*)b));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_DbgStr {
 | 
				
			||||||
 | 
						int level;
 | 
				
			||||||
 | 
						const char *str;
 | 
				
			||||||
 | 
						const char ** str_list;
 | 
				
			||||||
 | 
						const char *descr;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_msg[] = {
 | 
				
			||||||
 | 
						"msg_in", "msg_out", NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_pkt[] = {
 | 
				
			||||||
 | 
						"pkt_in", "pkt_out",  NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_elem[]={
 | 
				
			||||||
 | 
						"elem_in","elem_out",NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_elem_detail[] = {
 | 
				
			||||||
 | 
						"elem_detail_in", "elem_detail_out", NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_elem_dmp[] = {
 | 
				
			||||||
 | 
						"elem_dmp_in", "elem_dmp_out", NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					static const char * dbg_level_elem_all[] = {
 | 
				
			||||||
 | 
						"elem", "elem_dmp", "elem_detail",NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char * dbg_level_std[] = {
 | 
				
			||||||
 | 
						"msg","elem","msg_err", "elem_err", "pkt_err", "rfc", "warn", "state", "info", NULL
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Debug strings
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct cw_DbgStr cw_dbg_strings[] = {
 | 
				
			||||||
 | 
						{ 0, 			"std", dbg_level_std, "some useful standard options to debug CAPWAP"},
 | 
				
			||||||
 | 
						{ 0,			"msg", dbg_level_msg, "messages headers" },
 | 
				
			||||||
 | 
						{ 0,			"pkt", dbg_level_pkt, "packet headers" },
 | 
				
			||||||
 | 
						{ 0,			"elem", dbg_level_elem, "message elemenst" },
 | 
				
			||||||
 | 
						{ 0, 			"elem_detail", dbg_level_elem_detail, "details for message elements"},
 | 
				
			||||||
 | 
						{ 0, 			"elem_dmp", dbg_level_elem_dmp,"hexdump element"},
 | 
				
			||||||
 | 
						{ 0, 			"elem_all", dbg_level_elem_all,"all possible elem options"},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_WARN,		"warn", NULL, "warnings" },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_ELEM_ERR, 	"elem_err", NULL, "errors in elements" },
 | 
				
			||||||
 | 
						{ DBG_PKT_ERR,		"pkt_err", NULL, "packets with errors which are usually would be discard" },
 | 
				
			||||||
 | 
						{ DBG_MSG_ERR,		"msg_err", NULL, "message errors"},
 | 
				
			||||||
 | 
						{ DBG_RFC,		"rfc", NULL, "errors related to RFC5415/RFC5416 viloations" },
 | 
				
			||||||
 | 
						{ DBG_CFG_UPDATES, 	"cfg_updates",NULL, "show configuration aupdates" },
 | 
				
			||||||
 | 
						{ DBG_MOD,		"mod",NULL, "module related"},
 | 
				
			||||||
 | 
						{ DBG_MOD_DETAIL,	"mod_detail",NULL, "module related details"},
 | 
				
			||||||
 | 
						{ DBG_STATE,		"state",NULL, "CAWPAP states" },
 | 
				
			||||||
 | 
						{ DBG_MSG_COMPOSE,	"msg_compose",NULL,"message composing details" },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_INFO,		"info", NULL, "several infos are displayed" },
 | 
				
			||||||
 | 
						{ DBG_PKT_IN,		"pkt_in",NULL, "headers of incomming packets."  },
 | 
				
			||||||
 | 
						{ DBG_PKT_OUT,		"pkt_out",NULL, "headers out outgoing packets." },
 | 
				
			||||||
 | 
						{ DBG_PKT_DMP_IN,	"pkt_dmp_in",NULL, "hex-dump incomming packets" },
 | 
				
			||||||
 | 
						{ DBG_PKT_DMP_OUT,	"pkt_dmp_out",NULL, "hex-dump outgoing packets"  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_MSG_IN,		"msg_in", NULL, "incomming messages" },
 | 
				
			||||||
 | 
						{ DBG_MSG_OUT,		"msg_out", NULL, "outgoing messages" },
 | 
				
			||||||
 | 
						{ DBG_MSG_DMP_IN,	"msg_dmp_in", NULL, "hex-dump incomming messages" },
 | 
				
			||||||
 | 
						{ DBG_MSG_DMP_OUT,	"msg_dmp_out", NULL,"hex-dump of outgong messages"  },
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_ELEM_IN,  	"elem_in", NULL, "elements of incomming messages"},
 | 
				
			||||||
 | 
						{ DBG_ELEM_OUT, 	"elem_out", NULL, "elements of outgoing messages"},
 | 
				
			||||||
 | 
						{ DBG_ELEM_DETAIL_IN, 	"elem_detail_in", NULL, "details of incomming message elements" },
 | 
				
			||||||
 | 
						{ DBG_ELEM_DETAIL_OUT, 	"elem_detail_out",NULL, "details of outgoing message elememnts" },
 | 
				
			||||||
 | 
						{ DBG_ELEM_DMP_IN, 	"elem_dmp_in", NULL, "hex-dump of incoming elements"},
 | 
				
			||||||
 | 
						{ DBG_ELEM_DMP_OUT, 	"elem_dmp_out", NULL, "hex-dump of outgoing elements"},
 | 
				
			||||||
 | 
						{ DBG_ELEM_VNDR,	"elem_vndr", NULL, "expand vendor specific payloads"},	
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						{ DBG_DTLS, 		"dtls",NULL, "DTLS related stuff"},
 | 
				
			||||||
 | 
						{ DBG_DTLS_BIO,		"dtls_bio",NULL, "DTLS BIO releated" },
 | 
				
			||||||
 | 
						{ DBG_DTLS_BIO_DMP,	"dtls_bio_dmp",NULL, "hex-dump dtls packets" },
 | 
				
			||||||
 | 
						{ DBG_DTLS_DETAIL, 	"dtls_detail",NULL, "DTLS detailed messages"},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_X,		"x", NULL, "only for developers" },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						{ DBG_ALL, 		"all", NULL, "all debug levels at once"},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						{ 0, NULL } 
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,7 +197,6 @@ static struct cw_StrListElem * color_on = theme0;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct cw_StrListElem color_ontext[] = {
 | 
					struct cw_StrListElem color_ontext[] = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*	{DBG_ELEM_DMP, "\x1b[37m"},*/
 | 
					 | 
				
			||||||
	{DBG_ELEM_DMP_OUT, ANSI_BBLACK ANSI_ITALIC},
 | 
						{DBG_ELEM_DMP_OUT, ANSI_BBLACK ANSI_ITALIC},
 | 
				
			||||||
	{DBG_ELEM_DMP_IN,  ANSI_BBLACK},
 | 
						{DBG_ELEM_DMP_IN,  ANSI_BBLACK},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -182,16 +275,36 @@ const char *get_dbg_color_ontext(int level)
 | 
				
			|||||||
 * @param level Level to check
 | 
					 * @param level Level to check
 | 
				
			||||||
 * @return 0 if leveln is not set, otherwise level is set
 | 
					 * @return 0 if leveln is not set, otherwise level is set
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					 | 
				
			||||||
int cw_dbg_is_level(int level)
 | 
					int cw_dbg_is_level(int level)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (level > 1 && (level &1))
 | 
						if (cw_dbg_opt_level == NULL)
 | 
				
			||||||
		return 1;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*	if (level >= DBG_ALL ){
 | 
						return mavl_get(cw_dbg_opt_level,&level) == NULL ? 0:1;
 | 
				
			||||||
		return 1;
 | 
					}
 | 
				
			||||||
	}*/
 | 
					
 | 
				
			||||||
	return (cw_dbg_opt_level & (level));
 | 
					/**
 | 
				
			||||||
 | 
					  * Set debug level
 | 
				
			||||||
 | 
					  * @param level debug level to set, allowed values are enumberated in #cw_dbg_levels structure.
 | 
				
			||||||
 | 
					  * @param on 1: turns the specified debug level on, 0: turns the specified debug level off.
 | 
				
			||||||
 | 
					  *
 | 
				
			||||||
 | 
					  * To check if a specific debug level is set, call #cw_dbg_is_level.
 | 
				
			||||||
 | 
					  */
 | 
				
			||||||
 | 
					void cw_dbg_set_level (int level, int on)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int exists;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (cw_dbg_opt_level == NULL){
 | 
				
			||||||
 | 
							cw_dbg_opt_level = mavl_create(dbg_cmp,NULL,sizeof(int));
 | 
				
			||||||
 | 
							if (cw_dbg_opt_level == NULL)
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (on){
 | 
				
			||||||
 | 
							mavl_insert(cw_dbg_opt_level,&level,&exists);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else 
 | 
				
			||||||
 | 
							mavl_del(cw_dbg_opt_level,&level);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -211,63 +324,37 @@ static void cw_dbg_vlog_line(struct cw_LogWriter * writer,
 | 
				
			|||||||
				
 | 
									
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	writer->write(LOG_DEBUG,fbuf,args,writer);
 | 
						writer->write(LOG_DEBUG,fbuf,args,writer);
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Put a list of missing mandatory message elements to debug output
 | 
					 * Display a packet on debugger
 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
void cw_dbg_missing_mand(int level, struct cw_Conn *conn, int ** ml, int n,
 | 
					 | 
				
			||||||
			 int  * a)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
//      if (!cw_dbg_is_level(DBG_MSG_ERR) || n == 0)
 | 
					 | 
				
			||||||
//              return;
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	char buffer[2000];
 | 
					 | 
				
			||||||
/*	char *p = buffer; */
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
/*	char *delim = "";*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (!cw_dbg_is_level(level) || n == 0)
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	// TODO XXXX
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	for (i = 0; i < n; i++) {
 | 
					 | 
				
			||||||
/*		p += sprintf(p, "%s", delim);
 | 
					 | 
				
			||||||
		delim = ", ";
 | 
					 | 
				
			||||||
		p += sprintf(p, "%s", cw_strelemp(conn->actions, ml[i]->elem_id));
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	cw_dbg(level, "Missing mandatory elements: [%s]", buffer);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Display a packet on for debugger
 | 
					 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
 | 
					void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
 | 
				
			||||||
		struct sockaddr *from)
 | 
							struct sockaddr *from)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*	int hlen;*/
 | 
					 | 
				
			||||||
	char buf[1024];
 | 
						char buf[1024];
 | 
				
			||||||
 | 
						int (*fmt_pkt_hdr)(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from);
 | 
				
			||||||
 | 
						fmt_pkt_hdr = NULL;
 | 
				
			||||||
 | 
						if (conn){
 | 
				
			||||||
 | 
							if (conn->msgset)
 | 
				
			||||||
 | 
								fmt_pkt_hdr = conn->msgset->format_pkt_hdr;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (fmt_pkt_hdr==NULL){
 | 
				
			||||||
 | 
							fmt_pkt_hdr = cw_format_pkt_hdr;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!cw_dbg_is_level(level))
 | 
						if (!cw_dbg_is_level(level))
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (level == DBG_PKT_IN)
 | 
						if (level == DBG_PKT_IN)
 | 
				
			||||||
		cw_format_pkt_hdr(buf, 1,  packet, len, from);
 | 
							fmt_pkt_hdr(buf, 1,  packet, len, from);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		cw_format_pkt_hdr(buf, 0,  packet, len, from);
 | 
							fmt_pkt_hdr(buf, 0,  packet, len, from);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
/*	hlen = cw_get_hdr_msg_offset(packet);*/
 | 
					/*	hlen = cw_get_hdr_msg_offset(packet);*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -414,7 +501,7 @@ void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
 | 
				
			|||||||
	cw_dbg(level,"%s %d (%s), len=%d ",vendorname,handler->id,
 | 
						cw_dbg(level,"%s %d (%s), len=%d ",vendorname,handler->id,
 | 
				
			||||||
			handler->name,len);
 | 
								handler->name,len);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	if (cw_dbg_is_level(DBG_ELEM_DMP)) {
 | 
						if (cw_dbg_is_level(DBG_ELEM_DMP_OUT) || cw_dbg_is_level(DBG_ELEM_DMP_IN)) {
 | 
				
			||||||
		if (level == DBG_ELEM_OUT)
 | 
							if (level == DBG_ELEM_OUT)
 | 
				
			||||||
			cw_dbg_dmp(DBG_ELEM_DMP_OUT,msgbuf,len,"");
 | 
								cw_dbg_dmp(DBG_ELEM_DMP_OUT,msgbuf,len,"");
 | 
				
			||||||
		else 
 | 
							else 
 | 
				
			||||||
@ -429,36 +516,132 @@ void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_dbg_set_level_from_str0(const char *level,int on)
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
void dbg_istore_dmp(mbag_t s)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	DEFINE_AVLITER(it,s);
 | 
						int i,all;
 | 
				
			||||||
	avliter_foreach(&it) {
 | 
						all = strcmp(level,"all")==0 ? 1: 0;
 | 
				
			||||||
 | 
					 | 
				
			||||||
		mbag_item_t *i = avliter_get(&it);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		char buffer[1000];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		struct cw_str * strings = cw_item_strings;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		const char * in = cw_strlist_get_str(strings,i->id);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		cw_format_item(buffer,i);
 | 
					 | 
				
			||||||
		printf("Item ID %d-%s: %s\n",i->id,in,buffer);
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						for(i=0; cw_dbg_strings[i].str != NULL; i++){
 | 
				
			||||||
 | 
							if (strcmp(cw_dbg_strings[i].str,level)==0 || all){
 | 
				
			||||||
 | 
								if (cw_dbg_strings[i].str_list==NULL)
 | 
				
			||||||
 | 
									cw_dbg_set_level(cw_dbg_strings[i].level,on);
 | 
				
			||||||
 | 
								else {
 | 
				
			||||||
 | 
									const char **l;
 | 
				
			||||||
 | 
									for (l=cw_dbg_strings[i].str_list; *l; l++){
 | 
				
			||||||
 | 
										if (!cw_dbg_set_level_from_str0(*l,on)){
 | 
				
			||||||
 | 
											stop();
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								if (!all)
 | 
				
			||||||
 | 
									return 1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
						if (all)
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
					/*	blevel = cw_strlist_get_id(cw_dbg_strings, slevel);
 | 
				
			||||||
 | 
						if (blevel==-1)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
*/		
 | 
					*/		
 | 
				
			||||||
 | 
					//	cw_dbg_set_level(blevel,on);
 | 
				
			||||||
 | 
					//	return 1;
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_dbg_set_level_from_str(const char *level)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int on;
 | 
				
			||||||
 | 
						const char *slevel;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						switch(*level){
 | 
				
			||||||
 | 
							case '-':
 | 
				
			||||||
 | 
							case '!':
 | 
				
			||||||
 | 
							case '~':
 | 
				
			||||||
 | 
								on =0;
 | 
				
			||||||
 | 
								slevel=level+1;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case '+':
 | 
				
			||||||
 | 
								slevel=level+1;
 | 
				
			||||||
 | 
								on=1;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								slevel=level;
 | 
				
			||||||
 | 
								on=1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return cw_dbg_set_level_from_str0(slevel,on);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_dbg_print_help(FILE *out, const char * prefix)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cw_DbgStr *s;
 | 
				
			||||||
 | 
						for (s=cw_dbg_strings; s->str != NULL; s++){
 | 
				
			||||||
 | 
							const char * descr = s->descr!=NULL ? s->descr : "";
 | 
				
			||||||
 | 
							fprintf(out,"%s%s: %s",prefix,s->str,descr);
 | 
				
			||||||
 | 
							if (s->str_list != NULL){
 | 
				
			||||||
 | 
								const char **l;
 | 
				
			||||||
 | 
								char *sp="";
 | 
				
			||||||
 | 
								fprintf(out," (");
 | 
				
			||||||
 | 
								for(l = s->str_list; *l!=NULL; l++){
 | 
				
			||||||
 | 
									fprintf(out,"%s%s",sp,*l);
 | 
				
			||||||
 | 
									sp=" ";
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								fprintf(out,")");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							fprintf(out,"\n");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_dbg_dot11_elems(const uint8_t *src,int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						uint8_t id,l;
 | 
				
			||||||
 | 
						int p;
 | 
				
			||||||
 | 
						char str[1024];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(p=0; p<len; p+=l+2){
 | 
				
			||||||
 | 
							if (len-p<3){
 | 
				
			||||||
 | 
								cw_dbg(DBG_X,"Error in dot11 element");
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							id=src[p];
 | 
				
			||||||
 | 
							l=src[p+1];
 | 
				
			||||||
 | 
							cw_format_dot11_elem(str,id,src+p+2,l);
 | 
				
			||||||
 | 
							cw_dbg_dmp(DBG_X,src+p+2,l,"");
 | 
				
			||||||
 | 
							cw_dbg(DBG_X,str);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_dbg_dot11_frame(uint8_t * frame,int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char hdr[1024];
 | 
				
			||||||
 | 
						cw_format_dot11_hdr(hdr, frame, len);
 | 
				
			||||||
 | 
						cw_dbg(DBG_X,"%s",hdr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int type =dot11_get_type_and_subtype(frame);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch (type){
 | 
				
			||||||
 | 
							case DOT11_ASSOC_REQ:
 | 
				
			||||||
 | 
								cw_dbg_dot11_elems(frame+28,len-28);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case DOT11_ASSOC_RESP:
 | 
				
			||||||
 | 
								cw_dbg(DBG_X,"  Capapility info: %04X",dot11_assoc_resp_get_cap(frame)); 
 | 
				
			||||||
 | 
								cw_dbg(DBG_X,"  Status CodeCapapility info: %04X",dot11_assoc_resp_get_status_code(frame));
 | 
				
			||||||
 | 
								cw_dbg(DBG_X,"  Assoc ID: %04X",dot11_assoc_resp_get_assoc_id(frame)); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								cw_dbg_dot11_elems((frame+DOT11_BODY_POS+DOT11_ASSOC_RESP_BODY_LEN),
 | 
				
			||||||
 | 
										len-DOT11_BODY_POS-DOT11_ASSOC_RESP_BODY_LEN);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**@}*/
 | 
					/**@}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**@}*/
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										97
									
								
								src/cw/dbg.h
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								src/cw/dbg.h
									
									
									
									
									
								
							@ -39,7 +39,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *@addtogroup LOGDBG
 | 
					 *@addtogroup DBG
 | 
				
			||||||
 *@{
 | 
					 *@{
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -48,92 +48,91 @@
 | 
				
			|||||||
 */ 
 | 
					 */ 
 | 
				
			||||||
enum cw_dbg_levels{
 | 
					enum cw_dbg_levels{
 | 
				
			||||||
	/** Show headers of incomming/outgoing CAPWAP packets */
 | 
						/** Show headers of incomming/outgoing CAPWAP packets */
 | 
				
			||||||
	DBG_PKT_IN 	= (1<<0), 
 | 
						DBG_PKT_IN 	= 1, 
 | 
				
			||||||
	DBG_PKT_OUT 	= (1<<1),	
 | 
						DBG_PKT_OUT,	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Hex-dump incomming/outgoing CAPWAP packets */
 | 
						/** Hex-dump incomming/outgoing CAPWAP packets */
 | 
				
			||||||
	DBG_PKT_DMP_IN	= (1<<3),
 | 
						DBG_PKT_DMP_IN,
 | 
				
			||||||
	DBG_PKT_DMP_OUT = (1<<4),
 | 
						DBG_PKT_DMP_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Incomming CAPWAP packets with errors, wich would
 | 
						/** Incomming CAPWAP packets with errors, wich would
 | 
				
			||||||
	    usually silently discarded */ 
 | 
						    usually silently discarded */ 
 | 
				
			||||||
	DBG_PKT_ERR	= (1<<5),
 | 
						DBG_PKT_ERR,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Display incomming/outgoing CAPWAP/LWAPP messages */
 | 
						/** Display incomming/outgoing CAPWAP/LWAPP messages */
 | 
				
			||||||
	DBG_MSG_IN	= (1<<6),
 | 
						DBG_MSG_IN,
 | 
				
			||||||
	DBG_MSG_OUT	= (1<<7),
 | 
						DBG_MSG_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Show hex-dump of messages */
 | 
						/** Show hex-dump of messages */
 | 
				
			||||||
	DBG_MSG_DMP_IN	= (1<<8),
 | 
						DBG_MSG_DMP_IN,
 | 
				
			||||||
	DBG_MSG_DMP_OUT	= (1<<9),
 | 
						DBG_MSG_DMP_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Message errors */
 | 
						/** Message errors */
 | 
				
			||||||
	DBG_MSG_ERR	= (1<<10),
 | 
						DBG_MSG_ERR,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Show message elements in incomming/outgoing messages */
 | 
						/** Show message elements in incomming/outgoing messages */
 | 
				
			||||||
	DBG_ELEM_IN	= (1<<11),
 | 
						DBG_ELEM_IN,
 | 
				
			||||||
	DBG_ELEM_OUT	= (1<<12),
 | 
						DBG_ELEM_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Show message element details  */
 | 
						/** Show message element details  */
 | 
				
			||||||
	DBG_ELEM_DETAIL_IN = (1<<13),
 | 
						DBG_ELEM_DETAIL_IN,
 | 
				
			||||||
	DBG_ELEM_DETAIL_OUT = (1<<14),
 | 
						DBG_ELEM_DETAIL_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Error in msg elements */
 | 
						/** Error in msg elements */
 | 
				
			||||||
	DBG_ELEM_ERR	= (1<<15),
 | 
						DBG_ELEM_ERR,
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/** hex dump elements */	
 | 
					 | 
				
			||||||
	DBG_ELEM_DMP	= (1<<16),
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** General infos, like CAPWAP state */
 | 
						/** General infos, like CAPWAP state */
 | 
				
			||||||
	DBG_INFO	= (1<<17),	
 | 
						DBG_INFO,	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Misc. warnings */
 | 
						/** Misc. warnings */
 | 
				
			||||||
	DBG_WARN	= (1<<18),
 | 
						DBG_WARN,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** RFC related */
 | 
						/** RFC related */
 | 
				
			||||||
	DBG_RFC		= (1<<19),
 | 
						DBG_RFC,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** DTLS related messages */
 | 
						/** DTLS related messages */
 | 
				
			||||||
	DBG_DTLS	= (1<<20),
 | 
						DBG_DTLS,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** DTLS BIOs in/out */
 | 
						/** DTLS BIOs in/out */
 | 
				
			||||||
	DBG_DTLS_BIO	= (1<<21),
 | 
						DBG_DTLS_BIO,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Dump DTLS BIO i/o */
 | 
						/** Dump DTLS BIO i/o */
 | 
				
			||||||
	DBG_DTLS_BIO_DMP = (1<<22),
 | 
						DBG_DTLS_BIO_DMP,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Show DTLS Details */
 | 
						/** Show DTLS Details */
 | 
				
			||||||
	DBG_DTLS_DETAIL	= (1<<23),
 | 
						DBG_DTLS_DETAIL,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
//	DBG_CFG_DMP	= (1<<20),
 | 
					//	DBG_CFG_DMP,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//	DBG_CFG_SET	= (1<<21),
 | 
					//	DBG_CFG_SET,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/** Debug Mods */
 | 
						/** Debug Mods */
 | 
				
			||||||
	DBG_MOD		= (1<<24),
 | 
						DBG_MOD,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
       	/**Debug State machine */
 | 
					       	/**Debug State machine */
 | 
				
			||||||
	DBG_STATE	= (1<<25),
 | 
						DBG_STATE,
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/** Infos about nessage composing */	
 | 
				
			||||||
 | 
						DBG_MSG_COMPOSE,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Debug Configuration updates */
 | 
				
			||||||
 | 
						DBG_CFG_UPDATES,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Debug Vendor elements */
 | 
				
			||||||
 | 
						DBG_ELEM_VNDR,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	DBG_MSG_COMPOSE	= (1<<26),
 | 
						DBG_X,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DBG_CFG_UPDATES	= (1<<27),
 | 
						DBG_MOD_DETAIL,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DBG_ELEM_VNDR	= (1<<28),
 | 
						DBG_ALL,
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	DBG_X		= (1<<30),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	DBG_MOD_DETAIL	= (1<<31),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	DBG_ALL 	= (0x7fffffff),
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	DBG_ELEM_DMP_IN	= 7,
 | 
					 | 
				
			||||||
	DBG_ELEM_DMP_OUT = 9,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** Hexdump incoming msg elemenets */
 | 
				
			||||||
 | 
						DBG_ELEM_DMP_IN,
 | 
				
			||||||
 | 
						/** Hexdump outgoing msg elemenst */
 | 
				
			||||||
 | 
						DBG_ELEM_DMP_OUT,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -192,8 +191,8 @@ void cw_dbg_dmp(int level, const uint8_t * data, int len, const char *format, ..
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern uint32_t cw_dbg_opt_display;
 | 
					extern uint32_t cw_dbg_opt_display;
 | 
				
			||||||
extern uint32_t cw_dbg_opt_level;
 | 
					//extern uint32_t cw_dbg_opt_level;
 | 
				
			||||||
extern struct cw_StrListElem cw_dbg_strings[];
 | 
					//extern struct cw_StrListElem cw_dbg_strings[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
#define cw_dbg cw_dbg_colored
 | 
					#define cw_dbg cw_dbg_colored
 | 
				
			||||||
@ -220,8 +219,6 @@ void cw_dbg_msg(int level,struct cw_Conn *conn, uint8_t * packet, int len,struct
 | 
				
			|||||||
char * cw_dbg_mkdmp(const uint8_t * data, int len);
 | 
					char * cw_dbg_mkdmp(const uint8_t * data, int len);
 | 
				
			||||||
//void cw_dbg_version_subelem(int level, const char *context, int subtype, 
 | 
					//void cw_dbg_version_subelem(int level, const char *context, int subtype, 
 | 
				
			||||||
//		uint32_t vendor_id, const uint8_t * vstr, int len);
 | 
					//		uint32_t vendor_id, const uint8_t * vstr, int len);
 | 
				
			||||||
void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel, 
 | 
					 | 
				
			||||||
		const char *header, const char *prefix, const char *footer );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  * Set debug level
 | 
					  * Set debug level
 | 
				
			||||||
@ -243,6 +240,10 @@ void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
int cw_dbg_is_level(int level);
 | 
					int cw_dbg_is_level(int level);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cw_dbg_print_help(FILE *out, const char * prefix);
 | 
				
			||||||
 | 
					void cw_dbg_dot11_frame(uint8_t * frame,int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define stop() printf("STOP IN %s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__); exit(1)
 | 
					#define stop() printf("STOP IN %s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__); exit(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,137 +0,0 @@
 | 
				
			|||||||
/*
 | 
					 | 
				
			||||||
    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 <http://www.gnu.org/licenses/>.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 *@file
 | 
					 | 
				
			||||||
 *@brief 
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 *@addtogroup DbgOptions 
 | 
					 | 
				
			||||||
 *@{
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Debug strings
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
struct cw_StrListElem cw_dbg_strings[] = {
 | 
					 | 
				
			||||||
	{ DBG_INFO,		"info",  },
 | 
					 | 
				
			||||||
	{ DBG_PKT_IN,		"pkt_in"  },
 | 
					 | 
				
			||||||
	{ DBG_PKT_OUT,		"pkt_out" },
 | 
					 | 
				
			||||||
	{ DBG_PKT_ERR,		"pkt_err" },
 | 
					 | 
				
			||||||
	{ DBG_PKT_DMP_IN,	"pkt_dmp_in" },
 | 
					 | 
				
			||||||
	{ DBG_PKT_DMP_OUT,	"pkt_dmp_out" },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ DBG_MSG_IN,		"msg_in"  },
 | 
					 | 
				
			||||||
	{ DBG_MSG_OUT,		"msg_out" },
 | 
					 | 
				
			||||||
	{ DBG_MSG_DMP_IN,	"msg_dmp_in"  },
 | 
					 | 
				
			||||||
	{ DBG_MSG_DMP_OUT,	"msg_dmp_out" },
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	{ DBG_MSG_ERR,		"msg_err"},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ DBG_RFC,		"rfc", 	 },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ DBG_ELEM_IN,  	"elem_in"},
 | 
					 | 
				
			||||||
	{ DBG_ELEM_OUT, 	"elem_out"},
 | 
					 | 
				
			||||||
	{ DBG_ELEM_DMP, 	"elem_dmp"},
 | 
					 | 
				
			||||||
	{ DBG_ELEM_ERR, 	"elem_err" },
 | 
					 | 
				
			||||||
	{ DBG_ELEM_DETAIL_IN, 	"elem_detail_in" },
 | 
					 | 
				
			||||||
	{ DBG_ELEM_DETAIL_OUT, 	"elem_detail_out" },
 | 
					 | 
				
			||||||
	{ DBG_ELEM_VNDR,	"elem_vndr"},	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	{ DBG_DTLS, 		"dtls" },
 | 
					 | 
				
			||||||
	{ DBG_DTLS_BIO,		"dtls_bio" },
 | 
					 | 
				
			||||||
	{ DBG_DTLS_BIO_DMP,	"dtls_bio_dmp"},
 | 
					 | 
				
			||||||
	{ DBG_DTLS_DETAIL, 	"dtls_detail"},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ DBG_CFG_UPDATES, 	"cfg_updates" },
 | 
					 | 
				
			||||||
	{ DBG_X,		"x" },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	{DBG_CFG_DMP, "cfg_dmp" },
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	{ DBG_WARN,		"warn" },
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	{ DBG_MOD,		"mod"},
 | 
					 | 
				
			||||||
	{ DBG_STATE,		"state" },
 | 
					 | 
				
			||||||
	{ DBG_MSG_COMPOSE,	"msg_compose" },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ (DBG_MSG_IN | DBG_MSG_OUT), "msg" },
 | 
					 | 
				
			||||||
	{ (DBG_PKT_IN | DBG_PKT_OUT), "pkt" },
 | 
					 | 
				
			||||||
	{ (DBG_ELEM_IN | DBG_ELEM_OUT), "elem" },
 | 
					 | 
				
			||||||
	{ (DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_detail" },
 | 
					 | 
				
			||||||
	{ (DBG_ELEM_IN | DBG_ELEM_OUT | DBG_ELEM_DMP | DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_all" },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ (	DBG_MSG_IN | DBG_MSG_OUT | 
 | 
					 | 
				
			||||||
		DBG_ELEM_IN | DBG_ELEM_OUT |
 | 
					 | 
				
			||||||
		DBG_MSG_ERR | DBG_ELEM_ERR |
 | 
					 | 
				
			||||||
		DBG_PKT_ERR | DBG_RFC | DBG_WARN
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		| DBG_STATE), 			"std" },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{ DBG_ALL, 		"all"},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	{ CW_STR_STOP, NULL } 
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 *@}
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
struct cw_dbg_cfgstrs cw_dbg_cfgstrs[] = {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{"info",DBG_CW_INFO},
 | 
					 | 
				
			||||||
	{"msg",DBG_MSG},
 | 
					 | 
				
			||||||
	{"elem",DBG_ELEM},
 | 
					 | 
				
			||||||
	{"elem_dmp",DBG_ELEM_DMP},
 | 
					 | 
				
			||||||
	{"rfc",DBG_CW_RFC},
 | 
					 | 
				
			||||||
	{"pkt_in",DBG_CW_PKT_IN},
 | 
					 | 
				
			||||||
	{"pkt_out",DBG_CW_PKT_OUT},
 | 
					 | 
				
			||||||
	{"pkt_dtl",DBG_CW_PKT_DTL},
 | 
					 | 
				
			||||||
	{"pkt",(DBG_CW_PKT_IN | DBG_CW_PKT_OUT)},
 | 
					 | 
				
			||||||
	{"pkt_dmp",DBG_CW_PKT_DMP},
 | 
					 | 
				
			||||||
	{"pkt_err",DBG_CW_PKT_ERR},
 | 
					 | 
				
			||||||
	{"msg_err",DBG_MSG_ERR},
 | 
					 | 
				
			||||||
	{"img_dtl",DBG_CW_IMG_DTL},
 | 
					 | 
				
			||||||
	{"elem_err",DBG_ELEM_ERR},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{"dtls",DBG_DTLS},
 | 
					 | 
				
			||||||
	{"dtls_dietail",DBG_DTLS_DETAIL},
 | 
					 | 
				
			||||||
	{"dtls_bio",DBG_DTLS_BIO},
 | 
					 | 
				
			||||||
	{"dtls_bio_dmp",DBG_DTLS_BIO_DMP},
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	{"all",DBG_ALL},
 | 
					 | 
				
			||||||
	{"err",DBG_ERR},
 | 
					 | 
				
			||||||
	{0,0}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -38,3 +38,28 @@ const char * dot11_type_strings[]=
 | 
				
			|||||||
	"Probe Req",
 | 
						"Probe Req",
 | 
				
			||||||
	"Probe Resp"
 | 
						"Probe Resp"
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct dot11_name{
 | 
				
			||||||
 | 
						uint8_t val;
 | 
				
			||||||
 | 
						const char * str;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_StrListElem dot11_names[]={
 | 
				
			||||||
 | 
						{DOT11_ASSOC_REQ, "Assoc Req"},
 | 
				
			||||||
 | 
						{DOT11_ASSOC_RESP, "Assoc Resp"},
 | 
				
			||||||
 | 
						{DOT11_REASSOC_REQ, "Reassoc Req"},
 | 
				
			||||||
 | 
						{DOT11_REASSOC_RESP, "Reassoc Resp"},
 | 
				
			||||||
 | 
						{DOT11_PROBE_REQ, "Probe Req"},	
 | 
				
			||||||
 | 
						{DOT11_PROBE_RESP, "Probe Resp"},
 | 
				
			||||||
 | 
						{DOT11_TIMING_ADV, "Timing Adv"},
 | 
				
			||||||
 | 
						{DOT11_MGM_RES111, "MGMRES111"},
 | 
				
			||||||
 | 
						{DOT11_BEACON, "Beacon"},
 | 
				
			||||||
 | 
						{CW_STR_STOP,"Unknown"},
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dot11_init_assoc_resp(uint8_t * dst)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						dot11_set_type_and_subtype(dst,DOT11_ASSOC_RESP);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										140
									
								
								src/cw/dot11.h
									
									
									
									
									
								
							
							
						
						
									
										140
									
								
								src/cw/dot11.h
									
									
									
									
									
								
							@ -20,6 +20,8 @@
 | 
				
			|||||||
#include <endian.h>
 | 
					#include <endian.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "strlist.h"
 | 
				
			||||||
 | 
					#include "bstr.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @defgroup DOT11_FRAME_TYPES Frame Types
 | 
					 * @defgroup DOT11_FRAME_TYPES Frame Types
 | 
				
			||||||
@ -47,17 +49,17 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * @{
 | 
					 * @{
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
#define DOT11_FC_ASSOC_REQ	dot11_fc_mgm(0b0000)
 | 
					#define DOT11_ASSOC_REQ		dot11_fc_mgm(0b0000)
 | 
				
			||||||
#define DOT11_FC_ASSOC_RESP	dot11_fc_mgm(0b0001)
 | 
					#define DOT11_ASSOC_RESP	dot11_fc_mgm(0b0001)
 | 
				
			||||||
#define DOT11_FC_REASSOC_REQ	dot11_fc_mgm(0b0010)
 | 
					#define DOT11_REASSOC_REQ	dot11_fc_mgm(0b0010)
 | 
				
			||||||
#define DOT11_FC_REASSOC_RESP	dot11_fc_mgm(0b0011)
 | 
					#define DOT11_REASSOC_RESP	dot11_fc_mgm(0b0011)
 | 
				
			||||||
#define DOT11_FC_PROBE_REQ	dot11_fc_mgm(0b0100)
 | 
					#define DOT11_PROBE_REQ		dot11_fc_mgm(0b0100)
 | 
				
			||||||
#define DOT11_FC_PROBE_RESP	dot11_fc_mgm(0b0101)
 | 
					#define DOT11_PROBE_RESP	dot11_fc_mgm(0b0101)
 | 
				
			||||||
#define DOT11_FC_TIMING_ADV	dot11_fc_mgm(0b0110)
 | 
					#define DOT11_TIMING_ADV	dot11_fc_mgm(0b0110)
 | 
				
			||||||
#define DOT11_FC_MGM_RES111	dot11_fc_mgm(0b0111)
 | 
					#define DOT11_MGM_RES111	dot11_fc_mgm(0b0111)
 | 
				
			||||||
#define DOT11_FC_BEACON		dot11_fc_mgm(0b1000)
 | 
					#define DOT11_BEACON		dot11_fc_mgm(0b1000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define DOT11_FC_DATA		dot11_fc_dta(0b0000)
 | 
					#define DOT11_DATA		dot11_fc_dta(0b0000)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @}
 | 
					 * @}
 | 
				
			||||||
@ -114,6 +116,14 @@
 | 
				
			|||||||
#define DOT11_ELEM_FH_PARAM_SET			2
 | 
					#define DOT11_ELEM_FH_PARAM_SET			2
 | 
				
			||||||
#define DOT11_ELEM_DSSS_PARAM_SET		3
 | 
					#define DOT11_ELEM_DSSS_PARAM_SET		3
 | 
				
			||||||
#define DOT11_ELEM_CF_PARAM_SET			4
 | 
					#define DOT11_ELEM_CF_PARAM_SET			4
 | 
				
			||||||
 | 
					#define DOT11_ELEM_POWER_CAPABILITY		33
 | 
				
			||||||
 | 
					#define DOT11_ELEM_SUPPORTED_CHANNELS		36
 | 
				
			||||||
 | 
					#define DOT11_ELEM_EXTENDED_SUPPORTED_RATES	50
 | 
				
			||||||
 | 
					#define DOT11_ELEM_AP_CHANNEL_REPORT		51
 | 
				
			||||||
 | 
					#define DOT11_ELEM_SUPPORTED_OPERATING_CLASSES	59
 | 
				
			||||||
 | 
					#define DOT11_ELEM_VENDOR_SPECIFIC		221
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @}
 | 
					 * @}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@ -125,27 +135,32 @@ extern const uint8_t dot11_tab_br[256];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define dot11_get_byte(ptr) (*(ptr))
 | 
					#define dot11_get_byte(ptr) (*(ptr))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define dot11_put_byte(ptr,b) (*(ptr) = b)
 | 
					#define dot11_put_byte(ptr,b) (*(ptr) = b,1)
 | 
				
			||||||
#define dot11_put_word(dst,v) ((*((uint16_t*)(dst))=htobe16(v)),2)
 | 
					#define dot11_put_word(dst,v) ((*((uint16_t*)(dst))=htobe16(v)),2)
 | 
				
			||||||
#define dot11_put_dword(dst,v) ((*((uint16_t*)(dst))=htobe16(v)),4)
 | 
					#define dot11_put_dword(dst,v) ((*((uint32_t*)(dst))=htobe32(v)),4)
 | 
				
			||||||
#define dot11_put_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)),8)
 | 
					#define dot11_put_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)),8)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_set_byte(ptr,b) (*(ptr) = b)
 | 
				
			||||||
 | 
					#define dot11_set_word(dst,v) ((*((uint16_t*)(dst))=htobe16(v)))
 | 
				
			||||||
 | 
					#define dot11_set_dword(dst,v) ((*((uint32_t*)(dst))=htobe32(v)))
 | 
				
			||||||
 | 
					#define dot11_set_qword(dst,v) ((*((uint64_t*)(dst))=htobe64(v)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_set_byte(ptr,b) (*(ptr) = b)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint16_t dot11_get_word(uint8_t * ptr);
 | 
					uint16_t dot11_get_word(uint8_t * ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define dot11_get_version(frame) ((frame[1])&0x03)
 | 
					#define dot11_get_version(frame) ( (frame)[1] & 0x03)
 | 
				
			||||||
#define dot11_get_type(frame) (((frame[1])&0x0c) >> 2)
 | 
					#define dot11_get_type(frame)    ( ((frame)[1] & 0x0c) >> 2)
 | 
				
			||||||
#define dot11_get_subtype(frame) (((frame[1])&0xf0) >> 4)
 | 
					#define dot11_get_subtype(frame) ( (frame)[1] >> 4 )
 | 
				
			||||||
/** 
 | 
					
 | 
				
			||||||
 * Get Frame Control field 
 | 
					#define dot11_get_type_and_subtype(frame) ((frame)[1])
 | 
				
			||||||
 * @param frame
 | 
					#define dot11_set_type_and_subtype(frame,val) ((frame)[1]=val)
 | 
				
			||||||
 * @return Frame Control field
 | 
					
 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define dot11_get_fc(frame) dot11_get_word(frame)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define dot11_get_duration(frame) dot11_get_word(frame+2)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void dot11_get_address(uint8_t * dst, uint8_t * frame);
 | 
					void dot11_get_address(uint8_t * dst, uint8_t * frame);
 | 
				
			||||||
@ -201,6 +216,9 @@ void dot11_timer_set(uint64_t val);
 | 
				
			|||||||
#define dot11_put_address(dst,addr) (memcpy(dst,addr,6),6)
 | 
					#define dot11_put_address(dst,addr) (memcpy(dst,addr,6),6)
 | 
				
			||||||
#define dot11_put_sequence_control(dst,v) (dot11_put_word(dst,v))
 | 
					#define dot11_put_sequence_control(dst,v) (dot11_put_word(dst,v))
 | 
				
			||||||
#define dot11_put_capability(dst,v) dot11_put_word(dst,v)
 | 
					#define dot11_put_capability(dst,v) dot11_put_word(dst,v)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int  dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len);
 | 
					int  dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -221,7 +239,9 @@ int  dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len);
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#define dot11_rate2float(rate) (((float)(rate))/2.0)
 | 
					#define dot11_rate2float(rate) (((float)(rate))/2.0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates);
 | 
					int dot11_put_supported_rates(uint8_t *dst, bstr_t src);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//		float *basic, float *rates);
 | 
				
			||||||
int dot11_put_dsss_param_set(uint8_t *dst,int ch);
 | 
					int dot11_put_dsss_param_set(uint8_t *dst,int ch);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -235,7 +255,81 @@ extern uint8_t dot11_broadcast_address[6];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern struct cw_StrListElem dot11_names[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_get_frame_name(data) cw_strlist_get_str(dot11_names,(data)[1])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** 
 | 
				
			||||||
 | 
					 * Get Frame Control field 
 | 
				
			||||||
 | 
					 * @param frame uint8_t pointer to the frame
 | 
				
			||||||
 | 
					 * @return uint16_t Frame Control field
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define dot11_get_fc(frame) dot11_get_word(frame)
 | 
				
			||||||
 | 
					 /** Get duration/aid field 
 | 
				
			||||||
 | 
					  * @param frame uint8_t pointer to frame */
 | 
				
			||||||
 | 
					#define dot11_get_duration(frame) dot11_get_word(frame+2)
 | 
				
			||||||
 | 
					#define dot11_get_da(frame) ((frame)+4)
 | 
				
			||||||
 | 
					#define dot11_get_sa(frame) ((frame)+10)
 | 
				
			||||||
 | 
					#define dot11_get_bssid(frame) ((frame)+16)
 | 
				
			||||||
 | 
					#define dot11_get_seq(frame) dot11_get_word((frame)+22)
 | 
				
			||||||
 | 
					#define dot11_get_body(frame) ((frame)+24)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DOT11_BODY_POS 24
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_set_duration(frame,d) dot11_set_word(frame+2,d)
 | 
				
			||||||
 | 
					#define dot11_set_seq(frame,s) dot11_set_word((frame)+22,s)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DOT11_ASSOC_RESP_BODY_LEN 6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_assoc_req_get_cap(frame) \
 | 
				
			||||||
 | 
							dot11_get_word((frame)+24)
 | 
				
			||||||
 | 
					#define dot11_assoc_req_get_listen_interval(frame) \
 | 
				
			||||||
 | 
								dot11_get_word((frame)+24+2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					#define dot11_assoc_req_get_ssid_len(frame)\
 | 
				
			||||||
 | 
								((frame)[29])
 | 
				
			||||||
 | 
					#define dot11_assoc_req_get_ssid(frame)\
 | 
				
			||||||
 | 
								(frame+30)
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_set_cap(frame,cap)\
 | 
				
			||||||
 | 
						dot11_set_word(dot11_get_body(frame),cap)
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_get_cap(frame)\
 | 
				
			||||||
 | 
						dot11_get_word(dot11_get_body(frame))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_set_status_code(frame,code)\
 | 
				
			||||||
 | 
						dot11_set_word(dot11_get_body(frame)+2,code)
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_get_status_code(frame)\
 | 
				
			||||||
 | 
						dot11_get_word(dot11_get_body(frame)+2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_set_assoc_id(frame,id)\
 | 
				
			||||||
 | 
						dot11_set_word(dot11_get_body(frame)+4,id)
 | 
				
			||||||
 | 
					#define dot11_assoc_resp_get_assoc_id(frame)\
 | 
				
			||||||
 | 
						dot11_get_word(dot11_get_body(frame)+4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//#define dot11_assoce_resp_get_var_body(frame) 
 | 
				
			||||||
 | 
					//	(get_frame_body(frame)+6)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define dot11_copy_mac(src,dst)\
 | 
				
			||||||
 | 
						memcpy(dst,src,6);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_Dot11Elemenst {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bstr_t supportet_rates;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dot11_init_assoc_resp(uint8_t * dst);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 | 
				
			|||||||
@ -31,8 +31,6 @@ uint64_t dot11_timer_get()
 | 
				
			|||||||
	return 1000000 * tv.tv_sec + tv.tv_usec - dot11_timer_offset;
 | 
						return 1000000 * tv.tv_sec + tv.tv_usec - dot11_timer_offset;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void dot11_timer_set(uint64_t val)
 | 
					void dot11_timer_set(uint64_t val)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct timeval tv;
 | 
						struct timeval tv;
 | 
				
			||||||
@ -41,14 +39,15 @@ void dot11_timer_set(uint64_t val)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int  dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len){
 | 
					int  dot11_put_ssid(uint8_t *dst,uint8_t * ssid,int len){
 | 
				
			||||||
	dot11_put_byte(dst,DOT11_ELEM_SSID);
 | 
						dot11_set_byte(dst,DOT11_ELEM_SSID);
 | 
				
			||||||
	dot11_put_byte(dst+1,len);
 | 
						dot11_set_byte(dst+1,len);
 | 
				
			||||||
	memcpy(dst+2,ssid,len);
 | 
						memcpy(dst+2,ssid,len);
 | 
				
			||||||
	return len;
 | 
						return len;
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates){
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dot11_convert_supported_rates(uint8_t *dst, float *basic, float *rates){
 | 
				
			||||||
	uint8_t *d = dst+2;
 | 
						uint8_t *d = dst+2;
 | 
				
			||||||
	while(*basic != 0.0){
 | 
						while(*basic != 0.0){
 | 
				
			||||||
		*d++ = 0x80 | dot11_float2rate(*basic);
 | 
							*d++ = 0x80 | dot11_float2rate(*basic);
 | 
				
			||||||
@ -65,12 +64,25 @@ int dot11_put_supported_rates(uint8_t *dst, float *basic, float *rates){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int dot11_put_supported_rates(uint8_t * dst, bstr_t src)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int l = bstr_len(src);
 | 
				
			||||||
 | 
						dot11_set_byte(dst,DOT11_ELEM_SUPPORTED_RATES);
 | 
				
			||||||
 | 
						memcpy(dst+1, src,l+1);
 | 
				
			||||||
 | 
						return l+2;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int dot11_put_dsss_param_set(uint8_t *dst,int ch) {
 | 
					int dot11_put_dsss_param_set(uint8_t *dst,int ch) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dot11_put_byte(dst,DOT11_ELEM_DSSS_PARAM_SET);
 | 
						dot11_set_byte(dst,DOT11_ELEM_DSSS_PARAM_SET);
 | 
				
			||||||
	dot11_put_byte(dst+1,1);
 | 
						dot11_set_byte(dst+1,1);
 | 
				
			||||||
	dot11_put_byte(dst+2,ch);
 | 
						dot11_set_byte(dst+2,ch);
 | 
				
			||||||
	return 3;
 | 
						return 3;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DOT11_INLINE 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -305,7 +305,10 @@ static unsigned int psk_server_cb(SSL *ssl,const char *identity, unsigned char *
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static unsigned int timer_cb(SSL *s, unsigned int timer_us)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return 5000000;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
 | 
					struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const SSL_METHOD * method, BIO_METHOD * bio)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -322,7 +325,7 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = SSL_CTX_get_security_level(d->ctx);
 | 
					//	rc = SSL_CTX_get_security_level(d->ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SSL_CTX_set_security_level(d->ctx,0);
 | 
						SSL_CTX_set_security_level(d->ctx,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -338,6 +341,8 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* set dtls psk if exists */
 | 
						/* set dtls psk if exists */
 | 
				
			||||||
/*	if (conn->dtls_psk)
 | 
					/*	if (conn->dtls_psk)
 | 
				
			||||||
		SSL_CTX_set_psk_server_callback( d->ctx, psk_server_cb);
 | 
							SSL_CTX_set_psk_server_callback( d->ctx, psk_server_cb);
 | 
				
			||||||
@ -456,6 +461,7 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
 | 
				
			|||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DTLS_set_timer_cb(d->ssl,timer_cb);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	d->bio = BIO_new(bio);
 | 
						d->bio = BIO_new(bio);
 | 
				
			||||||
/*	d->bio->ptr = conn;*/
 | 
					/*	d->bio->ptr = conn;*/
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										145
									
								
								src/cw/format.c
									
									
									
									
									
								
							
							
						
						
									
										145
									
								
								src/cw/format.c
									
									
									
									
									
								
							@ -27,6 +27,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "cw.h"
 | 
					#include "cw.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "format.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "capwap80211.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Format bytes as hex string.
 | 
					 * Format bytes as hex string.
 | 
				
			||||||
 * @param dst Destination buffer
 | 
					 * @param dst Destination buffer
 | 
				
			||||||
@ -87,4 +91,145 @@ int format_hdr_flags(char *dst, uint8_t * th)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char * cw_format_radio_information(char * dst, int ri)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char *d = dst;	
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_A)
 | 
				
			||||||
 | 
							*d++='a';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_B)
 | 
				
			||||||
 | 
							*d++='b';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_G)
 | 
				
			||||||
 | 
							*d++='g';
 | 
				
			||||||
 | 
						if (ri & CW_80211_RADIO_TYPE_N)
 | 
				
			||||||
 | 
							*d++='n';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*d=0;
 | 
				
			||||||
 | 
						return dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int cw_format_pkt_hdr0(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from, int draft7)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						char sock_buf[SOCK_ADDR_BUFSIZE]; 
 | 
				
			||||||
 | 
						int preamble;
 | 
				
			||||||
 | 
						char *s;
 | 
				
			||||||
 | 
						int hlen, rid, wbid;
 | 
				
			||||||
 | 
						int frag_id,frag_offs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s = dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (incomming){
 | 
				
			||||||
 | 
							if (cw_get_hdr_flag_f(packet)) {
 | 
				
			||||||
 | 
								s += sprintf(s, "Fragment from %s",
 | 
				
			||||||
 | 
									     sock_addr2str_p(from,sock_buf));
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								s += sprintf(s, "From %s", sock_addr2str_p(from,sock_buf));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else{
 | 
				
			||||||
 | 
							if (cw_get_hdr_flag_f(packet)) {
 | 
				
			||||||
 | 
								s += sprintf(s, "Fragment to %s", sock_addr2str(from,sock_buf));
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								s += sprintf(s, "To %s", sock_addr2str(from,sock_buf));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						s += sprintf(s, " l=%d: ", len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						preamble = cw_get_hdr_preamble(packet);
 | 
				
			||||||
 | 
						if (preamble == 01) {
 | 
				
			||||||
 | 
							s += sprintf(s, " (encrypted)");
 | 
				
			||||||
 | 
							return s - dst;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (len < 4)
 | 
				
			||||||
 | 
							goto abort;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						hlen = cw_get_hdr_hlen(packet);
 | 
				
			||||||
 | 
						rid = cw_get_hdr_rid(packet);
 | 
				
			||||||
 | 
						wbid = cw_get_hdr_wbid(packet);
 | 
				
			||||||
 | 
						s += sprintf(s, " H:%d R:%02d W:%02d", hlen, rid, wbid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s += sprintf(s, " Flgs:");
 | 
				
			||||||
 | 
						s += format_hdr_flags(s, packet);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (len < 8)
 | 
				
			||||||
 | 
							goto abort;
 | 
				
			||||||
 | 
						frag_id = cw_get_hdr_fragid(packet);
 | 
				
			||||||
 | 
						frag_offs = cw_get_hdr_fragoffset(packet);
 | 
				
			||||||
 | 
						s += sprintf(s, " Frag/Offs:%d/%d", frag_id, frag_offs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (cw_get_hdr_flag_m(packet)) {
 | 
				
			||||||
 | 
							/* rmac is present, print the rmac */
 | 
				
			||||||
 | 
							int rmac_len = cw_get_hdr_rmac_len(packet);
 | 
				
			||||||
 | 
							int plen = rmac_len;
 | 
				
			||||||
 | 
							if (rmac_len + 8 > len)
 | 
				
			||||||
 | 
								plen = len - 8;
 | 
				
			||||||
 | 
							if (rmac_len > 10)
 | 
				
			||||||
 | 
								plen = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							s += sprintf(s, " R-MAC:");
 | 
				
			||||||
 | 
							s += format_mac(s, cw_get_hdr_rmac_data(packet), plen);
 | 
				
			||||||
 | 
							if (rmac_len > 10) {
 | 
				
			||||||
 | 
								s += sprintf(s, " ... (len=%d)", rmac_len);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (cw_get_hdr_flag_w(packet)) {
 | 
				
			||||||
 | 
							if (!draft7){
 | 
				
			||||||
 | 
								/* print wireless specific info */
 | 
				
			||||||
 | 
								int ws_len = cw_get_hdr_ws_len(packet);
 | 
				
			||||||
 | 
								int plen = ws_len > 20 ? 20 : ws_len;
 | 
				
			||||||
 | 
								s += sprintf(s, " WS:");
 | 
				
			||||||
 | 
								s += format_hexu(s, cw_get_hdr_ws_data(packet), plen);
 | 
				
			||||||
 | 
								if (ws_len > 20) {
 | 
				
			||||||
 | 
									s += sprintf(s, " ... (len=%d)", ws_len);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else {
 | 
				
			||||||
 | 
								int ws_len = cw_get_hdr_ws_len_7(packet);
 | 
				
			||||||
 | 
								int plen = ws_len > 20 ? 20 : ws_len;
 | 
				
			||||||
 | 
								s += sprintf(s, " WS:");
 | 
				
			||||||
 | 
								s += format_hexu(s, cw_get_hdr_ws_data_7(packet), plen);
 | 
				
			||||||
 | 
								if (ws_len > 20) {
 | 
				
			||||||
 | 
									s += sprintf(s, " ... (len=%d)", ws_len);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return s - dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      abort:
 | 
				
			||||||
 | 
						s += sprintf(s, " Incomplete...");
 | 
				
			||||||
 | 
						return s - dst;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @brief Format a packet header for debugging purposes
 | 
				
			||||||
 | 
					 * @param dst Destination buffer
 | 
				
			||||||
 | 
					 * @param incomming True if the packet is an incomming packet, otherweise 0
 | 
				
			||||||
 | 
					 * @param packet packet data
 | 
				
			||||||
 | 
					 * @param len length of packet data
 | 
				
			||||||
 | 
					 * @param from Address from where the packet was received
 | 
				
			||||||
 | 
					 * @return Number of bytes written
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_format_pkt_hdr0(dst, incomming, packet, len,
 | 
				
			||||||
 | 
						      from, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cw_format_pkt_hdr_7(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cw_format_pkt_hdr0(dst, incomming, packet, len,
 | 
				
			||||||
 | 
						      from, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -45,7 +45,6 @@ char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
 | 
					int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct avltree;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Format bytes as a hex string. Hexadecimal letters are lower-case.
 | 
					 * Format bytes as a hex string. Hexadecimal letters are lower-case.
 | 
				
			||||||
@ -110,8 +109,16 @@ char *cw_format_dump(const uint8_t * data, int len,
 | 
				
			|||||||
void cw_format_get_dump_defaults(struct cw_FormatDumpSettings * settings);
 | 
					void cw_format_get_dump_defaults(struct cw_FormatDumpSettings * settings);
 | 
				
			||||||
int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
					int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
		      struct sockaddr *from);
 | 
							      struct sockaddr *from);
 | 
				
			||||||
 | 
					int cw_format_pkt_hdr_7(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int cw_format_version(char *s, const uint8_t * version, int len);
 | 
					int cw_format_version(char *s, const uint8_t * version, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char * cw_format_radio_information(char * dst, int ri);
 | 
				
			||||||
 | 
					int cw_format_dot11_hdr(char * dst, uint8_t *packet, int len);
 | 
				
			||||||
 | 
					int cw_format_dot11_elem(char *dst, uint8_t id, const uint8_t *src, int len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**@}*/
 | 
					/**@}*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -54,6 +54,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "capwap.h"
 | 
					#include "capwap.h"
 | 
				
			||||||
 | 
					#include "cw.h"
 | 
				
			||||||
#include "fragman.h"
 | 
					#include "fragman.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -101,20 +102,6 @@ static struct frag * frag_new(struct frag * frags, int fragid)
 | 
				
			|||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
void fragman_free(frag_t * frags,struct frag * f)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int i;
 | 
					 | 
				
			||||||
	for (i=0; i<FRAG_MAXIDS; i++){
 | 
					 | 
				
			||||||
		if (frags[i]->fragid==f->fragid){
 | 
					 | 
				
			||||||
			frags[i]=NULL;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	free(f);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Add a fragment
 | 
					 * Add a fragment
 | 
				
			||||||
 * @pram frags Fragman object
 | 
					 * @pram frags Fragman object
 | 
				
			||||||
@ -129,12 +116,10 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
 | 
				
			|||||||
	uint32_t val0,val1;
 | 
						uint32_t val0,val1;
 | 
				
			||||||
	int fragid,fragoffset;
 | 
						int fragid,fragoffset;
 | 
				
			||||||
	int dst;
 | 
						int dst;
 | 
				
			||||||
	int ti;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* read the transport header dword 0,
 | 
						/* read the transport header dword 0,
 | 
				
			||||||
	 * contains hlen*/	
 | 
						 * contains hlen*/	
 | 
				
			||||||
	val0 = ntohl(*((uint32_t*)packet));
 | 
						val0 = ntohl(*((uint32_t*)packet));
 | 
				
			||||||
/*	int hlen = (val0 >> 19) & 0x1f;*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* read the transport header dword 1,
 | 
						/* read the transport header dword 1,
 | 
				
			||||||
	 * contains fragid and fragoffset */	
 | 
						 * contains fragid and fragoffset */	
 | 
				
			||||||
@ -142,33 +127,30 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
 | 
				
			|||||||
	fragid = val1>>16;
 | 
						fragid = val1>>16;
 | 
				
			||||||
	fragoffset=(val1 >>3) & 0x1fff;
 | 
						fragoffset=(val1 >>3) & 0x1fff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*//	printf("Fragid = %i, offset = %i\n",fragid,fragoffset);*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/* determine size of payload */
 | 
					 | 
				
			||||||
/*	int payloadlen = len - hlen*4;
 | 
					 | 
				
			||||||
	if (payloadlen<0){
 | 
					 | 
				
			||||||
		errno = EINVAL;
 | 
					 | 
				
			||||||
		return NULL;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	/* find / create cfragment */
 | 
						/* find / create cfragment */
 | 
				
			||||||
	f = frag_get(frags,fragid);
 | 
						f = frag_get(frags,fragid);
 | 
				
			||||||
	if (!f){
 | 
						if (!f){
 | 
				
			||||||
		f = frag_new(frags,fragid);
 | 
							f = frag_new(frags,fragid);
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
		if (!f){
 | 
							if (!f){
 | 
				
			||||||
			errno = ENOMEM;
 | 
								errno = ENOMEM;
 | 
				
			||||||
			/* out of fragmentation space */
 | 
								/* out of fragmentation space */
 | 
				
			||||||
			return NULL;
 | 
								return NULL;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	errno = 0;
 | 
						errno = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dst = fragoffset*8;
 | 
						dst = fragoffset*8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* copy fragment*/
 | 
						/* copy fragment*/
 | 
				
			||||||
	if (dst + payloadlen < FRAG_MAXSIZE) {
 | 
						if (dst + payloadlen < FRAG_MAXSIZE) {
 | 
				
			||||||
		memcpy( f->buffer+4+dst,packet+hlen,payloadlen);
 | 
							if (fragoffset==0){
 | 
				
			||||||
 | 
								/* preserve header of 1st fragment */
 | 
				
			||||||
 | 
								memset(f->buffer,0,MAX_PKT_HDR_LEN);
 | 
				
			||||||
 | 
								memcpy(f->buffer,packet,hlen);
 | 
				
			||||||
 | 
								cw_set_hdr_hlen(f->buffer,MAX_PKT_HDR_LEN/4);
 | 
				
			||||||
 | 
								cw_set_hdr_flags(f->buffer, CAPWAP_FLAG_HDR_F, 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							memcpy( f->buffer+MAX_PKT_HDR_LEN+4+dst,packet+hlen,payloadlen);
 | 
				
			||||||
		f->bytesreceived+=payloadlen;
 | 
							f->bytesreceived+=payloadlen;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -177,21 +159,13 @@ uint8_t * fragman_add(frag_t * frags, uint8_t *packet, int hlen, int payloadlen)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (ti=0; ti<16; ti++){
 | 
					 | 
				
			||||||
/*//		printf("%02X ",(f->buffer+4)[ti]);*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (f->bytesneeded>0 && f->bytesneeded<=f->bytesreceived){
 | 
						if (f->bytesneeded>0 && f->bytesneeded<=f->bytesreceived){
 | 
				
			||||||
		uint8_t * r=f->buffer;
 | 
							uint8_t * r=f->buffer;
 | 
				
			||||||
		f->buffer=0;
 | 
							f->buffer=0;
 | 
				
			||||||
/*//		printf("last bytes need %i\n",f->bytesneeded);*/
 | 
							*((uint32_t*)(r+MAX_PKT_HDR_LEN))=f->bytesneeded;
 | 
				
			||||||
		*((uint32_t*)(r))=f->bytesneeded;
 | 
					 | 
				
			||||||
		return r; 
 | 
							return r; 
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*//	printf("Fragman bytes needed: %i, received  %i\n",f->bytesneeded,f->bytesreceived);*/
 | 
					 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -19,9 +19,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *@defgroup Fragman FRAGMAN
 | 
					 *@defgroup Fragman FRAGMAN
 | 
				
			||||||
 *@breif Frgaman functions
 | 
					 *@brief Frgaman functions
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Detailed esription
 | 
					 * Detailed desription
 | 
				
			||||||
 *@{
 | 
					 *@{
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -33,18 +33,18 @@
 | 
				
			|||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef FRAG_MAXSIZE
 | 
					
 | 
				
			||||||
 | 
					#define MAX_PKT_HDR_LEN 64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** maximaum size of a fragment */
 | 
					/** maximaum size of a fragment */
 | 
				
			||||||
	#define FRAG_MAXSIZE 65536+4
 | 
					#define FRAG_MAXSIZE (65536+MAX_PKT_HDR_LEN)
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef FRAG_MAXIDS
 | 
					 | 
				
			||||||
#define FRAG_MAXIDS 10
 | 
					#define FRAG_MAXIDS 10
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef FRAG_TTL
 | 
					/**
 | 
				
			||||||
 | 
					 * TTL of received fragment in seconds
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
#define FRAG_TTL 5 
 | 
					#define FRAG_TTL 5 
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct frag {
 | 
					struct frag {
 | 
				
			||||||
@ -57,7 +57,7 @@ struct frag {
 | 
				
			|||||||
	int bytesreceived;
 | 
						int bytesreceived;
 | 
				
			||||||
	int bytesneeded;
 | 
						int bytesneeded;
 | 
				
			||||||
	struct timespec t;
 | 
						struct timespec t;
 | 
				
			||||||
	uint8_t * header;
 | 
					//	uint8_t * header;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct frag frag_t; /*FRAGMAN;*/
 | 
					typedef struct frag frag_t; /*FRAGMAN;*/
 | 
				
			||||||
 | 
				
			|||||||
@ -137,7 +137,7 @@
 | 
				
			|||||||
#define LW_ELEM_DIRECT_SEQUENCE_CONTROL			14
 | 
					#define LW_ELEM_DIRECT_SEQUENCE_CONTROL			14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define LW_ELEM_CHANGE_STATE_EVENT			26
 | 
					#define LW_ELEM_CHANGE_STATE_EVENT			26
 | 
				
			||||||
#define LW_ELEM_80211_DELETE_WLAN			28
 | 
					#define LWAPP_ELEM_80211_DELETE_WLAN			28
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define LW_ELEM_AC_NAME					31
 | 
					#define LW_ELEM_AC_NAME					31
 | 
				
			||||||
#define LW_ELEM_LOCATION_DATA				35
 | 
					#define LW_ELEM_LOCATION_DATA				35
 | 
				
			||||||
@ -151,7 +151,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define LW_ELEM_CERTIFICATE				44
 | 
					#define LW_ELEM_CERTIFICATE				44
 | 
				
			||||||
#define LW_ELEM_WTP_BOARD_DATA				50
 | 
					#define LW_ELEM_WTP_BOARD_DATA				50
 | 
				
			||||||
#define LW_BCAST_SSID_MODE				51
 | 
					#define LWAPP_ELEM_BCAST_SSID_MODE			51
 | 
				
			||||||
#define LW_ELEM_WTP_MODE_AND_TYPE			54
 | 
					#define LW_ELEM_WTP_MODE_AND_TYPE			54
 | 
				
			||||||
#define LW_ELEM_QOS					57
 | 
					#define LW_ELEM_QOS					57
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -405,7 +405,9 @@ struct cw_MsgData *cw_msgset_get_msgdata(struct cw_MsgSet *set, int type)
 | 
				
			|||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
					cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			||||||
	cw_MsgCallbackFun fun)
 | 
						cw_MsgCallbackFun fun)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -420,5 +422,5 @@ cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			|||||||
	return old_callback;
 | 
						return old_callback;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,6 +72,9 @@ struct cw_MsgSet {
 | 
				
			|||||||
	mavl_t statemachine_states;
 | 
						mavl_t statemachine_states;
 | 
				
			||||||
	int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
 | 
						int (*write_header)(struct cw_ElemHandler * handler, uint8_t * dst, int len);
 | 
				
			||||||
	int (*header_len)(struct cw_ElemHandler *handler);
 | 
						int (*header_len)(struct cw_ElemHandler *handler);
 | 
				
			||||||
 | 
						int (*format_pkt_hdr)(char *dst, int incomming, uint8_t * packet, int len,
 | 
				
			||||||
 | 
							      struct sockaddr *from);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -146,9 +149,8 @@ struct cw_ElemHandler * cw_msgset_get_elemhandler(struct cw_MsgSet * set,
 | 
				
			|||||||
#define CW_MSGSET_POSTPROCESS	1
 | 
					#define CW_MSGSET_POSTPROCESS	1
 | 
				
			||||||
#define CW_MSGSET_PREPROCESS	2
 | 
					#define CW_MSGSET_PREPROCESS	2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					//cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
				
			||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
 | 
					//	cw_MsgCallbackFun fun);
 | 
				
			||||||
	cw_MsgCallbackFun fun);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										135
									
								
								src/cw/send.c
									
									
									
									
									
								
							
							
						
						
									
										135
									
								
								src/cw/send.c
									
									
									
									
									
								
							@ -90,10 +90,143 @@ int conn_send_data_msg(struct cw_Conn * conn, uint8_t *rawmsg,int len)
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#define MAX_MTU 9500
 | 
					#define MAX_MTU 9500
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Initialize a capwap header
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @param buf	Buffer to be initialized
 | 
				
			||||||
 | 
					 * @param wbid  Wireless Binding ID 
 | 
				
			||||||
 | 
					 * @param rid 	Radio ID
 | 
				
			||||||
 | 
					 * @param rmac	Radio MAC, NULL if not present
 | 
				
			||||||
 | 
					 * @param wd	Wireless Data, NULL if not present
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @return Length of the header that was initialized
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int 
 | 
				
			||||||
 | 
					cw_init_capwap_packet( uint8_t * buf, int wbid ,int rid, bstr_t rmac, bstr_t wd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int len,hlen;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* header len */
 | 
				
			||||||
 | 
						len = 8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* zero the first 8 bytes */
 | 
				
			||||||
 | 
						cw_set_dword(buf + 0, 0);
 | 
				
			||||||
 | 
						cw_set_dword(buf + 4, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* capwap version/unencrypted */
 | 
				
			||||||
 | 
						#if CAPWAP_VERSION != 0 
 | 
				
			||||||
 | 
							cw_set_hdr_preamble(buf, CAPWAP_VERSION << 4 | 0);
 | 
				
			||||||
 | 
						#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* set wbid and rid */
 | 
				
			||||||
 | 
						cw_set_hdr_wbid(buf, wbid);
 | 
				
			||||||
 | 
						cw_set_hdr_rid(buf, rid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* add rmac if present */
 | 
				
			||||||
 | 
						if (rmac != NULL){
 | 
				
			||||||
 | 
							int rmac_len = bstr_len(rmac);
 | 
				
			||||||
 | 
							memcpy(cw_get_hdr_rmac(buf), rmac, rmac_len + 1);
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf, CAPWAP_FLAG_HDR_M, 1);
 | 
				
			||||||
 | 
							len+=rmac_len+1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* Add wireless data if present */
 | 
				
			||||||
 | 
						if (wd!=NULL){
 | 
				
			||||||
 | 
							int wd_len = bstr_len(wd);
 | 
				
			||||||
 | 
							memcpy(buf+len, wd, wd_len + 1);
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf, CAPWAP_FLAG_HDR_M, 1);
 | 
				
			||||||
 | 
							len+=wd_len;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						hlen = len / 4;
 | 
				
			||||||
 | 
						if (len % 4 != 0) {
 | 
				
			||||||
 | 
							hlen++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						cw_set_hdr_hlen(buf, hlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return hlen*4;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Send a CAPWAP packet and fragment it if nececerry
 | 
				
			||||||
 | 
					 * @param conn connection where to send packet over
 | 
				
			||||||
 | 
					 * @param buf pointer to a buffer initialized with #cw_init_capwap_packet
 | 
				
			||||||
 | 
					 * @param hlen length of header, which is the value returned by #cw_init_capwap_packet
 | 
				
			||||||
 | 
					 * @param data payload
 | 
				
			||||||
 | 
					 * @param len length of payload 
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int cw_send_capwap_packet(struct cw_Conn * conn, uint8_t * buf, int hlen, uint8_t * data, int len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int fragoffset,mtu;
 | 
				
			||||||
 | 
						int fragid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* get mtu and align it to 8 */
 | 
				
			||||||
 | 
						mtu = conn->mtu;
 | 
				
			||||||
 | 
						mtu &= ~3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* initialize fragid and fragoffset */
 | 
				
			||||||
 | 
						fragoffset = 0;
 | 
				
			||||||
 | 
						if (len + hlen > mtu)
 | 
				
			||||||
 | 
							fragid = conn->fragid++;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							fragid = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* create all fragments */
 | 
				
			||||||
 | 
						while (len + hlen > mtu){
 | 
				
			||||||
 | 
							memcpy(buf+hlen,data+(fragoffset*8),mtu-hlen);
 | 
				
			||||||
 | 
							len -= (mtu - hlen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf,CAPWAP_FLAG_HDR_F,1);
 | 
				
			||||||
 | 
							cw_set_dword(buf+4, fragid<<16 | fragoffset<<3 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cw_dbg_pkt(DBG_PKT_OUT,conn,buf,mtu,(struct sockaddr*)&conn->addr);
 | 
				
			||||||
 | 
							if (conn->write(conn,buf,mtu)<0)
 | 
				
			||||||
 | 
								return -1;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
							fragoffset+=(mtu-hlen)/8;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* put rmac and wireless data only into the 1st fragment */
 | 
				
			||||||
 | 
							if (hlen!=8){
 | 
				
			||||||
 | 
								cw_set_hdr_flags(buf,CAPWAP_FLAG_HDR_M,0);
 | 
				
			||||||
 | 
								cw_set_hdr_flags(buf,CAPWAP_FLAG_HDR_W,0);
 | 
				
			||||||
 | 
								hlen = 8;
 | 
				
			||||||
 | 
								cw_set_hdr_hlen(buf,hlen/4);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (fragoffset)
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf,CAPWAP_FLAG_HDR_F | CAPWAP_FLAG_HDR_L,1);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							cw_set_hdr_flags(buf,CAPWAP_FLAG_HDR_F,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						memcpy(buf+hlen,data+(fragoffset*8),len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_set_dword(buf+4, fragid<<16 | fragoffset<<3 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg_pkt(DBG_PKT_OUT,conn,buf,len+hlen,(struct sockaddr*)&conn->addr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return conn->write(conn,buf,len + hlen);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int 
 | 
					int 
 | 
				
			||||||
cw_send_msg( struct cw_Conn * conn, uint8_t *msg)
 | 
					cw_send_msg( struct cw_Conn * conn, uint8_t *msg)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						uint8_t buf[MAX_MTU];
 | 
				
			||||||
 | 
						int hlen,msglen;
 | 
				
			||||||
 | 
						hlen = cw_init_capwap_packet(buf,1,0,NULL,NULL);
 | 
				
			||||||
 | 
						msglen = cw_get_msg_elems_len(msg) + 8;
 | 
				
			||||||
 | 
						return cw_send_capwap_packet(conn,buf,hlen,msg,msglen);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int 
 | 
				
			||||||
 | 
					cw_send_msg_old( struct cw_Conn * conn, uint8_t *msg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	uint8_t buf[MAX_MTU];
 | 
						uint8_t buf[MAX_MTU];
 | 
				
			||||||
	int fragoffset,hlen,mtu;
 | 
						int fragoffset,hlen,mtu;
 | 
				
			||||||
 | 
				
			|||||||
@ -52,6 +52,7 @@ typedef struct cw_Val cw_Val_t;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @class cw_Type
 | 
					 * @class cw_Type
 | 
				
			||||||
 * @author 7u83
 | 
					 * @author 7u83
 | 
				
			||||||
@ -117,7 +118,10 @@ struct cw_ValStruct {
 | 
				
			|||||||
typedef struct cw_ValStruct cw_ValStruct_t;
 | 
					typedef struct cw_ValStruct cw_ValStruct_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cw_ValBit {
 | 
				
			||||||
 | 
						uint16_t bit;
 | 
				
			||||||
 | 
						const char *key;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -147,6 +151,7 @@ struct cw_ValIndexed{
 | 
				
			|||||||
typedef struct cw_ValIndexed cw_ValIndexed_t;
 | 
					typedef struct cw_ValIndexed cw_ValIndexed_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const struct cw_Type cw_type_bits;
 | 
				
			||||||
extern const struct cw_Type cw_type_byte;
 | 
					extern const struct cw_Type cw_type_byte;
 | 
				
			||||||
extern const struct cw_Type cw_type_word;
 | 
					extern const struct cw_Type cw_type_word;
 | 
				
			||||||
extern const struct cw_Type cw_type_dword;
 | 
					extern const struct cw_Type cw_type_dword;
 | 
				
			||||||
@ -159,6 +164,7 @@ extern const struct cw_Type cw_type_bool;
 | 
				
			|||||||
extern const struct cw_Type cw_type_struct;
 | 
					extern const struct cw_Type cw_type_struct;
 | 
				
			||||||
extern const struct cw_Type cw_type_array;
 | 
					extern const struct cw_Type cw_type_array;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CW_TYPE_BITS (&cw_type_bits)
 | 
				
			||||||
#define CW_TYPE_BYTE (&cw_type_byte)
 | 
					#define CW_TYPE_BYTE (&cw_type_byte)
 | 
				
			||||||
#define CW_TYPE_WORD (&cw_type_word)
 | 
					#define CW_TYPE_WORD (&cw_type_word)
 | 
				
			||||||
#define CW_TYPE_DWORD (&cw_type_dword)
 | 
					#define CW_TYPE_DWORD (&cw_type_dword)
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ include ../../Defs.mak
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES=\
 | 
					SOURCES=\
 | 
				
			||||||
	mod_capwap_ac.c \
 | 
						mod_capwap.c \
 | 
				
			||||||
	capwap_actions.c \
 | 
						capwap_actions.c \
 | 
				
			||||||
	capwap_in_wtp_board_data.c \
 | 
						capwap_in_wtp_board_data.c \
 | 
				
			||||||
	capwap_in_ac_descriptor.c \
 | 
						capwap_in_ac_descriptor.c \
 | 
				
			||||||
 | 
				
			|||||||
@ -24,10 +24,10 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "cw/msgset.h"
 | 
					#include "cw/msgset.h"
 | 
				
			||||||
#include "cw/keys.h"
 | 
					#include "cw/keys.h"
 | 
				
			||||||
 | 
					#include "cw/format.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "mod_capwap.h"
 | 
					#include "mod_capwap.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/mavltypes.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
					static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -86,7 +86,26 @@ static cw_ValValRange_t mac_types[]={
 | 
				
			|||||||
	{0,0,NULL}
 | 
						{0,0,NULL}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					struct cw_ValBit xx[] = {
 | 
				
			||||||
 | 
					                {0,"ess"},
 | 
				
			||||||
 | 
					                {1,"ibss"},
 | 
				
			||||||
 | 
					                {2,"cf-pollable"},
 | 
				
			||||||
 | 
					                {3,"cf-poll-request"},
 | 
				
			||||||
 | 
					                {4,"privacy"},
 | 
				
			||||||
 | 
					                {5,"short-preamble"},
 | 
				
			||||||
 | 
					                {2,"pbcc"},
 | 
				
			||||||
 | 
					                {3,"cf-poll-request"},
 | 
				
			||||||
 | 
					                {2,NULL}        
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					struct cw_ValBit frame_tunnel_bits[] = {
 | 
				
			||||||
 | 
						{3,"native"},
 | 
				
			||||||
 | 
						{2,"802-3"},
 | 
				
			||||||
 | 
						{1,"local-bridging"},
 | 
				
			||||||
 | 
						{0,"reserved"},
 | 
				
			||||||
 | 
						{1, NULL}        
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cw_ValStruct_t radio_admin_state[] = {
 | 
					static cw_ValStruct_t radio_admin_state[] = {
 | 
				
			||||||
@ -152,10 +171,13 @@ static struct cw_ElemHandler handlers[] = {
 | 
				
			|||||||
		CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE,	/* Element ID */
 | 
							CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE,	/* Element ID */
 | 
				
			||||||
		0,0,					/* Vendor / Proto */
 | 
							0,0,					/* Vendor / Proto */
 | 
				
			||||||
		1,1,					/* min/max length */
 | 
							1,1,					/* min/max length */
 | 
				
			||||||
		CW_TYPE_BYTE,				/* type */
 | 
							CW_TYPE_BITS,				/* type */
 | 
				
			||||||
		"capwap/wtp-frame-tunnel-mode",		/* Key */
 | 
							"capwap/wtp-frame-tunnel-mode",		/* Key */
 | 
				
			||||||
		cw_in_generic,				/* get */
 | 
							cw_in_generic,				/* get */
 | 
				
			||||||
		cw_out_generic				/* put */
 | 
							cw_out_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							frame_tunnel_bits
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	,
 | 
						,
 | 
				
			||||||
	{ 
 | 
						{ 
 | 
				
			||||||
@ -920,6 +942,7 @@ struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	set->write_header = write_header;
 | 
						set->write_header = write_header;
 | 
				
			||||||
	set->header_len = header_len;
 | 
						set->header_len = header_len;
 | 
				
			||||||
 | 
						set->format_pkt_hdr = cw_format_pkt_hdr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_dbg(DBG_INFO,"CAPWAP: Done register messages");
 | 
						cw_dbg(DBG_INFO,"CAPWAP: Done register messages");
 | 
				
			||||||
	return set;
 | 
						return set;
 | 
				
			||||||
 | 
				
			|||||||
@ -37,11 +37,13 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
 | 
				
			||||||
	val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
						val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
				
			||||||
	d+=cw_put_byte(d,val);
 | 
						if (val<0){
 | 
				
			||||||
	if (val<=0){
 | 
					 | 
				
			||||||
		cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", CW_SKEY_MAX_RADIOS);
 | 
							cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", CW_SKEY_MAX_RADIOS);
 | 
				
			||||||
		d+=cw_put_byte(d,0);
 | 
							d+=cw_put_byte(d,0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						else{
 | 
				
			||||||
 | 
							d+=cw_put_byte(d,val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
 | 
				
			||||||
	val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
						val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
 | 
				
			||||||
@ -52,8 +54,6 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
 | 
				
			|||||||
	d+=cw_put_encryption_subelems(d,0);
 | 
						d+=cw_put_encryption_subelems(d,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*cw_ktv_dump(params->conn->local_cfg,DBG_INFO,"*** ktv dump ***","","*** end of dump ***");*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* hardware version sub element */
 | 
						/* hardware version sub element */
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
 | 
						sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
 | 
				
			||||||
	d+=cw_write_descriptor_subelem (d, params->cfg_list,
 | 
						d+=cw_write_descriptor_subelem (d, params->cfg_list,
 | 
				
			||||||
 | 
				
			|||||||
@ -43,6 +43,21 @@ static cw_ValStruct_t capwap80211_wtp_radio_cfg_stru[]={
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct cw_ElemHandler handlers[] = {
 | 
					static struct cw_ElemHandler handlers[] = {
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							"IEEE 802.11 Add WLAN",				/* name */
 | 
				
			||||||
 | 
							CAPWAP80211_ELEM_ADD_WLAN,			/* Element ID */
 | 
				
			||||||
 | 
							0, 0,						/* Vendor / Proto */
 | 
				
			||||||
 | 
							3, 0,						/* min/max length */
 | 
				
			||||||
 | 
							CW_TYPE_STRUCT,					/* type */
 | 
				
			||||||
 | 
							"capwap80211",					/* Key */
 | 
				
			||||||
 | 
							cw_in_radio_generic,				/* get */
 | 
				
			||||||
 | 
							cw_out_radio_generic,				/* put */
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							NULL,
 | 
				
			||||||
 | 
							capwap80211_antenna_stru
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						,
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		"IEEE 802.11 WTP Radio Information",		/* name */
 | 
							"IEEE 802.11 WTP Radio Information",		/* name */
 | 
				
			||||||
		CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,		/* Element ID */
 | 
							CAPWAP80211_ELEM_WTP_RADIO_INFORMATION,		/* Element ID */
 | 
				
			||||||
 | 
				
			|||||||
@ -3,8 +3,7 @@ include ../../Defs.mak
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES=\
 | 
					SOURCES=\
 | 
				
			||||||
	mod_cisco_ac.c \
 | 
						mod_cisco.c \
 | 
				
			||||||
	cisco_actions.c \
 | 
					 | 
				
			||||||
	cisco_in_wtp_descriptor.c \
 | 
						cisco_in_wtp_descriptor.c \
 | 
				
			||||||
	cisco_out_wtp_descriptor.c \
 | 
						cisco_out_wtp_descriptor.c \
 | 
				
			||||||
	cisco_in_ac_descriptor.c\
 | 
						cisco_in_ac_descriptor.c\
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@
 | 
				
			|||||||
#define CISCO_ELEM_RAD_NAME			LWAPP_ELEM_WTP_NAME			/* 5 */
 | 
					#define CISCO_ELEM_RAD_NAME			LWAPP_ELEM_WTP_NAME			/* 5 */
 | 
				
			||||||
#define	CW_CISCO_MWAR				LW_ELEM_AC_DESCRIPTOR			/* 6 */
 | 
					#define	CW_CISCO_MWAR				LW_ELEM_AC_DESCRIPTOR			/* 6 */
 | 
				
			||||||
#define CISCO_ELEM_ADD_WLAN			LW_ELEM_80211_ADD_WLAN			/* 7 */
 | 
					#define CISCO_ELEM_ADD_WLAN			LW_ELEM_80211_ADD_WLAN			/* 7 */
 | 
				
			||||||
#define CISCO_ELEM_WTP_RADIO_CONFIGURATION	8					/* 9 */
 | 
					#define CISCO_ELEM_WTP_RADIO_CONFIGURATION	8					/* 8 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_9				9					/* 9 */
 | 
					#define CISCO_ELEM_9				9					/* 9 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -56,8 +56,8 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_RRM_LOAD			25					/* 25 */
 | 
					#define CISCO_ELEM_RRM_LOAD			25					/* 25 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define CISCO_ELEM_DELETE_WLAN			LWAPP_ELEM_80211_DELETE_WLAN		/* 28 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_80211_DELETE_WLAN		LW_ELEM_80211_DELETE_WLAN		/* 28 */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_MWAR_NAME			LW_ELEM_AC_NAME				/* 31 */
 | 
					#define CW_CISCO_MWAR_NAME			LW_ELEM_AC_NAME				/* 31 */
 | 
				
			||||||
#define CISCO_ELEM_33				33
 | 
					#define CISCO_ELEM_33				33
 | 
				
			||||||
@ -76,13 +76,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_WTP_BOARD_DATA		LW_ELEM_WTP_BOARD_DATA			/* 50 */
 | 
					#define CISCO_ELEM_WTP_BOARD_DATA		LW_ELEM_WTP_BOARD_DATA			/* 50 */
 | 
				
			||||||
#define CW_CISCO_BCAST_SSID_MODE		LW_BCAST_SSID_MODE
 | 
					#define CISCO_ELEM_BCAST_SSID_MODE		LWAPP_ELEM_BCAST_SSID_MODE		/* 51 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_AP_MODE_AND_TYPE		LW_ELEM_80211_WTP_MODE_AND_TYPE		/* 54 */
 | 
					#define CISCO_ELEM_AP_MODE_AND_TYPE		LW_ELEM_80211_WTP_MODE_AND_TYPE		/* 54 */
 | 
				
			||||||
#define CISCO_ELEM_AP_QOS			LW_ELEM_QOS				/* 57 */
 | 
					#define CISCO_ELEM_AP_QOS			LW_ELEM_QOS				/* 57 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CW_CISCO_AC_IPV4_LIST			LW_ELEM_AC_IPV4_LIST			/* 59 */
 | 
					#define CW_CISCO_AC_IPV4_LIST			LW_ELEM_AC_IPV4_LIST			/* 59 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_CAPWAP_TIMERS		LW_ELEM_LWAPP_TIMERS			/* 68 */
 | 
					#define CISCO_ELEM_CAPWAP_TIMERS		LW_ELEM_LWAPP_TIMERS			/* 68 */
 | 
				
			||||||
 | 
					#define CISCO_ELEM_CLIENT_AUTO_HANDOFF		72					/* 72 */
 | 
				
			||||||
#define CISCO_ELEM_81				81					/* 81 */
 | 
					#define CISCO_ELEM_81				81					/* 81 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_AP_STATIC_IP_ADDR		83
 | 
					#define CISCO_ELEM_AP_STATIC_IP_ADDR		83
 | 
				
			||||||
@ -104,7 +106,7 @@
 | 
				
			|||||||
#define CISCO_ELEM_RESET_BUTTON_STATE		128
 | 
					#define CISCO_ELEM_RESET_BUTTON_STATE		128
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_132				132					/* 132 */
 | 
					#define CISCO_ELEM_AP_DOT11H			132					/* 132 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_ELEM_CHANNEL_POWER		134
 | 
					#define CISCO_ELEM_CHANNEL_POWER		134
 | 
				
			||||||
#define CISCO_ELEM_AP_CORE_DUMP			135
 | 
					#define CISCO_ELEM_AP_CORE_DUMP			135
 | 
				
			||||||
 | 
				
			|||||||
@ -16,10 +16,17 @@ int cisco_out_lw_path_mtu(struct cw_ElemHandler * eh,
 | 
				
			|||||||
	int len,max;
 | 
						int len,max;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int hl = params->msgset->header_len(eh);
 | 
						int hl = params->msgset->header_len(eh);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/* get the current length of message */
 | 
				
			||||||
	int cl = dst-params->rawmsg;
 | 
						int cl = dst-params->rawmsg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int wl = 1400-cl-hl;
 | 
						int wl = 1400-cl-hl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("HL:%d CL:%d WL: %d\n",hl,cl,wl);
 | 
					//printf("HL:%d CL:%d WL: %d\n",hl,cl,wl);
 | 
				
			||||||
 | 
						if (wl<=40)
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sprintf(key,"%s/%s",eh->key,"len");
 | 
						sprintf(key,"%s/%s",eh->key,"len");
 | 
				
			||||||
	len = cw_cfg_get_word_l(params->cfg_list,key,0);
 | 
						len = cw_cfg_get_word_l(params->cfg_list,key,0);
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,7 @@ cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
					int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
 | 
				
			||||||
			, uint8_t * dst)
 | 
								, uint8_t * dst)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -39,6 +39,6 @@ int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
 | 
				
			|||||||
	return cw_out_radio_generic(handler,params,dst);	
 | 
						return cw_out_radio_generic(handler,params,dst);	
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@
 | 
				
			|||||||
#define CISCO_LWELEM_9				9
 | 
					#define CISCO_LWELEM_9				9
 | 
				
			||||||
#define CISCO_LWELEM_AP_MFP_CAP_SUBTYPE		11
 | 
					#define CISCO_LWELEM_AP_MFP_CAP_SUBTYPE		11
 | 
				
			||||||
#define CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE	14
 | 
					#define CISCO_LWELEM_AP_MFP_CONFIG_SUBTYPE	14
 | 
				
			||||||
 | 
					#define CISCO_LWELEM_15				15
 | 
				
			||||||
#define CISCO_LWELEM_AP_USERNAME_PASSWORD	18
 | 
					#define CISCO_LWELEM_AP_USERNAME_PASSWORD	18
 | 
				
			||||||
#define LW_CISCO_MANAGER_IP_ADDR		19
 | 
					#define LW_CISCO_MANAGER_IP_ADDR		19
 | 
				
			||||||
#define CISCO_LWELEM_DISCOVERY_PROTOCOL		20
 | 
					#define CISCO_LWELEM_DISCOVERY_PROTOCOL		20
 | 
				
			||||||
@ -43,6 +44,7 @@
 | 
				
			|||||||
#define CISCO_LWELEM_33				33
 | 
					#define CISCO_LWELEM_33				33
 | 
				
			||||||
#define CISCO_LWELEM_AP_ETHERNET_PORT_SUBTYPE	34
 | 
					#define CISCO_LWELEM_AP_ETHERNET_PORT_SUBTYPE	34
 | 
				
			||||||
#define CISCO_LWELEM_AP_LOGHOST_CONFIG		36
 | 
					#define CISCO_LWELEM_AP_LOGHOST_CONFIG		36
 | 
				
			||||||
 | 
					#define CISCO_LWELEM_37				37
 | 
				
			||||||
#define CISCO_LWELEM_MCAST_MGID_INFO		39
 | 
					#define CISCO_LWELEM_MCAST_MGID_INFO		39
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define CISCO_LWELEM_AP_TELNET_SSH		44
 | 
					#define CISCO_LWELEM_AP_TELNET_SSH		44
 | 
				
			||||||
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -1,271 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include "cw/cw.h"
 | 
					 | 
				
			||||||
#include "cw/mod.h"
 | 
					 | 
				
			||||||
#include "cw/log.h"
 | 
					 | 
				
			||||||
#include "cw/dbg.h"
 | 
					 | 
				
			||||||
#include "cw/dtls.h"
 | 
					 | 
				
			||||||
#include "cw/cfg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*#include "mod_cisco.h"*/
 | 
					 | 
				
			||||||
/*#include "../modload.h"*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/vendors.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "mod_cisco.h"
 | 
					 | 
				
			||||||
#include "capwap_cisco.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
 | 
					 | 
				
			||||||
extern int cisco_register_actions_ac(struct cw_actiondef *def);
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*mbag_t cisco_config = NULL;*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct cw_Mod * capwap_mod = NULL;
 | 
					 | 
				
			||||||
static struct cw_Mod * capwap80211_mod = NULL; 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (handler->proto == 0){
 | 
					 | 
				
			||||||
		if (handler->vendor)
 | 
					 | 
				
			||||||
			return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		return  len + cw_put_elem_hdr(dst, handler->id, len);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/* put the lwap elem header */
 | 
					 | 
				
			||||||
	lw_set_dword(dst + 10, handler->vendor);
 | 
					 | 
				
			||||||
	lw_set_word(dst + 14, handler->id);
 | 
					 | 
				
			||||||
	return len + 6 + cw_put_elem_vendor_hdr(dst, handler->vendor, 
 | 
					 | 
				
			||||||
		CISCO_ELEM_SPAM_VENDOR_SPECIFIC, len+6);	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int header_len(struct cw_ElemHandler * handler)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (handler->proto==0) 
 | 
					 | 
				
			||||||
		return handler->vendor ? 10 : 4;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return 16;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"CISCO: Register messages");
 | 
					 | 
				
			||||||
	switch (mode) {
 | 
					 | 
				
			||||||
		case CW_MOD_MODE_CAPWAP:
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			capwap_mod->register_messages(set, CW_MOD_MODE_CAPWAP);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			capwap80211_mod->register_messages(set, CW_MOD_MODE_BINDINGS);
 | 
					 | 
				
			||||||
			cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			set->write_header = write_header;
 | 
					 | 
				
			||||||
		      	set->header_len = header_len;	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/*	cw_dbg(DBG_MOD,"Cisco: loading cisco message set");*/
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
/*			cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		case CW_MOD_MODE_BINDINGS:
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"CISCO: Done register messages");
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
static void errfunc(cfg_t *cfg, const char *fmt, va_list ap){
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (cfg && cfg->filename && cfg->line)
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "MOD Cisco cfg file in %s:%d: ", 
 | 
					 | 
				
			||||||
			cfg->filename, cfg->line);
 | 
					 | 
				
			||||||
	else if (cfg && cfg->filename)
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "MOD Cisco cfg file in %s:", cfg->filename);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int init(struct cw_Mod *mod, cw_Cfg_t * global_cfg, int role)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
/*	uint8_t * str;*/
 | 
					 | 
				
			||||||
//	static char * hardware_version; /*strdup(".x01000001");* /
 | 
					 | 
				
			||||||
//	static char * software_version; /* = NULL; * /
 | 
					 | 
				
			||||||
/*	cfg_t *cfg;*/
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	int rc = 1;
 | 
					 | 
				
			||||||
/*	cfg_opt_t opts[] = {
 | 
					 | 
				
			||||||
		CFG_SIMPLE_STR("hardware_version", &hardware_version),
 | 
					 | 
				
			||||||
		CFG_SIMPLE_STR("software_version",&software_version),
 | 
					 | 
				
			||||||
		CFG_END()
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO, "CISCO: Initialiazing mod_cisco ...");
 | 
					 | 
				
			||||||
	cw_dbg(DBG_MOD, "CISCO: Loading base module: capwap");
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	capwap_mod = cw_mod_load("capwap",global_cfg,role);
 | 
					 | 
				
			||||||
	if (capwap_mod == NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_MOD, "CISCO: Loading base module: capwap80211");
 | 
					 | 
				
			||||||
	capwap80211_mod = cw_mod_load("capwap80211", global_cfg,role);
 | 
					 | 
				
			||||||
	if (capwap_mod == NULL){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap80211");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	cw_dbg(DBG_MOD, "CISCO: All base modules are sucessfully loaded.");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*cisco_config = mbag_create();*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	cfg = cfg_init(opts, CFGF_NONE);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	cfg_set_error_function(cfg, errfunc);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	char *filename = "cisco.conf";
 | 
					 | 
				
			||||||
	FILE * f = fopen(filename,"r");
 | 
					 | 
				
			||||||
	if (f){
 | 
					 | 
				
			||||||
		fclose(f);
 | 
					 | 
				
			||||||
		if (cfg_parse(cfg, filename)){
 | 
					 | 
				
			||||||
			rc = 0;
 | 
					 | 
				
			||||||
			goto errX;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	
 | 
					 | 
				
			||||||
	str = bstr_create_from_cfgstr(hardware_version);
 | 
					 | 
				
			||||||
	mbag_set_bstrv(cisco_config, CW_ITEM_AC_HARDWARE_VERSION, 
 | 
					 | 
				
			||||||
		CW_VENDOR_ID_CISCO, 
 | 
					 | 
				
			||||||
		bstr_data(str),bstr_len(str)
 | 
					 | 
				
			||||||
		);
 | 
					 | 
				
			||||||
	free(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (software_version){
 | 
					 | 
				
			||||||
		str = bstr_create_from_cfgstr(software_version);
 | 
					 | 
				
			||||||
		mbag_set_bstrv(cisco_config, CW_ITEM_AC_SOFTWARE_VERSION, 
 | 
					 | 
				
			||||||
			CW_VENDOR_ID_CISCO, 
 | 
					 | 
				
			||||||
			bstr_data(str),bstr_len(str)
 | 
					 | 
				
			||||||
			);
 | 
					 | 
				
			||||||
		free(str);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
/*errX:*/
 | 
					 | 
				
			||||||
/*	if (hardware_version)
 | 
					 | 
				
			||||||
		free (hardware_version);
 | 
					 | 
				
			||||||
	if (software_version)
 | 
					 | 
				
			||||||
		free(software_version);*/
 | 
					 | 
				
			||||||
	return rc;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
 | 
					 | 
				
			||||||
		  struct sockaddr *from, int mode)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int offset = cw_get_hdr_msg_offset(rawmsg);
 | 
					 | 
				
			||||||
	const uint8_t *msg_ptr = rawmsg + offset;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
 | 
					 | 
				
			||||||
	const uint8_t *elem;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* To detect a Cisco AP we look for any vendor 
 | 
					 | 
				
			||||||
	 * specific payload Cisco identifier */
 | 
					 | 
				
			||||||
	cw_foreach_elem(elem, elems_ptr, elems_len) {
 | 
					 | 
				
			||||||
		int id = cw_get_elem_id(elem);
 | 
					 | 
				
			||||||
		if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
 | 
					 | 
				
			||||||
			uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
 | 
					 | 
				
			||||||
			if (vendor_id == CW_VENDOR_ID_CISCO) {
 | 
					 | 
				
			||||||
/*				//              conn->actions = &actions;*/
 | 
					 | 
				
			||||||
				if (mode == CW_MOD_MODE_CAPWAP) {
 | 
					 | 
				
			||||||
					cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				return 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (mode == CW_MOD_MODE_CAPWAP) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_MOD, "CISCO capwap detected: no");
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_MOD, "CISCO bindings detected: no");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
static struct cw_Mod capwap_ac = {
 | 
					 | 
				
			||||||
	.name = "cisco",
 | 
					 | 
				
			||||||
	.init = init,
 | 
					 | 
				
			||||||
	.detect = detect,
 | 
					 | 
				
			||||||
//	.register_actions = register_actions,
 | 
					 | 
				
			||||||
	.register_messages = register_messages
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int static setup_cfg(struct cw_Conn  * conn)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int security;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//	conn->write_header=write_header;
 | 
					 | 
				
			||||||
//	conn->header_len=header_len;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	security = cw_setup_dtls(conn,conn->global_cfg,"cisco",CAPWAP_CIPHER);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (conn->role == CW_ROLE_AC){
 | 
					 | 
				
			||||||
		cw_cfg_set_int(conn->local_cfg,"capwap/ac-descriptor/security",security);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
//		if (conn->default_cfg==NULL){
 | 
					 | 
				
			||||||
//			conn->default_cfg=cw_cfg_create();
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct cw_Mod mod_cisco = {
 | 
					 | 
				
			||||||
	"cisco",			/* name */
 | 
					 | 
				
			||||||
	init,				/* init */
 | 
					 | 
				
			||||||
	detect,				/* detect */
 | 
					 | 
				
			||||||
	register_messages,		/* register_messages */
 | 
					 | 
				
			||||||
	NULL,				/* dll_handle */
 | 
					 | 
				
			||||||
	NULL,				/* data */
 | 
					 | 
				
			||||||
	setup_cfg			/* setup_cfg */
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
struct cw_Mod *mod_cisco()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return &cisco_data;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
@ -1,235 +0,0 @@
 | 
				
			|||||||
#
 | 
					 | 
				
			||||||
# 1142 startup
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
capwap/location-data: default location
 | 
					 | 
				
			||||||
capwap/maximum-message-length: 14000
 | 
					 | 
				
			||||||
capwap/session-id: .x45e59826
 | 
					 | 
				
			||||||
capwap/wtp-board-data/board-id: .x0000
 | 
					 | 
				
			||||||
capwap/wtp-board-data/mac-address: .xc47d4f3af8a6
 | 
					 | 
				
			||||||
capwap/wtp-board-data/model-no: "AIR-LAP1142N-E-K9   "
 | 
					 | 
				
			||||||
capwap/wtp-board-data/revision: A0
 | 
					 | 
				
			||||||
capwap/wtp-board-data/serial-no: FCZ1406W232
 | 
					 | 
				
			||||||
capwap/wtp-board-data/vendor: 4232704
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/bootloader/vendor: 4232704
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/bootloader/version: .x0c041200
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/hardware/vendor: 4232704
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/hardware/version: .x01000000
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/max-radios: 2
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/radios-in-use: 2
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/software/vendor: 4232704
 | 
					 | 
				
			||||||
capwap/wtp-descriptor/software/version: .x07007400
 | 
					 | 
				
			||||||
capwap/wtp-frame-tunnel-mode: 4
 | 
					 | 
				
			||||||
capwap/wtp-mac-type: 1 - Split MAC
 | 
					 | 
				
			||||||
capwap/wtp-name: APc47d.4f3a.f8a6
 | 
					 | 
				
			||||||
cisco/ap-group-name: default-group
 | 
					 | 
				
			||||||
cisco/lw-path-mtu/len: 1095
 | 
					 | 
				
			||||||
cisco/lw-path-mtu/max: 1485
 | 
					 | 
				
			||||||
cisco/mwar-addr/address: 192.168.0.161
 | 
					 | 
				
			||||||
cisco/mwar-addr/mwar-type: 0
 | 
					 | 
				
			||||||
cisco/mwar-addr/unknown: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/ant-type: 1
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/ap-type: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/failover-priority: 1
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/flex-connect: 0
 | 
					 | 
				
			||||||
radio.0/capwap80211/wtp-radio-information: 1
 | 
					 | 
				
			||||||
radio.1/capwap80211/wtp-radio-information: 2
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
capwap/ac-name: 
 | 
					 | 
				
			||||||
capwap/statistics-timer: 180
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/ac-initiated-count: 1
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/hw-failure-count: 0
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/last-failure-type: 1
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/link-failure-count: 0
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/other-failure-count: 17
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/reboot-count: 0
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/sw-failure-count: 0
 | 
					 | 
				
			||||||
capwap/wtp-reboot-statistics/unknown-failure-count: 0
 | 
					 | 
				
			||||||
cisco/ap-backup-software-version: .x00000000
 | 
					 | 
				
			||||||
cisco/ap-dtls-data-cfg/cabable: true
 | 
					 | 
				
			||||||
cisco/ap-dtls-data-cfg/enabled: false
 | 
					 | 
				
			||||||
cisco/ap-ethernet-port-type: .x000000
 | 
					 | 
				
			||||||
cisco/ap-led-state-config/led-state: 1
 | 
					 | 
				
			||||||
cisco/ap-log-facility: 0
 | 
					 | 
				
			||||||
cisco/ap-min-ios-version: .x08036f00
 | 
					 | 
				
			||||||
cisco/ap-mode-and-type/mode: 0
 | 
					 | 
				
			||||||
cisco/ap-mode-and-type/type: 15
 | 
					 | 
				
			||||||
cisco/ap-model/image: 12.4(23c)JA2
 | 
					 | 
				
			||||||
cisco/ap-model/model: "AIR-LAP1142N-E-K9   "
 | 
					 | 
				
			||||||
cisco/ap-power-injector-config/selection: 0
 | 
					 | 
				
			||||||
cisco/ap-power-injector-config/state: 17
 | 
					 | 
				
			||||||
cisco/ap-power-injector-config/switch-mac-address: .x000000000000
 | 
					 | 
				
			||||||
cisco/ap-pre-std-switch-config: 0
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.0/code0: 0
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.0/code1: 1
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.0/set: true
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.0/slot: 0
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.1/code0: 0
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.1/code1: 1
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.1/set: true
 | 
					 | 
				
			||||||
cisco/ap-regulatory-domain.1/slot: 1
 | 
					 | 
				
			||||||
cisco/ap-static-ip-addr/address: 192.168.0.13
 | 
					 | 
				
			||||||
cisco/ap-static-ip-addr/enabled: false
 | 
					 | 
				
			||||||
cisco/ap-static-ip-addr/gateway: 192.168.0.1
 | 
					 | 
				
			||||||
cisco/ap-static-ip-addr/netmask: 255.255.255.0
 | 
					 | 
				
			||||||
cisco/ap-static-ip-addr/unknown: 0.0.0.0
 | 
					 | 
				
			||||||
cisco/ap-sub-mode: 0
 | 
					 | 
				
			||||||
cisco/ap-telnet-ssh/ssh: false
 | 
					 | 
				
			||||||
cisco/ap-telnet-ssh/telnet: false
 | 
					 | 
				
			||||||
cisco/ap-uptime/current-uptime: 291
 | 
					 | 
				
			||||||
cisco/ap-uptime/last-uptime: 1
 | 
					 | 
				
			||||||
cisco/ap-username-and-password/login-credentials/enable-password: $1$AmeO$sVDsj.7u2p72.6OD7ZxEo.
 | 
					 | 
				
			||||||
cisco/ap-username-and-password/login-credentials/option: 1
 | 
					 | 
				
			||||||
cisco/ap-username-and-password/login-credentials/password: $1$5oz2$kFPn2Dsy576Q50Z3XwVVx.
 | 
					 | 
				
			||||||
cisco/ap-username-and-password/login-credentials/username: Cisco
 | 
					 | 
				
			||||||
cisco/cisco-discovery-protocol/data: 513
 | 
					 | 
				
			||||||
cisco/cisco-discovery-protocol/enabled: false
 | 
					 | 
				
			||||||
cisco/loghost-config/last-joined-ap: None
 | 
					 | 
				
			||||||
cisco/loghost-config/loghost: 255.255.255.255
 | 
					 | 
				
			||||||
cisco/lwelem105: .x0000
 | 
					 | 
				
			||||||
cisco/lwelem14: .x000100000000000000000000000000000000
 | 
					 | 
				
			||||||
cisco/reset-button-state: true
 | 
					 | 
				
			||||||
cisco/rouge-and-mss/enable: false
 | 
					 | 
				
			||||||
cisco/rouge-and-mss/tcp-adjust-mss: 0
 | 
					 | 
				
			||||||
cisco/rouge-detection/rest: .x0000000a
 | 
					 | 
				
			||||||
cisco/rouge-detection/rouge-detection: true
 | 
					 | 
				
			||||||
cisco/wtp-board-data/card-id: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/card-revision: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/ethernet-mac-address: .xc47d4f3af8a6
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/ant-type: 1
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/ap-type: 1
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/failover-priority: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/options/flex-connect: 1
 | 
					 | 
				
			||||||
cisco/wtp-board-data/wtp-model-hi: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/wtp-model-lo: 0
 | 
					 | 
				
			||||||
cisco/wtp-board-data/wtp-serial-number: FCZ1406W232
 | 
					 | 
				
			||||||
radio.0/capwap/admin-state: 1 - enabled
 | 
					 | 
				
			||||||
radio.0/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.0/capwap80211/tx-power/current-tx-power: 0
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/802-11n-rx-antennas: 0
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/802-11n-tx-antennas: 0
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/antenna-1: 1
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/antenna-2: 1
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/antenna-mode: 3
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/diversity-selection: 255
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/number-of-antennas: 2
 | 
					 | 
				
			||||||
radio.0/cisco/antenna-payload/unknown: 0
 | 
					 | 
				
			||||||
radio.0/cisco/ap-mfp-cap-subtype: 515
 | 
					 | 
				
			||||||
radio.0/cisco/channel-power: .x08080d0108221c16100a04fefe0208221c16100a04fefe0308221c16100a04fefe0408221c16100a04fefe0508221c16100a04fefe0608221c16100a04fefe0708221c16100a04fefe0808221c16100a04fefe0908221c16100a04fefe0a08221c16100a04fefe0b08221c16100a04fefe0c08221c16100a04fefe0d08221c16100a04fefe
 | 
					 | 
				
			||||||
radio.0/cisco/elem16: .x02040b0c
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/fragmentation-threshold: 0
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/long-retry: 0
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/reserved: 1
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/rts-threshold: 2347
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/rx-msdu-lifetime: 1000
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/short-retry: 0
 | 
					 | 
				
			||||||
radio.0/cisco/mac-operation/tx-msdu-lifetime: 5000
 | 
					 | 
				
			||||||
radio.0/cisco/multi-domain-capability/first-channel: 1
 | 
					 | 
				
			||||||
radio.0/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
					 | 
				
			||||||
radio.0/cisco/multi-domain-capability/number-of-channels: 13
 | 
					 | 
				
			||||||
radio.0/cisco/multi-domain-capability/reserved: 1
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-cap/extendend-ht-cap-info: 0
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-cap/ht-cap-info: 0
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-cap/rest: .x000000000000000000000000000000000000000000
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-control/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-control/current-freq: 0
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-control/enable-ht: 0
 | 
					 | 
				
			||||||
radio.0/cisco/phy-ht-control/rest: .x00000000000200001400
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/bytes-per-sec: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/excpection-level: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/foreigh-threshold: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/min-num-clients: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/min-perf-snr: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/num-clients-threshold: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/rf-busy-threshold: 0
 | 
					 | 
				
			||||||
radio.0/cisco/proformance-profile/rssi-threshold: 0
 | 
					 | 
				
			||||||
radio.0/cisco/spam-cfp-status: false
 | 
					 | 
				
			||||||
radio.0/cisco/station-cfg/cfg-type: 3
 | 
					 | 
				
			||||||
radio.0/cisco/station-cfg/current-freq: 3
 | 
					 | 
				
			||||||
radio.0/cisco/station-cfg/rest: .x020202000000000000000000000000000000000000000000313f01
 | 
					 | 
				
			||||||
radio.0/cisco/tx-power-levels: .x070011000e000b000800050002ffff0000
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/beacon-period: 0
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/bss-id: .x04fe7f499b90
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/cfg-period: 0
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/cfg-type: 1
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/cfp-maximum-duration: 0
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/country-str1: 
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/country-str2: 
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/occupancy-limit: 0
 | 
					 | 
				
			||||||
radio.0/cisco/wtp-radio-config/reg: 256
 | 
					 | 
				
			||||||
radio.1/capwap/admin-state: 1 - enabled
 | 
					 | 
				
			||||||
radio.1/capwap80211/tx-power/@cisco/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.1/capwap80211/tx-power/current-tx-power: 0
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/802-11n-rx-antennas: 0
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/802-11n-tx-antennas: 0
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/antenna-1: 1
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/antenna-2: 1
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/antenna-mode: 3
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/diversity-selection: 255
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/number-of-antennas: 2
 | 
					 | 
				
			||||||
radio.1/cisco/antenna-payload/unknown: 0
 | 
					 | 
				
			||||||
radio.1/cisco/ap-mfp-cap-subtype: 66051
 | 
					 | 
				
			||||||
radio.1/cisco/channel-power: .x0808102408221c16100a04fefe2808221c16100a04fefe2c08221c16100a04fefe3008221c16100a04fefe3408221c16100a04fefe3808221c16100a04fefe3c08221c16100a04fefe4008221c16100a04fefe6408221c16100a04fefe6808221c16100a04fefe6c08221c16100a04fefe7008221c16100a04fefe7408221c16100a04fefe8408221c16100a04fefe8808221c16100a04fefe8c08221c16100a04fefe
 | 
					 | 
				
			||||||
radio.1/cisco/elem16: .x0c121824
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/fragmentation-threshold: 0
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/long-retry: 0
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/reserved: 1
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/rts-threshold: 2347
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/rx-msdu-lifetime: 1000
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/short-retry: 0
 | 
					 | 
				
			||||||
radio.1/cisco/mac-operation/tx-msdu-lifetime: 5000
 | 
					 | 
				
			||||||
radio.1/cisco/multi-domain-capability/first-channel: 36
 | 
					 | 
				
			||||||
radio.1/cisco/multi-domain-capability/max-tx-power-level: 65535
 | 
					 | 
				
			||||||
radio.1/cisco/multi-domain-capability/number-of-channels: 16
 | 
					 | 
				
			||||||
radio.1/cisco/multi-domain-capability/reserved: 1
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-cap/extendend-ht-cap-info: 0
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-cap/ht-cap-info: 0
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-cap/rest: .x000000000000000000000000000000000000000000
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-control/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-control/current-freq: 0
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-control/enable-ht: 0
 | 
					 | 
				
			||||||
radio.1/cisco/phy-ht-control/rest: .x03000000000200001400
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/bytes-per-sec: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/cfg-type: 1 - global
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/excpection-level: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/foreigh-threshold: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/min-num-clients: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/min-perf-snr: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/num-clients-threshold: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/rf-busy-threshold: 0
 | 
					 | 
				
			||||||
radio.1/cisco/proformance-profile/rssi-threshold: 0
 | 
					 | 
				
			||||||
radio.1/cisco/spam-cfp-status: false
 | 
					 | 
				
			||||||
radio.1/cisco/station-cfg/cfg-type: 3
 | 
					 | 
				
			||||||
radio.1/cisco/station-cfg/current-freq: 3
 | 
					 | 
				
			||||||
radio.1/cisco/station-cfg/rest: .x020202000000000000000000000000000000000000000000313f01
 | 
					 | 
				
			||||||
radio.1/cisco/tx-power-levels: .x070011000e000b000800050002ffff0000
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/beacon-period: 0
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/bss-id: .x04fe7f499b90
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/cfg-period: 0
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/cfg-type: 1
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/cfp-maximum-duration: 0
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/country-str1: 
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/country-str2: 
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/occupancy-limit: 0
 | 
					 | 
				
			||||||
radio.1/cisco/wtp-radio-config/reg: 256
 | 
					 | 
				
			||||||
radio.255/capwap/admin-state: 1 - enabled
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cisco/ssl-certfile: ../../ssl/certs/wtpc.crt
 | 
					 | 
				
			||||||
cisco/ssl-cipher: SHA1
 | 
					 | 
				
			||||||
cisco/ssl-keyfile: ../../ssl/certs/wtpc.key
 | 
					 | 
				
			||||||
cisco/wtp-use-ac-version: true
 | 
					 | 
				
			||||||
capwap/wtp-board-data/mac-address: .x0800276edf58
 | 
					 | 
				
			||||||
capwap/local-ip-address: 192.168.0.14
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -5,9 +5,9 @@ OBJDIR=./o
 | 
				
			|||||||
LIBDIR		:= ../../lib
 | 
					LIBDIR		:= ../../lib
 | 
				
			||||||
LIBARCHDIR	:= $(LIBDIR)/$(KERNEL)/$(ARCH)
 | 
					LIBARCHDIR	:= $(LIBDIR)/$(KERNEL)/$(ARCH)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CFLAGS+=-I../ -DUSE_OPENSSL -I../../include
 | 
					CFLAGS+=-I../ -DUSE_OPENSSL -I../../include -I/usr/include/libnl3
 | 
				
			||||||
LDFLAGS+=-L$(LIBARCHDIR) -L/usr/local/lib
 | 
					LDFLAGS+=-L$(LIBARCHDIR) -L/usr/local/lib
 | 
				
			||||||
LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl
 | 
					LIBS+=-lcw -lnettle -lssl -lcrypto -ldl -lpthread -lmavl -lnl-3 -lnl-genl-3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SOURCES=\
 | 
					SOURCES=\
 | 
				
			||||||
     	wtp_main.c\
 | 
					     	wtp_main.c\
 | 
				
			||||||
@ -15,6 +15,7 @@ SOURCES=\
 | 
				
			|||||||
	join.c\
 | 
						join.c\
 | 
				
			||||||
	configure.c\
 | 
						configure.c\
 | 
				
			||||||
	run.c\
 | 
						run.c\
 | 
				
			||||||
	changestate.c
 | 
						changestate.c \
 | 
				
			||||||
 | 
						nlt.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include ../prog.mk
 | 
					include ../prog.mk
 | 
				
			||||||
 | 
				
			|||||||
@ -1,242 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <sys/socket.h>
 | 
					 | 
				
			||||||
#include <sys/types.h>
 | 
					 | 
				
			||||||
#include <arpa/inet.h>
 | 
					 | 
				
			||||||
#include <ifaddrs.h>
 | 
					 | 
				
			||||||
#include <net/if.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <uci.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/capwap.h"
 | 
					 | 
				
			||||||
#include "cw/log.h"
 | 
					 | 
				
			||||||
#include "wtp_conf.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/log.h"
 | 
					 | 
				
			||||||
#include "cw/dbg.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "cw/bstr.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static struct uci_section  * get_anon_section(struct uci_package * pkg, const char *type)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct uci_element * e;
 | 
					 | 
				
			||||||
	struct uci_list * l = &pkg->sections;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	uci_foreach_element(l,e){
 | 
					 | 
				
			||||||
		struct uci_section *s = (struct uci_section*)e;
 | 
					 | 
				
			||||||
		if (!s->anonymous)
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (strcmp(s->type,type)==0){
 | 
					 | 
				
			||||||
			return s;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void set_dbg_opt(struct uci_context *ctx,struct uci_section * section,int opt,const char * optstr)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	const char *str = uci_lookup_option_string(ctx,section,optstr);
 | 
					 | 
				
			||||||
	if (!str){
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if ((strcmp(str,"1")==0) || (strcmp(str,"true")==0))
 | 
					 | 
				
			||||||
		//conf_dbg_level |= opt;
 | 
					 | 
				
			||||||
		cw_dbg_set_level(opt,1);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if ((strcmp(str,"0")==0) || (strcmp(str,"false")==0))
 | 
					 | 
				
			||||||
		cw_dbg_set_level(opt,0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void read_dbg_options(struct uci_context *ctx, struct uci_section *section)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        int i;
 | 
					 | 
				
			||||||
        for (i=0; cw_dbg_strings[i].id!=CW_STR_STOP; i++) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		set_dbg_opt(ctx,section,cw_dbg_strings[i].id,cw_dbg_strings[i].str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static void read_timers(struct uci_context *ctx,struct uci_section *section)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
        int i;
 | 
					 | 
				
			||||||
        for (i=0; conf_timer_cfgstrs[i].name; i++) {
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		const char *str = uci_lookup_option_string(ctx,section,conf_timer_cfgstrs[i].name);
 | 
					 | 
				
			||||||
		if ( str ) {
 | 
					 | 
				
			||||||
			*(conf_timer_cfgstrs[i].value)=atol(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int read_config(const char * filename){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct uci_context * ctx;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ctx = uci_alloc_context();
 | 
					 | 
				
			||||||
	if (!ctx){
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Fatal: Can't create uci ctx, can't read config file");
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct uci_package * pkg;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (filename == NULL){
 | 
					 | 
				
			||||||
		filename = "wtp_uci.conf";
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	cw_dbg(DBG_INFO,"Reading config file %s",filename);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	int rc = uci_load(ctx, filename, &pkg );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (rc == UCI_ERR_NOTFOUND){
 | 
					 | 
				
			||||||
		cw_log(LOG_INFO,"Config file '%s' not found, running without config",filename);
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (rc) {
 | 
					 | 
				
			||||||
		char * errstr; 
 | 
					 | 
				
			||||||
		uci_get_errorstr(ctx, &errstr, "");
 | 
					 | 
				
			||||||
		cw_log(LOG_ERR,"Fatal: Can't read config file: %s",errstr);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct uci_section * section;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	section  = get_anon_section(pkg,"dbg");
 | 
					 | 
				
			||||||
	read_dbg_options(ctx,section);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	section = get_anon_section(pkg,"wtp");
 | 
					 | 
				
			||||||
	if (!section) {
 | 
					 | 
				
			||||||
		cw_dbg(DBG_INFO,"No 'wtp' section found, running without config");
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	read_timers(ctx,section);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	const char  *str;
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"name");
 | 
					 | 
				
			||||||
	if (str)
 | 
					 | 
				
			||||||
		conf_wtpname = strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"mtu");
 | 
					 | 
				
			||||||
	if (str)
 | 
					 | 
				
			||||||
		conf_mtu = atoi(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"mtu_discovery");
 | 
					 | 
				
			||||||
	if (str)
 | 
					 | 
				
			||||||
		conf_mtu_discovery = atoi(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"interface");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_primary_if=strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"ip");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_ip=strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"ssl_key");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_sslkeyfilename=strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"ssl_cert");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_sslcertfilename=strdup(str);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"dtls_psk");
 | 
					 | 
				
			||||||
	if (str)
 | 
					 | 
				
			||||||
		conf_dtls_psk=strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"ssl_cipher");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_dtls_cipher=strdup(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"vendor_id");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_vendor_id=atoi(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"echo_interval");
 | 
					 | 
				
			||||||
	if (str) 
 | 
					 | 
				
			||||||
		conf_echo_interval=atoi(str);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"software_version");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_software_version,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"hardware_version");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_hardware_version,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"bootloader_version");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_bootloader_version,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"board_id");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_board_id,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"board_revision");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_board_revision,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"serial_no");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_serial_no,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	str = uci_lookup_option_string(ctx,section,"model_no");
 | 
					 | 
				
			||||||
	if (str){
 | 
					 | 
				
			||||||
		uint8_t * s = bstr16_create_from_cfgstr(str);
 | 
					 | 
				
			||||||
		bstr16_replace(&conf_model_no,s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -10,7 +10,7 @@
 | 
				
			|||||||
#include "wtp.h"
 | 
					#include "wtp.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int config_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int config_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	cw_dbg(DBG_X,"*** Configurations Status Response received ****");
 | 
						cw_dbg(DBG_X,"*** Configurations Status Response received ****");
 | 
				
			||||||
	cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlbalCfg");
 | 
						cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlbalCfg");
 | 
				
			||||||
@ -28,7 +28,7 @@ int configure(struct cw_Conn * conn)
 | 
				
			|||||||
	char sockbuff[SOCK_ADDR_BUFSIZE];
 | 
						char sockbuff[SOCK_ADDR_BUFSIZE];
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	cw_conn_set_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,config_cb);
 | 
						cw_conn_register_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,config_cb);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	int rc;
 | 
						int rc;
 | 
				
			||||||
	cw_cfg_copy(conn->global_cfg,conn->update_cfg,0,"");
 | 
						cw_cfg_copy(conn->global_cfg,conn->update_cfg,0,"");
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
 | 
						struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
 | 
				
			||||||
//	cw_Cfg_t * cfg = cw_cfg_create();
 | 
					//	cw_Cfg_t * cfg = cw_cfg_create();
 | 
				
			||||||
@ -75,18 +75,12 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
 | 
				
			|||||||
	/*discovery_results = mlist_create(NULL, NULL, sizeof(void *));*/
 | 
						/*discovery_results = mlist_create(NULL, NULL, sizeof(void *));*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conn->data = results;
 | 
						conn->data = results;
 | 
				
			||||||
	cw_conn_set_msg_cb(conn,CAPWAP_MSG_DISCOVERY_RESPONSE,discovery_cb);
 | 
						cw_conn_register_msg_cb(conn,CAPWAP_MSG_DISCOVERY_RESPONSE,discovery_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	while (!cw_timer_timeout(timer)
 | 
						while (!cw_timer_timeout(timer)
 | 
				
			||||||
	       && conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
 | 
						       && conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
 | 
				
			||||||
		int rc;
 | 
							int rc;
 | 
				
			||||||
//		conn->remote_cfg = cw_ktv_create();
 | 
					 | 
				
			||||||
//		if (conn->remote_cfg == NULL) {
 | 
					 | 
				
			||||||
//			cw_log_errno("Can't allocate memory for remote_cfg");
 | 
					 | 
				
			||||||
//			break;
 | 
					 | 
				
			||||||
//		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		rc = cw_read_from(conn, &from);
 | 
							rc = cw_read_from(conn, &from);
 | 
				
			||||||
		if (rc < 0) {
 | 
							if (rc < 0) {
 | 
				
			||||||
			if (errno == EAGAIN)
 | 
								if (errno == EAGAIN)
 | 
				
			||||||
 | 
				
			|||||||
@ -322,6 +322,9 @@ struct beacon_data{
 | 
				
			|||||||
int dot11_get_beacon_data(struct apdata *ap,struct beacon_data *bd);
 | 
					int dot11_get_beacon_data(struct apdata *ap,struct beacon_data *bd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define cw_dot11_get_version(frame) ( (frame)[1] & 3)
 | 
				
			||||||
 | 
					#define cw_dot11_get_type(frame) ( ( (frame)[1] & 0x0c) >> 2)
 | 
				
			||||||
 | 
					#define cw_dot11_get_subtype(frame)  ( (frame)[1] >> 4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -1,16 +1,17 @@
 | 
				
			|||||||
#include "netlink/netlink.h"
 | 
					#include <netlink/netlink.h>
 | 
				
			||||||
#include "netlink/genl/genl.h"
 | 
					#include <netlink/genl/genl.h>
 | 
				
			||||||
#include "netlink/genl/ctrl.h"
 | 
					#include <netlink/genl/ctrl.h>
 | 
				
			||||||
#include <netlink/msg.h>
 | 
					#include <netlink/msg.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/log.h"
 | 
					#include "cw/log.h"
 | 
				
			||||||
#include "cw/dbg.h"
 | 
					#include "cw/dbg.h"
 | 
				
			||||||
#include "cw/avltree.h"
 | 
					
 | 
				
			||||||
 | 
					#include <mavl.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "nlt.h"
 | 
					#include "nlt.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
 | 
					static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -32,21 +33,22 @@ static int wiphylist_cmp(const void * d1,const void *d2)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct avltree * wiphylist_create()
 | 
					struct mavl * wiphylist_create()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return avltree_create(wiphylist_cmp,0);
 | 
						return mavl_create(wiphylist_cmp,0,sizeof(struct nlt_wiphyinfo));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct nlt_wiphyinfo * wiphylist_get( struct avltree * l,int idx)
 | 
					struct nlt_wiphyinfo * wiphylist_get( struct mavl * l,int idx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	//return avltree_get(l);
 | 
						//return avltree_get(l);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct nlt_wiphyinfo * nlt_wiphylist_add(struct avltree * t, struct nlt_wiphyinfo * wi)
 | 
					struct nlt_wiphyinfo * nlt_wiphylist_add(struct mavl * t, struct nlt_wiphyinfo * wi)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return avltree_add(t,wi);
 | 
						int exists;
 | 
				
			||||||
 | 
						return mavl_insert(t,wi,exists);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -258,7 +260,7 @@ static int nlCallback(struct nl_msg *msg, void *arg)
 | 
				
			|||||||
		       genlmsg_attrlen(ghdr, 0), NULL);
 | 
							       genlmsg_attrlen(ghdr, 0), NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (rc < 0) {
 | 
						if (rc < 0) {
 | 
				
			||||||
		cw_dbg(DBG_DRV_ERR, "nla_parse failed: %d %d", rc, nl_geterror(rc));
 | 
							cw_dbg(DBG_X, "nla_parse failed: %d %d", rc, nl_geterror(rc));
 | 
				
			||||||
		return NL_SKIP;
 | 
							return NL_SKIP;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -267,7 +269,7 @@ static int nlCallback(struct nl_msg *msg, void *arg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	switch (cmd) {
 | 
						switch (cmd) {
 | 
				
			||||||
		case NL80211_CMD_NEW_WIPHY:
 | 
							case NL80211_CMD_NEW_WIPHY:
 | 
				
			||||||
			add_wiphy_data(msgattribs, arg);
 | 
								//add_wiphy_data(msgattribs, arg);
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
//              case NL80211_CMD_NEW_INTERFACE:
 | 
					//              case NL80211_CMD_NEW_INTERFACE:
 | 
				
			||||||
//                      add_interface_data(msgattribs);
 | 
					//                      add_interface_data(msgattribs);
 | 
				
			||||||
@ -337,7 +339,6 @@ static int get_wiphy_info_cb(struct nl_msg * msg,void * arg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int nlt_get_wiphy_list(struct nl_sock *sk)
 | 
					int nlt_get_wiphy_list(struct nl_sock *sk)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
	struct nlt_wiphyinfo ** wi = malloc (sizeof(struct nlt_wiphyinfo *)*NLT_MAX_WIPHYINDEX);
 | 
						struct nlt_wiphyinfo ** wi = malloc (sizeof(struct nlt_wiphyinfo *)*NLT_MAX_WIPHYINDEX);
 | 
				
			||||||
	if (wi==0)
 | 
						if (wi==0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
@ -347,9 +348,9 @@ int nlt_get_wiphy_list(struct nl_sock *sk)
 | 
				
			|||||||
	struct nl_msg * msg = nlt_nl_msg_new(sk,NL80211_CMD_GET_WIPHY,NLM_F_DUMP);
 | 
						struct nl_msg * msg = nlt_nl_msg_new(sk,NL80211_CMD_GET_WIPHY,NLM_F_DUMP);
 | 
				
			||||||
	nl_send_auto(sk, msg);
 | 
						nl_send_auto(sk, msg);
 | 
				
			||||||
	struct nl_cb *nl_cb = get_nl_cb(get_wiphy_info_cb,wi);
 | 
						struct nl_cb *nl_cb = get_nl_cb(get_wiphy_info_cb,wi);
 | 
				
			||||||
//	while(1){
 | 
						while(1){
 | 
				
			||||||
		int nlr = nl_recvmsgs(sk, nl_cb);
 | 
							int nlr = nl_recvmsgs(sk, nl_cb);
 | 
				
			||||||
//	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
@ -364,4 +365,15 @@ int nlt_get_wiphy_list(struct nl_sock *sk)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*/
 | 
					nlt_test()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct nl_sock *nl;
 | 
				
			||||||
 | 
						nl = nl_socket_alloc();
 | 
				
			||||||
 | 
						if (!nl) {
 | 
				
			||||||
 | 
							fprintf(stderr, "Failed to allocate netlink socket.\n");
 | 
				
			||||||
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						nlt_get_wiphy_list(nl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,7 @@ int update =1;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
 | 
					static int update_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
//	cw_dbg(DBG_X," **** Configuration Update Request Received ***");
 | 
					//	cw_dbg(DBG_X," **** Configuration Update Request Received ***");
 | 
				
			||||||
//	cw_cfg_dump(params->conn->global_cfg);
 | 
					//	cw_cfg_dump(params->conn->global_cfg);
 | 
				
			||||||
@ -79,7 +79,7 @@ int run(struct cw_Conn * conn)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cw_conn_set_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST,update_cb);
 | 
						cw_conn_register_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST,update_cb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	conn->capwap_state = CAPWAP_STATE_RUN;
 | 
						conn->capwap_state = CAPWAP_STATE_RUN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -29,6 +29,7 @@ struct bootcfg{
 | 
				
			|||||||
	const char * modpath;
 | 
						const char * modpath;
 | 
				
			||||||
	const char * config_file;
 | 
						const char * config_file;
 | 
				
			||||||
	const char * startup_file;
 | 
						const char * startup_file;
 | 
				
			||||||
 | 
						const char * local_startup_file;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern struct bootcfg bootcfg;
 | 
					extern struct bootcfg bootcfg;
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@
 | 
				
			|||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
\
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "cw/val.h"
 | 
					#include "cw/val.h"
 | 
				
			||||||
#include "cw/dbg.h"
 | 
					#include "cw/dbg.h"
 | 
				
			||||||
@ -34,8 +34,9 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	bootcfg->config_file = "config.ckv";
 | 
						bootcfg->config_file = "config.ckv";
 | 
				
			||||||
	bootcfg->startup_file = "startup.ckv";
 | 
						bootcfg->startup_file = "startup.ckv";
 | 
				
			||||||
 | 
						bootcfg->local_startup_file ="startup-local.ckv";
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	while ( (c = getopt (argc, argv, "s:p:d:vc:m:h")) != -1) {
 | 
						while ( (c = getopt (argc, argv, "l:s:p:d:vc:m:h")) != -1) {
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		switch (c) {
 | 
							switch (c) {
 | 
				
			||||||
			case 'v':
 | 
								case 'v':
 | 
				
			||||||
@ -65,6 +66,9 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
 | 
				
			|||||||
			case 's':
 | 
								case 's':
 | 
				
			||||||
				bootcfg->startup_file = optarg;
 | 
									bootcfg->startup_file = optarg;
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
								case 'l':
 | 
				
			||||||
 | 
									bootcfg->local_startup_file = optarg;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
			case '?':
 | 
								case '?':
 | 
				
			||||||
				exit(EXIT_FAILURE);
 | 
									exit(EXIT_FAILURE);
 | 
				
			||||||
			default:
 | 
								default:
 | 
				
			||||||
@ -80,9 +84,86 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
 | 
				
			|||||||
#include "cw/rand.h"
 | 
					#include "cw/rand.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct bootcfg bootcfg;
 | 
					struct bootcfg bootcfg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cw/file.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cw/dot11.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int test()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
						uint8_t  *f,*frame;
 | 
				
			||||||
 | 
						size_t len;
 | 
				
			||||||
 | 
						f=(uint8_t*)cw_load_file("wificap-002",&len);
 | 
				
			||||||
 | 
						cw_dbg(DBG_X, "Loaded %d bytes",len);
 | 
				
			||||||
 | 
						int l;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint8_t rates[] = {
 | 
				
			||||||
 | 
							12,0x82,0x84,0x8b,0x96,0x0c,0x12,0x18,0x24,0x30,0x48,0x60,0x6c	
 | 
				
			||||||
 | 
						}; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	static int got_radiotap = 0;
 | 
				
			||||||
 | 
					//	struct libwifi_frame frame = {0};
 | 
				
			||||||
 | 
					///	rc = libwifi_get_wifi_frame(&frame, (unsigned char*)(f+16+1), len-16-1, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// struct libwifi_frame_ctrl *frame_control = (struct libwifi_frame_ctrl *) (f+16);
 | 
				
			||||||
 | 
					// printf("SO: %d\n",frame_control->type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  //  	if (rc != 0) {
 | 
				
			||||||
 | 
					   //     	printf("[!] Error getting libwifi_frame: %d\n", rc);
 | 
				
			||||||
 | 
					   // 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"Frame CTL:%d,%d",frame.frame_control.type, frame.frame_control.subtype);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"MY RESULT: Type %d, SubType %d",cw_dot11_get_type(f+16), cw_dot11_get_subtype(f+16));
 | 
				
			||||||
 | 
					//	cw_dbg(DBG_X,"FRAME: %s",dot11_get_frame_name(f+16+1));
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_X,"%04x",dot11_get_word((uint8_t*)(f)+16));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						char dstr[2048];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_format_dot11_hdr(dstr,f+16,len-16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg(DBG_X,"R:\n%s",dstr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg_dot11_frame(f+16,len-16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						frame = f+16;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint8_t  rframe[1000];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        dot11_init_assoc_resp(rframe);
 | 
				
			||||||
 | 
						dot11_set_duration(rframe,100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        dot11_copy_mac(dot11_get_sa(frame),dot11_get_da(rframe));
 | 
				
			||||||
 | 
					        dot11_copy_mac(dot11_get_bssid(frame),dot11_get_bssid(rframe));
 | 
				
			||||||
 | 
					        dot11_copy_mac(dot11_get_da(frame),dot11_get_sa(rframe));
 | 
				
			||||||
 | 
						dot11_set_seq(rframe,0);
 | 
				
			||||||
 | 
						dot11_assoc_resp_set_cap(rframe,dot11_assoc_req_get_cap(frame));
 | 
				
			||||||
 | 
						dot11_assoc_resp_set_status_code(rframe,0);
 | 
				
			||||||
 | 
						dot11_assoc_resp_set_assoc_id(rframe,17);
 | 
				
			||||||
 | 
						l=24+6;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						l+=dot11_put_supported_rates(rframe+l,rates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cw_dbg_dot11_frame(rframe,l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						free(f);
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main (int argc, char **argv)
 | 
					int main (int argc, char **argv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cw_Mod * mod;
 | 
						struct cw_Mod * mod;
 | 
				
			||||||
@ -97,6 +178,29 @@ int main (int argc, char **argv)
 | 
				
			|||||||
	const char *bind_addr, *disc_addr;
 | 
						const char *bind_addr, *disc_addr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cw_ValBit bits[] = {
 | 
				
			||||||
 | 
							{0,"ess"},
 | 
				
			||||||
 | 
							{1,"ibss"},
 | 
				
			||||||
 | 
							{2,"cf-pollable"},
 | 
				
			||||||
 | 
							{3,"cf-poll-request"},
 | 
				
			||||||
 | 
							{4,"privacy"},
 | 
				
			||||||
 | 
							{5,"short-preamble"},
 | 
				
			||||||
 | 
							{2,"pbcc"},
 | 
				
			||||||
 | 
							{3,"cf-poll-request"},
 | 
				
			||||||
 | 
							{2,NULL}	
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						uint16_t x;
 | 
				
			||||||
 | 
						cw_set_word(&x,1057);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						CW_TYPE_BITS->read(global_cfg,"hello",(uint8_t*)(&x),2,bits);
 | 
				
			||||||
 | 
						exit(0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bootcfg.nmods=0;
 | 
						bootcfg.nmods=0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/* read command line args, results are in bootcfg */
 | 
						/* read command line args, results are in bootcfg */
 | 
				
			||||||
@ -108,6 +212,11 @@ int main (int argc, char **argv)
 | 
				
			|||||||
		bootcfg.nmods=2;
 | 
							bootcfg.nmods=2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						test();
 | 
				
			||||||
 | 
						nlt_test();
 | 
				
			||||||
 | 
						stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* 
 | 
						/* 
 | 
				
			||||||
	 * set ths for production
 | 
						 * set ths for production
 | 
				
			||||||
	 * cw_dbg_set_level(DBG_X,0); 
 | 
						 * cw_dbg_set_level(DBG_X,0); 
 | 
				
			||||||
@ -136,6 +245,16 @@ int main (int argc, char **argv)
 | 
				
			|||||||
		cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.startup_file, strerror(errno));
 | 
							cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.startup_file, strerror(errno));
 | 
				
			||||||
		goto errX;
 | 
							goto errX;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						cw_dbg(DBG_INFO,"Startup '%s' loaded.",bootcfg.startup_file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (access(bootcfg.local_startup_file,F_OK)==0){
 | 
				
			||||||
 | 
							rc = cw_cfg_load(bootcfg.local_startup_file,global_cfg);
 | 
				
			||||||
 | 
							if (rc){
 | 
				
			||||||
 | 
								cw_log(LOG_ERR,"Can't open file '%s':%s",bootcfg.local_startup_file, strerror(errno));
 | 
				
			||||||
 | 
								goto errX;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							cw_dbg(DBG_INFO,"Local startup '%s' loaded.",bootcfg.local_startup_file);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Create a temp. cfg */
 | 
						/* Create a temp. cfg */
 | 
				
			||||||
	cfg = cw_cfg_create();
 | 
						cfg = cw_cfg_create();
 | 
				
			||||||
@ -163,18 +282,6 @@ int main (int argc, char **argv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	cw_cfg_destroy(cfg);
 | 
						cw_cfg_destroy(cfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*	{
 | 
					 | 
				
			||||||
struct cw_Cfg_iter cfi;
 | 
					 | 
				
			||||||
struct cw_Cfg_entry *e;
 | 
					 | 
				
			||||||
int i;
 | 
					 | 
				
			||||||
for (i=0; (i=cw_cfg_get_first_index(global_cfg,"radio",i))!=-1; i++){
 | 
					 | 
				
			||||||
	printf("Inedx: %d\n", i);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
goto errX;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	conn->mod=mod;*/
 | 
					/*	conn->mod=mod;*/
 | 
				
			||||||
	conn->detected = 1;
 | 
						conn->detected = 1;
 | 
				
			||||||
	conn->dtls_verify_peer=0;
 | 
						conn->dtls_verify_peer=0;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,75 +0,0 @@
 | 
				
			|||||||
#default configuration file for wpt 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
config 'wtp'
 | 
					 | 
				
			||||||
	# WTP name 
 | 
					 | 
				
			||||||
	# (default is empty, the WTP will
 | 
					 | 
				
			||||||
	# create a random name)
 | 
					 | 
				
			||||||
	option name			
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# MTU
 | 
					 | 
				
			||||||
	option mtu		1500
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# Do MTU discovery (means append mtu discovery
 | 
					 | 
				
			||||||
	# padding msg element when sendig discovery requests)
 | 
					 | 
				
			||||||
	option mtu_discovery	1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# SSL certificate and key
 | 
					 | 
				
			||||||
	# (default is empty, you have to specify one)
 | 
					 | 
				
			||||||
	option ssl_cert
 | 
					 | 
				
			||||||
	option ssl_key
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# DTSL pre-shared key
 | 
					 | 
				
			||||||
	option dtls_psk
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# ciphers
 | 
					 | 
				
			||||||
	# 
 | 
					 | 
				
			||||||
	option ssl_cipher
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# vendor id
 | 
					 | 
				
			||||||
	# set the vendor id as integer value
 | 
					 | 
				
			||||||
	# default is gnu
 | 
					 | 
				
			||||||
	option vendor_id
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	option max_discovery_interval	30
 | 
					 | 
				
			||||||
	option discovery_interval	5
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# capwap mode
 | 
					 | 
				
			||||||
	# possible values: capwap, cisco
 | 
					 | 
				
			||||||
	# default is "capwap"
 | 
					 | 
				
			||||||
	option	capwap_mode	"capwap"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# bindings mode
 | 
					 | 
				
			||||||
	# possible values: capwpa80211, cisco
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	# interface
 | 
					 | 
				
			||||||
	# Interface to use as primary interface
 | 
					 | 
				
			||||||
	# Default: wtp tries to determine the primary interface
 | 
					 | 
				
			||||||
	# by itself.
 | 
					 | 
				
			||||||
	option interface
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# ip
 | 
					 | 
				
			||||||
	# IP address to use as 
 | 
					 | 
				
			||||||
	option ip
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
config 'dbg'
 | 
					 | 
				
			||||||
	# debug options 
 | 
					 | 
				
			||||||
	option info		0
 | 
					 | 
				
			||||||
	option dtls		0
 | 
					 | 
				
			||||||
	option dtls_detail	0
 | 
					 | 
				
			||||||
	option dtls_bio		0
 | 
					 | 
				
			||||||
	option dtls_bio_dmp	0
 | 
					 | 
				
			||||||
	option pkt_in		0
 | 
					 | 
				
			||||||
	option pkt_out		0
 | 
					 | 
				
			||||||
	option pkt_err		0
 | 
					 | 
				
			||||||
	option msg_in		0
 | 
					 | 
				
			||||||
	option msg_out		0	
 | 
					 | 
				
			||||||
	option msg_err		0
 | 
					 | 
				
			||||||
	option elem		0
 | 
					 | 
				
			||||||
	option elem_err		0
 | 
					 | 
				
			||||||
	option elem_dmp		0
 | 
					 | 
				
			||||||
	option rfc		0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user