extern int hungup;
+//#ifdef BBB_XML_API //Wilson add, (02/13/2006)
+#if defined(SUPPORT_XML_API) //Wilson add, (03/14/2006)
+extern int ppp_session;
+#endif
+
+#ifdef DEBUG_PRINT
+void dumpHex(char *direct, char *buff, int len)
+{
+ if(len<=0) return;
+
+ int i;
+ static struct timeval dumpTime;
+
+ gettimeofday(&dumpTime, NULL);
+
+ printf("(%d.%d) %s:\n", dumpTime.tv_sec, dumpTime.tv_usec, direct);
+ for(i=0;i<len;i++) {
+ printf("%02X ", buff[i]&0xff);
+ if(i%16==15) printf("\n");
+ }
+ printf("\n");
+
+ return;
+}
+#endif
+
/* new_fd is the fd of a tty */
static void set_ppp_fd (int new_fd)
{
*
* generic_establish_ppp - Turn the fd into a ppp interface.
*/
+#if defined(ODM_LANG_LLL)
+extern int ppp_session;
+extern int glbppppid;
+extern int got_ppp_down;
+#endif
int generic_establish_ppp (int fd)
{
int x;
+//#ifdef BBB_XML_API //Wilson add, (02/13/2006)
+#if defined(SUPPORT_XML_API) //Wilson add, (03/14/2006)
+ FILE *fp;
+#endif
+ //char cmd[30];
/*
* Demand mode - prime the old ppp device to relinquish the unit.
*/
if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) {
error("Couldn't get channel number: %m");
+ //printf("PVC error, Bye!!\n");
+ //sprintf(cmd,"kill -9 %d",glbppppid);
+ //system(cmd);
+//#ifdef BBB_XML_API //Wilson add, (02/13/2006)
+#if defined(SUPPORT_XML_API) //Wilson add, (03/14/2006)
+ if (ppp_session == PPPOE){
+ fp = fopen("/var/pppStatus", "w+");
+ if(fp){
+ fprintf(fp, "2,2");
+ fclose(fp);
+ }
+ }
+#endif //endif BBB_XML_API
+ //goto err;
+ //if (ppp_session == PPPOE){
+ // if (ioctl(fd, TIOCSETD, &tty_disc) < 0 && !ok_error(errno))
+ // warn("Couldn't reset tty to normal line discipline: %m");
+ // return -2;
+ //} else {
+#if defined(ODM_LANG_LLL)
+ char cmd[32]="";
+ FILE *wsnfp = NULL;
+ if (ppp_session == PPPOE){
+ wsnfp = fopen("/var/btaolstatus", "w");
+ if(wsnfp){
+ fprintf(wsnfp, "%d", 1);
+ fclose(wsnfp);
+ }
+ //printf("PVC error, Bye!!\n");
+ sprintf(cmd,"kill -9 %d",glbppppid);
+ system(cmd);
+ }
+#else
goto err;
+#endif
+ //}
}
dbglog("using channel %d", chindex);
fd = open("/dev/ppp", O_RDWR);
* Create a new PPP unit.
*/
if (make_ppp_unit() < 0)
- goto err_close;
+ die(1);
+ //goto err_close;
}
if (looped)
if (x < 0 && req_unit >= 0 && errno == EEXIST) {
warn("Couldn't allocate PPP unit %d as it is already in use");
ifunit = -1;
- x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit);
+ //x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit);
}
if (x < 0)
error("Couldn't create new ppp unit: %m");
{
int fd = ppp_fd;
int proto;
+#if defined(SUPPORT_PPPDBG_SYSLOG)
+ char *q;
+#endif
if (debug)
dbglog("sent %P", p, len);
if (len < PPP_HDRLEN)
return;
+
+#if defined(SUPPORT_PPPDBG_SYSLOG)//Dump ascii
+ q=p;
+ if (logstatus == 1){
+ if (((q[2]&0xff)!=0xC0) || ((q[3]&0xff)!=0x21)|| (((q[4]&0xff)!=0x09) && ((q[4]&0xff)!=0x0A))){//Don't log LCP echo request/and echo response
+ andydbglog("Sent %P", q, len);
+ }
+ }
+#endif
+
if (new_style_driver) {
p += 2;
len -= 2;
if (ifunit >= 0 && !(proto >= 0xc000 || proto == PPP_CCPFRAG))
fd = ppp_dev_fd;
}
+
+#if 0
+#if defined(SUPPORT_PPPDBG_SYSLOG)//Dump binary code
+
+ if (len <= 128 && (((p[0]&0xff)!=0xC0) || ((p[1]&0xff)!=0x21)
+ || (((p[2]&0xff)!=0x09) && ((p[2]&0xff)!=0x0A))) ){//Don't log LCP echo request/and echo response
+ andydbglog("sent(binary) %P", p, len);
+ }
+#endif
+#endif
+
+#ifdef DEBUG_PRINT
+ dumpHex("OUTPUT", p, len);
+#endif
+
if (write(fd, p, len) < 0) {
- if (errno == EWOULDBLOCK || errno == ENOBUFS
- || errno == ENXIO || errno == EIO || errno == EINTR)
+ if (errno == EWOULDBLOCK || errno == ENOBUFS || errno == ENXIO || errno == EIO || errno == EINTR)
warn("write: warning: %m (%d)", errno);
else
error("write: %m (%d)", errno);
}
nr = -1;
if (ppp_fd >= 0) {
- if (!(nr = read(ppp_fd, buf, len)))
- nr = -1;
+ nr = read(ppp_fd, buf, len);
+#ifdef DEBUG_PRINT
+ dumpHex("1. INPUT", buf, nr);
+#endif
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read: %m");
if (nr < 0 && errno == ENXIO)
}
if (nr < 0 && new_style_driver && ifunit >= 0) {
/* N.B. we read ppp_fd first since LCP packets come in there. */
- // To avoid nonppp ctl traffic
- if (!(nr = read(ppp_dev_fd, buf, len)))
- nr = -1;
+ nr = read(ppp_dev_fd, buf, len);
+#ifdef DEBUG_PRINT
+ dumpHex("2. INPUT", buf, nr);
+#endif
if (nr < 0 && errno != EWOULDBLOCK && errno != EIO && errno != EINTR)
error("read /dev/ppp: %m");
if (nr < 0 && errno == ENXIO)
{
int rv = 0;
int n;
-
if (new_style_driver) {
- while ((n = read_packet(inpacket_buf)) > 0)
- if (loop_frame(inpacket_buf, n))
+ while ((n = read_packet(inpacket_buf)) > 0){
+ if (loop_frame(inpacket_buf, n)){
rv = 1;
+ }
+ }
return rv;
}
- while ((n = read(master_fd, inbuf, sizeof(inbuf))) > 0)
- if (loop_chars(inbuf, n))
+ while ((n = read(master_fd, inbuf, sizeof(inbuf))) > 0){
+ if (loop_chars(inbuf, n)){
rv = 1;
+ }
+ }
if (n == 0)
fatal("eof on loopback");
if (errno != EWOULDBLOCK)
fatal("read from loopback: %m(%d)", errno);
-
return rv;
}
int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
{
struct rtentry rt;
-
default_route_gateway = 0;
memset (&rt, '\0', sizeof (rt));
return 0;
}
}
-
return 1;
}
{
struct ifreq ifr;
struct rtentry rt;
-
memset (&ifr, '\0', sizeof (ifr));
memset (&rt, '\0', sizeof (rt));
struct ifreq ifr;
create_msg(BCM_PPPOE_CLIENT_STATE_DOWN);
- syslog(LOG_CRIT,"Clear IP addresses. PPP connection DOWN.\n");
+ //syslog(LOG_CRIT,"Clear IP addresses. PPP connection DOWN.\n");
if (kernel_version < KVERSION(2,1,16)) {
/*