struct tunnel *l2tp_call (char *host, int port, struct lac *lac, struct lns *lns) { /* * Establish a tunnel from us to host * on port port */ struct call *tmp = NULL; struct hostent *hp; struct in_addr addr; port = htons (port); hp = gethostbyname (host); if (!hp) { l2tp_log (LOG_WARNING, "Host name lookup failed for %s.\n", host); schedule_redial(lac); return NULL; } bcopy (hp->h_addr, &addr.s_addr, hp->h_length); /* Force creation of a new tunnel and set it's tid to 0 to cause negotiation to occur */ /* * to do IPsec properly here, we need to set a socket policy, * and/or communicate with pluto. */ tmp = get_call (0, 0, addr, port, IPSEC_SAREF_NULL, IPSEC_SAREF_NULL); if (!tmp) { l2tp_log (LOG_WARNING, "%s: Unable to create tunnel to %s.\n", __FUNCTION__, host); schedule_redial(lac); return NULL; } tmp->container->tid = 0; tmp->container->lac = lac; tmp->container->lns = lns; tmp->lac = lac; tmp->lns = lns; if (lac) lac->t = tmp->container; if (lns) lns->t = tmp->container; /* * Since our state is 0, we will establish a tunnel now */ l2tp_log (LOG_NOTICE, "Connecting to host %s, port %d\n", host, ntohs (port)); if (lac) { if (lac->route_rdgw == 1) route_add(tmp->container->peer.sin_addr, 0, &tmp->container->rt); else if (lac->route_rdgw == 2) route_add(tmp->container->peer.sin_addr, 1, &tmp->container->rt); } control_finish (tmp->container, tmp); return tmp->container; }
struct call *lac_call (int tid, struct lac *lac, struct lns *lns) { struct tunnel *t = tunnels.head; struct call *tmp; while (t) { if (t->ourtid == tid) { tmp = new_call (t); if (!tmp) { log (LOG_WARN, "%s: unable to create new call\n", __FUNCTION__); return NULL; } tmp->next = t->call_head; t->call_head = tmp; t->count++; tmp->cid = 0; tmp->lac = lac; tmp->lns = lns; if (lac) lac->c = tmp; log (LOG_NOTICE, "Calling on tunnel %d\n", tid); strcpy (tmp->dial_no, dial_no_tmp); /* jz: copy dialnumber to tmp->dial_no */ control_finish (t, tmp); return tmp; } t = t->next; }; log (LOG_DEBUG, "%s: No such tunnel %d to generate call.\n", __FUNCTION__, tid); return NULL; }
int Read_Kinect::control() { int rtn = 0; control_initialize(); while (1) { control_running(); //exit if (_if_shutdown) { break; } int c = cvWaitKey(1); if (c == 27 || c == 'q' || c == 'Q') { _if_shutdown = true; break; } } control_finish(); return rtn; }
struct tunnel *l2tp_call (char *host, int port, struct lac *lac, struct lns *lns) { /* * Establish a tunnel from us to host * on port port */ struct call *tmp = NULL; struct hostent *hp; struct in_addr addr; #if !defined(__UCLIBC__) \ || (__UCLIBC_MAJOR__ == 0 \ && (__UCLIBC_MINOR__ < 9 || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 31))) /* force ns refresh from resolv.conf with uClibc pre-0.9.31 */ res_init(); #endif port = htons (port); hp = gethostbyname (host); if (!hp) { l2tp_log (LOG_WARNING, "Host name lookup failed for %s.\n", host); return NULL; } bcopy (hp->h_addr, &addr.s_addr, hp->h_length); /* Force creation of a new tunnel and set it's tid to 0 to cause negotiation to occur */ /* * to do IPsec properly here, we need to set a socket policy, * and/or communicate with pluto. */ tmp = get_call (0, 0, addr, port, IPSEC_SAREF_NULL, IPSEC_SAREF_NULL); if (!tmp) { l2tp_log (LOG_WARNING, "%s: Unable to create tunnel to %s.\n", __FUNCTION__, host); return NULL; } tmp->container->tid = 0; tmp->container->lac = lac; tmp->container->lns = lns; tmp->lac = lac; tmp->lns = lns; if (lac) lac->t = tmp->container; if (lns) lns->t = tmp->container; /* * Since our state is 0, we will establish a tunnel now */ l2tp_log (LOG_NOTICE, "Connecting to host %s, port %d\n", host, ntohs (port)); control_finish (tmp->container, tmp); return tmp->container; }
struct tunnel *l2tp_call (char *host, int port, struct lac *lac, struct lns *lns) { /* * Establish a tunnel from us to host * on port port */ struct call *tmp = NULL; struct hostent *hp; unsigned int addr; port = htons (port); hp = gethostbyname (host); if (!hp) { log (LOG_WARN, "Host name lookup failed for %s.\n", host); return NULL; } bcopy (hp->h_addr, &addr, hp->h_length); /* Force creation of a new tunnel and set it's tid to 0 to cause negotiation to occur */ /* XXX L2TP/IPSec: Set up SA to addr:port here? NTB 20011010 */ tmp = get_call (0, 0, addr, port); if (!tmp) { log (LOG_WARN, "%s: Unable to create tunnel to %s.\n", __FUNCTION__, host); return NULL; } tmp->container->tid = 0; tmp->container->lac = lac; tmp->container->lns = lns; tmp->lac = lac; tmp->lns = lns; if (lac) lac->t = tmp->container; if (lns) lns->t = tmp->container; /* * Since our state is 0, we will establish a tunnel now */ log (LOG_NOTICE, "Connecting to host %s, port %d\n", host, ntohs (port)); control_finish (tmp->container, tmp); return tmp->container; }
struct tunnel *l2tp_call (char *host, int port, struct lac *lac, struct lns *lns) { /* * Establish a tunnel from us to host * on port port */ struct call *tmp = NULL; struct hostent *hp; unsigned int addr; //------------------------------------------------- #if defined(CONFIG_RTL8186_TR) || defined(CONFIG_RTL865X_SC) struct in_addr retval; struct in_addr intaddr; struct in_addr intmask; char server_ip[100]; char l2tp_gw[30]; char l2tp_ipdyn[30]; char cmdBuffer[200]; FILE *fp1, *fp2; #endif //------------------------------------------------ port = htons (port); hp = gethostbyname (host); if (!hp) { log (LOG_WARN, "Host name lookup failed for %s.\n", host); return NULL; } #if defined(CONFIG_RTL8186_TR) || defined(CONFIG_RTL865X_SC) //Brad add //if l2tp server is not in the same subnet as l2tp client, we put l2tp server ip to /var/l2tp_server memcpy(&retval.s_addr, hp->h_addr, sizeof(retval.s_addr)); if (getInAddr("eth1", IP_ADDR, (void *)&intaddr )){ if(getInAddr("eth1", SUBNET_MASK, (void *)&intmask)){ if((intaddr.s_addr & intmask.s_addr) != (retval.s_addr & intmask.s_addr)){ //warn("generate pptp server =%s\n", inet_ntoa(retval)); sprintf(server_ip, "echo %s > /var/l2tp_server", inet_ntoa(retval)); system(server_ip); fp1= fopen("/var/l2tp_dyn", "r"); if(fp1 !=NULL){ fscanf(fp1, "%s", l2tp_ipdyn); if(l2tp_ipdyn[0]=='1'){ fp2= fopen("/var/l2tp_gw", "r"); if (fp2 != NULL) { fscanf(fp2, "%s", l2tp_gw); sprintf(cmdBuffer, "route add -host %s gw %s", inet_ntoa(retval), l2tp_gw); system(cmdBuffer); fclose(fp2); } }else{ fp2= fopen("/var/eth1_gw", "r"); if (fp2 != NULL) { fscanf(fp2, "%s", l2tp_gw); sprintf(cmdBuffer, "route add -host %s gw %s", inet_ntoa(retval), l2tp_gw); system(cmdBuffer); fclose(fp2); } } fclose(fp1); } } } } #endif bcopy (hp->h_addr, &addr, hp->h_length); /* Force creation of a new tunnel and set it's tid to 0 to cause negotiation to occur */ /* XXX L2TP/IPSec: Set up SA to addr:port here? NTB 20011010 */ tmp = get_call (0, 0, addr, port); if (!tmp) { log (LOG_WARN, "%s: Unable to create tunnel to %s.\n", __FUNCTION__, host); return NULL; } tmp->container->tid = 0; tmp->container->lac = lac; tmp->container->lns = lns; tmp->lac = lac; tmp->lns = lns; if (lac) lac->t = tmp->container; if (lns) lns->t = tmp->container; /* * Since our state is 0, we will establish a tunnel now */ log (LOG_NOTICE, "Connecting to host %s, port %d\n", host, ntohs (port)); control_finish (tmp->container, tmp); return tmp->container; }
struct tunnel *l2tp_call (char *host, int port, struct lac *lac, struct lns *lns) { /* * Establish a tunnel from us to host * on port port */ struct call *tmp = NULL; struct hostent *hp; unsigned int addr; FILE *fp; port = htons (port); /* Foxconn, added by MJ. 01/29/2010 */ struct in_addr l2tp_serv_ip; /* add routing for DNS server 01/29/2010*/ fxc_add_gw(1, l2tp_serv_ip); /* Foxconn, added end.*/ hp = gethostbyname (host); if (!hp) { log (LOG_WARN, "%s: gethostbyname() failed for %s.\n", __FUNCTION__, host); return NULL; } bcopy (hp->h_addr, &addr, hp->h_length); /* Foxconn, add start by MJ., for l2tp. 01/28/2010 */ if (hp->h_addrtype == AF_INET){ memcpy(&l2tp_serv_ip.s_addr, hp->h_addr, sizeof(l2tp_serv_ip.s_addr)); if ( fp = fopen("/tmp/ppp/l2tpSrvIp", "w") ) { fprintf(fp, "%s", inet_ntoa(l2tp_serv_ip)); fclose(fp); } } /* Add routing for L2TP server */ fxc_add_gw(2, l2tp_serv_ip); /* Foxconn, add end, by MJ., for l2tp. 01/28/2010 */ /* Force creation of a new tunnel and set it's tid to 0 to cause negotiation to occur */ /* XXX L2TP/IPSec: Set up SA to addr:port here? NTB 20011010 */ tmp = get_call (0, 0, addr, port); if (!tmp) { log (LOG_WARN, "%s: Unable to create tunnel to %s.\n", __FUNCTION__, host); return NULL; } tmp->container->tid = 0; tmp->container->lac = lac; tmp->container->lns = lns; tmp->lac = lac; tmp->lns = lns; if (lac) lac->t = tmp->container; if (lns) lns->t = tmp->container; /* * Since our state is 0, we will establish a tunnel now */ log (LOG_LOG, "%s:Connecting to host %s, port %d\n", __FUNCTION__, host, ntohs (port)); control_finish (tmp->container, tmp); return tmp->container; }