CURLcode easysrc_cleanup(void) { CHKRET(easysrc_add(&easysrc_code, "")); CHKRET(easysrc_add(&easysrc_code, "curl_easy_cleanup(hnd);")); CHKRET(easysrc_add(&easysrc_code, "hnd = NULL;")); return CURLE_OK; }
CURLcode easysrc_perform(void) { /* Note any setopt calls which we could not convert */ if(easysrc_toohard) { int i; struct curl_slist *ptr; const char *c; CHKRET(easysrc_add(&easysrc_code, "")); /* Preamble comment */ for(i=0; ((c = srchard[i]) != NULL); i++) CHKRET(easysrc_add(&easysrc_code, c)); /* Each unconverted option */ for(ptr=easysrc_toohard; ptr; ptr = ptr->next) CHKRET(easysrc_add(&easysrc_code, ptr->data)); CHKRET(easysrc_add(&easysrc_code, "")); CHKRET(easysrc_add(&easysrc_code, "*/")); curl_slist_free_all(easysrc_toohard); easysrc_toohard = NULL; } CHKRET(easysrc_add(&easysrc_code, "")); CHKRET(easysrc_add(&easysrc_code, "ret = curl_easy_perform(hnd);")); CHKRET(easysrc_add(&easysrc_code, "")); return CURLE_OK; }
static int cameras_init(void) { int i; CHKRET(cameras_off(1)); for (i=0; i<p.num_cameras; i++) { switch (p.camera[i].sensor) { case OV5650: // FIXME: to do break; case AP8140: mclk(1); mdelay(2); // min 2400 cycles camera_on(i, 1); mdelay(4); // min 5000 cycles cameras_off(1); mdelay(2); // min 2400 cycles mclk(0); break; case OV7692: case OV7739: case SOC380: // do nothing for these break; default: printk(KERN_ERR "unsupported sensor type\n"); return -ENODEV; } } return 0; }
static int cameras_off(bool ignore_vcsi) { int i; for (i=0; i<p.num_cameras; i++) { CHKRET( gpio_set( &p.camera[i].flash_rs, OFF ) ); CHKRET( gpio_set( &p.camera[i].cam_rs, OFF ) ); CHKRET( gpio_set( &p.camera[i].cam_pd, OFF ) ); } if (state != CAMERAS_OFF) { /* regulator requests must be balanced */ CHKRET( regulator_disable(reg_vcam) ); if (!ignore_vcsi) { CHKRET( regulator_disable(reg_vcsi) ); } } state = CAMERAS_OFF; return 0; }
/* IKSTABLEFOUR-8256 Functions camera_on() and camera_off() need to conditionally control the vcsi regulator and, thusly, argument ignore_vcsi is added. The decision to ignore control (or not) is made by the caller. During kernel initialization, the ignore flag is set to ensure the state of vcsi is cleanly inherited from the bootloader. */ static int camera_on(int num, bool ignore_vcsi) { if (state != CAMERAS_OFF) { printk(KERN_ERR "nvodmcam: camera_on: BAD STATE\n"); return -EFAULT; } if (num >= p.num_cameras) { printk(KERN_ERR "nvodmcam: invalid camera number\n"); return -EFAULT; } /* regulator requests must be balanced */ if (!ignore_vcsi) { CHKRET( regulator_enable(reg_vcsi) ); } CHKRET( regulator_enable(reg_vcam) ); /* set CAM_PD on ON state */ CHKRET( gpio_set( &p.camera[num].cam_pd, ON ) ); mdelay(5); /* toggle CAM_RS to ON state */ CHKRET( gpio_set( &p.camera[num].cam_rs, ON ) ); mdelay(5); CHKRET( gpio_set( &p.camera[num].cam_rs, OFF ) ); mdelay(50); // FIXME - check this CHKRET( gpio_set( &p.camera[num].cam_rs, ON ) ); /* set FLASH_RS to ON state */ CHKRET( gpio_set( &p.camera[num].flash_rs, ON ) ); state = CAMERA_ON; return 0; }
CURLcode easysrc_init(void) { CHKRET(easysrc_add(&easysrc_code, "hnd = curl_easy_init();")); return CURLE_OK; }
int main(int argc, char *argv[], char **env) { int tcpsock, tcpclientsock; int udpsockcap; double upcap = 0, downcap = 0; double measupcap = 0, measdowncap = 0; unsigned int tbresult = 0, tbabortflag = 0, tbmindepth = 0, tbmaxdepth = 0; double tbrate = 0, trueupcap = 0, truedowncap = 0; double sleepRes = 1; struct sockaddr_in saddr; unsigned int ssz = sizeof(saddr); char tracefile[256], filename[256]; struct timeval tv; struct sockaddr_in from; FILE *fp; extern double TB_RATE_AVG_INTERVAL; int clientversion = 0; double upCapLimit = 100000; double upProbeLimit = 95000; double downCapLimit = 100000; double downProbeLimit = 95000; TB_RATE_AVG_INTERVAL = 0.3; memset(tracefile, 0, 256); tcpsock = create_server(); sleepRes = prober_sleep_resolution(); printf("sleep time resolution: %.2f ms.\n", sleepRes*1000); while(1) { printf("Waiting for new clients..\n"); udpsockcap = prober_bind_port(SERV_PORT_UDP); CHKRET(udpsockcap); tcpclientsock = handle_clients(tcpsock, udpsockcap); CHKRET(tcpclientsock); close(tcpsock); begintimer(); if(getpeername(tcpclientsock, (struct sockaddr *)&saddr, &ssz) == -1) fprintf(stderr, "cannot get peer address\n"); gettimeofday(&tv, NULL); memset(filename, 0, 256); printf("Probing from %s\n", inet_ntoa(saddr.sin_addr)); printf("\nEstimating capacity:\n"); fp = openLog(filename, inet_ntoa(saddr.sin_addr), tv); //assume this opens a fp fprintf(fp, "sleep time resolution: %.2f ms.\n", sleepRes*1000); CHKRET(preprocess_newclient(tcpclientsock, udpsockcap, &clientversion, &upcap, &downcap, &from, tracefile, fp, filename)); trueupcap = upcap; truedowncap = downcap; if(clientversion > 3) // newer clients { upCapLimit = 200000; upProbeLimit = 195000; downCapLimit = 200000; downProbeLimit = 195000; } if(upcap > upCapLimit /*200000*/) { upcap = upProbeLimit /*195000*/; } if(downcap > downCapLimit /*200000*/) { downcap = downProbeLimit /*195000*/; } mflowReceiver(tcpclientsock, udpsockcap, &measupcap, fp, 0); mflowSender(tcpclientsock, udpsockcap, &from, downcap, sleepRes, &measdowncap, 0); printf("recvrates: up %f, down %f Kbps\n", measupcap, measdowncap); upcap = measupcap; downcap = measdowncap; fprintf(fp, "upstream capacity: %.2f Kbps.\n", upcap); fprintf(fp, "downstream capacity: %.2f Kbps.\n", downcap); fprintf(fp, "### UPSTREAM ###\n"); printf("upstream capacity: %.2f Kbps.\n", upcap); printf("downstream capacity: %.2f Kbps.\n", downcap); if(upcap > upCapLimit /*200000*/) { upcap = upProbeLimit /*195000*/; } //else { upcap *= 0.95; } if(downcap > downCapLimit /*200000*/) { downcap = downProbeLimit /*195000*/; } //else { downcap *= 0.95; } printf("Checking for traffic shapers:\n"); if(clientversion > 3) //backwards-compatibility mflowReceiver(tcpclientsock, udpsockcap, NULL, fp, 1); CHKRET(tbdetectReceiver(tcpclientsock, udpsockcap, upcap, sleepRes, &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp)); if(tbresult == 1) trueupcap = tbrate; printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, 0, fp); if(clientversion > 3) //backwards-compatibility mflowSender(tcpclientsock, udpsockcap, &from, -1, sleepRes, NULL, 1); CHKRET(tbdetectSender(tcpclientsock, udpsockcap, &from, downcap, sleepRes, &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp)); if(tbresult == 1) truedowncap = tbrate; printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, 1, fp); recvData(tcpclientsock, fp, 1 /*0 up 1 down*/); fclose(fp); close(udpsockcap); close(tcpclientsock); break; } execl("/bin/bzip2", "/bin/bzip2", filename, NULL); return(0); }
int main(int argc, char *argv[]) { int tcpsock = 0; int udpsock = 0; struct sockaddr_in from; double capacityup = 0, capacitydown = 0; double measupcap = 0, measdowncap = 0; unsigned int tbresult = 0, tbmindepth = 0, tbmaxdepth = 0, tbabortflag = 0; double tbrate = 0, truecapup = 0, truecapdown = 0; double sleepRes = 1; char filename[256], tracefile[256]; int fileid = -1; struct in_addr sin_addr; struct timeval tv; FILE *fp; extern double TB_RATE_AVG_INTERVAL; TB_RATE_AVG_INTERVAL = 0.3; memset(tracefile, 0, 256); CHKRET(prober_config_load(argc, argv, tracefile, &fileid)); sleepRes = prober_sleep_resolution(); if (serverip) { tcpsock = connect2server(serverip, fileid); } else { tcpsock = selectServer(fileid); if(tcpsock <= 0) printf("Server busy. Please try again later.\n"); } CHKRET(tcpsock); memset(&from, 0, sizeof(from)); from.sin_family = PF_INET; //from.sin_port = htons(SERV_PORT_UDP); from.sin_port = htons(serv_port); from.sin_addr.s_addr = serverip; gettimeofday(&tv, NULL); sin_addr.s_addr = serverip; memset(filename, 0, 256); sprintf(filename, "/tmp/udp_%s.log", inet_ntoa(sin_addr)); fp = fopen(filename, "a+w"); fprintf(fp, "sleep time resolution: %.2f ms.\n", sleepRes*1000); //udpsock = udpclient(serverip, SERV_PORT_UDP); udpsock = udpclient(serverip, serv_port); CHKRET(udpsock); sin_addr.s_addr = serverip; fprintf(fp, "Connected to server %s.\n", inet_ntoa(sin_addr)); fprintf(fp, "\nEstimating capacity:\n"); capacityup = estimateCapacity(tcpsock, udpsock, &from); CHKRET(capacityup); CHKRET(sendCapEst(tcpsock)); fprintf(fp, "Upstream: %d Kbps.\n", (int)capacityup); capacitydown = capacityEstimation(tcpsock, udpsock, &from, fp); CHKRET(capacitydown); //printf("Downstream: %d Kbps.\n", (int)capacitydown); // send to test log printf("%s, %d, %.2f, %.2f\n",inet_ntoa(sin_addr), (int)tv.tv_sec, capacityup, capacitydown); fprintf(fp, "LOG: %s, %s, %d, %.2f, %.2f\n", filename, inet_ntoa(sin_addr), (int)tv.tv_sec, capacityup, capacitydown); // finished logging close(udpsock); close(tcpsock); //printf("\nFor more information, visit: http://www.cc.gatech.edu/~partha/diffprobe\n"); fprintf(fp, "\nDONE\n"); fclose(fp); unlink(filename); return(0); }
int main(int argc, char *argv[]) { int tcpsock = 0; int udpsock = 0; struct sockaddr_in from; double capacityup = 0, capacitydown = 0; double measupcap = 0, measdowncap = 0; unsigned int tbresult = 0, tbmindepth = 0, tbmaxdepth = 0, tbabortflag = 0; double tbrate = 0, truecapup = 0, truecapdown = 0; double sleepRes = 1; char filename[256], tracefile[256]; int fileid = -1; struct in_addr sin_addr; struct timeval tv; FILE *fp; extern double TB_RATE_AVG_INTERVAL; TB_RATE_AVG_INTERVAL = 0.3; printf("DiffProbe beta release. October 2009.\n"); printf("Shaper Detection Module.\n\n"); memset(tracefile, 0, 256); CHKRET(prober_config_load(argc, argv, tracefile, &fileid)); sleepRes = prober_sleep_resolution(); tcpsock = connect2server(serverip, fileid); //tcpsock = selectServer(fileid); if(tcpsock <= 0) printf("Server busy. Please try again later.\n"); CHKRET(tcpsock); memset(&from, 0, sizeof(from)); from.sin_family = PF_INET; //from.sin_port = htons(SERV_PORT_UDP); from.sin_port = htons(serv_port); from.sin_addr.s_addr = serverip; gettimeofday(&tv, NULL); sin_addr.s_addr = serverip; memset(filename, 0, 256); sprintf(filename, "%s_%d.txt", inet_ntoa(sin_addr), (int)tv.tv_sec); //fp = fopen(filename, "w"); //fprintf(fp, "sleep time resolution: %.2f ms.\n", sleepRes*1000); //udpsock = udpclient(serverip, SERV_PORT_UDP); udpsock = udpclient(serverip, serv_port); CHKRET(udpsock); sin_addr.s_addr = serverip; printf("Connected to server %s.\n", inet_ntoa(sin_addr)); printf("\nEstimating capacity:\n"); capacityup = estimateCapacity(tcpsock, udpsock, &from); CHKRET(capacityup); CHKRET(sendCapEst(tcpsock)); capacitydown = capacityEstimation(tcpsock, udpsock, &from, fp); CHKRET(capacitydown); mflowSender(tcpsock, udpsock, &from, (capacityup > 100000) ? 95000 : capacityup, sleepRes, &measupcap); mflowReceiver(tcpsock, udpsock, &measdowncap, fp); //XXX: the meas code needs trains and lower cpu if(capacityup < 80000) capacityup = measupcap; if(capacitydown < 80000) capacitydown = measdowncap; if(capacityup > 100000) { //printf("Upstream: greater than 100 Mbps.\n"); printf("Upstream: %d Kbps.\n", (int)capacityup); capacityup = 95000; } else { printf("Upstream: %d Kbps.\n", (int)capacityup); // capacityup *= 0.95; //reduce loss-based aborts } truecapup = capacityup; if(capacitydown > 100000) { //printf("Downstream: greater than 100 Mbps.\n"); printf("Downstream: %d Kbps.\n", (int)capacitydown); capacitydown = 95000; } else { printf("Downstream: %d Kbps.\n", (int)capacitydown); // capacitydown *= 0.95; //reduce loss-based aborts } truecapdown = capacitydown; printf("\nThe measurement will last for about %.1f minutes. Please wait.\n", 0.5*ceil(2*( (2 * (60) // probing + low-rate + (40560 + 3.5 * capacitydown * (60) ) * 8 / (1000*capacityup))/60))); // to upload file printf("\nChecking for traffic shapers:\n\n"); CHKRET(tbdetectSender(tcpsock, udpsock, &from, capacityup, sleepRes, &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp)); if(tbresult == 1) truecapup = tbrate; // mflowSender(tcpsock, udpsock, &from, (tbresult == 1) ? tbrate : capacityup/2.0, sleepRes); printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, tbabortflag, 0, stdout); CHKRET(tbdetectReceiver(tcpsock, udpsock, capacitydown, sleepRes, &tbresult, &tbmindepth, &tbmaxdepth, &tbrate, &tbabortflag, fp)); if(tbresult == 1) truecapdown = tbrate; // mflowReceiver(tcpsock, udpsock, fp); //fclose(fp); //sendData(tcpsock, filename); printShaperResult(tbresult, tbmindepth, tbmaxdepth, tbrate, tbabortflag, 1, stdout); close(udpsock); close(tcpsock); printf("\nFor more information, visit: http://www.cc.gatech.edu/~partha/diffprobe\n"); return(0); }