Beispiel #1
0
static int request_video_info(pvp_uthttp put, char **ut_buf, u32 *pack_len)
{
	char      *p =NULL;
	char      s[32]={0};
	char      vsrcip[32] = {0};
	char      vsrcport[8] ={0};


	p = strnstr(*ut_buf, "c=IN", *pack_len, true); // c=IN IP4 10.18.13.79
	if (p != NULL)
		sscanf(p + 9, "%[^\r\n]", vsrcip);

	p = strnstr(*ut_buf, "m=video", *pack_len, true); // m=video 26828 RTP/AVP 99
	if (p != NULL)
		sscanf(p + 8, "%[^' ']", vsrcport);

	run_vs_udp_proxy(__gg.inner_addr, inet_atoul(vsrcip), atoi(vsrcport), atoi(vsrcport), 0, put->session_tout, __gg.ferry_port);
	run_vs_udp_proxy(__gg.inner_addr, inet_atoul(vsrcip), atoi(vsrcport)+1, atoi(vsrcport)+1, 0, put->session_tout, __gg.ferry_port);

	inet_ultoa(__gg.inner_addr, s);
	strreplace(ut_buf, vsrcip, s, REPLACE_ALL, pack_len);
	update_content_length(ut_buf, pack_len);
	return 1;
}
Beispiel #2
0
}
		
void handleForm(request *req)
{
	char *ptr;
	int i;
	#define SCRIPT_ALIAS "/boafrm/"

//fprintf(stderr, "###%s:%d req->request_uri=%s###\n", __FILE__, __LINE__, req->request_uri);

#ifdef ACTIONTEC_WCB
	int cgi_flag = 1;
	ptr = strstr(req->request_uri, ".cgi");
	if(!ptr)
	{
		ptr = strstr(req->request_uri, SCRIPT_ALIAS);
		cgi_flag = 0;
	}	
#else
	ptr = strstr(req->request_uri, SCRIPT_ALIAS);
#endif
	apmib_get(MIB_WAN_DHCP, (void *)&last_wantype);
	if (ptr==NULL) {
		send_r_not_found(req);
		return;
	}
	else {
		form_name_t *now_form;
		
#ifdef ACTIONTEC_WCB
		if(cgi_flag)
			ptr = '\0';		
		else
			ptr += strlen(SCRIPT_ALIAS);
#else
		ptr+=strlen(SCRIPT_ALIAS);
#endif		

		for (i=0; root_form[i].name!=NULL; i++) {
			now_form = &root_form[i];

#ifdef ACTIONTEC_WCB			
			if((cgi_flag && strstr(req->request_uri, now_form->name)) 
				|| (!cgi_flag && (strlen(ptr) == strlen(now_form->name)) 
					 && (memcmp(ptr,now_form->name,strlen(now_form->name))==0))) {
#else
			if ((strlen(ptr) == strlen(now_form->name)) &&
			    (memcmp(ptr,now_form->name,strlen(now_form->name))==0)) {
#endif
				send_r_request_ok2(req);		/* All's well */	
/*#ifdef USE_AUTH
				if (req->auth_flag == 1) { // user
					//brad add for wizard
					if(!strcmp(req->request_uri,"/boafrm/formSetEnableWizard")){
						send_redirect_perm(req, "/wizard_back.htm");
					}else{
						//ptr= (char *)req_get_cstream_var(req, ("webpage"), (""));					
						//strcpy(last_url, ptr);				
						//sprintf(ok_msg,"%s","\"Only <b>admin</b> account can change the settings.<br>\""); 				
						//send_redirect_perm(req, WEB_PAGE_APPLY_OK);	
						ptr= (char *)req_get_cstream_var(req, ("webpage"), (""));
						if(ptr ==NULL)
							sprintf(last_url, "/%s", directory_index);
						else
							strcpy(last_url, ptr);	
										
						if(!strcmp(req->request_uri,"/boafrm/formSetRestorePrev") || !strcmp(req->request_uri,"/boafrm/formSetFactory")){
							sprintf(last_url, "%s","util_savesetting.asp");
							if (req->upload_data)
								free(req->upload_data);	
						}
						if(!strcmp(req->request_uri,"/boafrm/formFirmwareUpgrade")){
							sprintf(last_url, "%s","util_firmware.asp");	
							if (req->upload_data)
								free(req->upload_data);	
						}	
						if(!strcmp(req->request_uri,"/boafrm/formWPS")){
							wps_action= (char *)req_get_cstream_var(req, ("wpsAction"), (""));
							if(!strcmp(wps_action, "pbc") || !strcmp(wps_action, "pin")){
								now_form->function(req,NULL,NULL);
								freeAllTempStr();
								return;
							}
						}	
						sprintf(ok_msg,"%s","\"Only <b>admin</b> account can change the settings.<br>\"");
						send_redirect_perm(req, WEB_PAGE_APPLY_OK);	
						}			
				}
				else
#endif*/
				now_form->function(req,NULL,NULL);
				update_content_length(req);
				freeAllTempStr();
				return;
			}
		}
	}
	send_r_not_found(req);
}

void handleScript(request *req,char *left1,char *right1)
{
	char *left=left1,*right=right1;
	asp_name_t *now_asp;
	unsigned int funcNameLength;
	int i, j;
	
	left += 2;
	right -= 1;
	while (1) {
		while (*left==' ') {if(left>=right) break;++left;}
		while (*left==';') {if(left>=right) break;++left;}
		while (*left=='(') {if(left>=right) break;++left;}
		while (*left==')') {if(left>=right) break;++left;}
		while (*left==',') {if(left>=right) break;++left;}
		if (left >= right)
			break;

		/* count the function name length */
		{
			char *ptr = left;

			funcNameLength = 0;
			while (*ptr!='(' && *ptr!=' ') {
				ptr++;
				funcNameLength++;
				if ((unsigned int )ptr >= (unsigned int)right) {
					break;
				}
			}
		}

		for (j=0; root_asp[j].name!=NULL; j++) {
			now_asp = &root_asp[j];
			if ((strlen(now_asp->name) == funcNameLength) &&
			    (memcmp(left,now_asp->name,strlen(now_asp->name))==0)) {
				char *leftc,*rightc;
				int argc=0;
				char *argv[8]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
				
				left += strlen(now_asp->name);
				while (1) {
					int size,exit=0;
					while (1) {
						if (*left==')') {
							exit=1;
							break;
						}
						if (*left=='\"')
							break;
						if ((unsigned int)left > (unsigned int)right) {
							exit=1;
							break;
						}
						left++;	
					}
					
					if (exit==1)
						break;					
					leftc = left;
					leftc++;
					rightc = strstr(leftc,"\"");
					if (rightc==NULL)
						break;
					size = (unsigned int)rightc-(unsigned int)leftc+1;
					argv[argc] = (char *)malloc(size);
					if (argv[argc]==NULL)
						break;
					memcpy(argv[argc],leftc,size-1);
					argv[argc][size-1] = '\0';
					argc++;
					left = rightc + 1;
				}
				//fprintf(stderr, "###%s:%d now_asp->name=%s###\n", __FILE__, __LINE__, now_asp->name);
				now_asp->function(req,argc,argv);
				for (i=0; i<argc; i++)
					free(argv[i]);
				break;
			}
		}
		++left;