Ejemplo n.º 1
0
Archivo: pppoe.c Proyecto: OPSF/uClinux
//int (*old_setdevname_hook)(char* cp) = NULL;
int setdevname_pppoe(char *cp)
{
    int ret;
    char dev[IFNAMSIZ+1];
    int addr[ETH_ALEN];
    int sid;

    char **a;
    ret =sscanf(cp, FMTSTRING(IFNAMSIZ),addr, addr+1, addr+2,
		addr+3, addr+4, addr+5,&sid,dev);
    if( ret != 8 ){

	ret = get_sockaddr_ll(cp,NULL,0);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");
	/* not a device name */
	if (ret == 0)
	    return 0;
	if (ret == 1)
	    strncpy(devnam, cp, sizeof(devnam));
    }else{
	/* long form parsed */
	ret = get_sockaddr_ll(dev,NULL,0);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");

	strncpy(devnam, cp, sizeof(devnam));
	ret = 1;
    }



    for (a = bad_options; *a != NULL; a++)
		remove_option(*a);
    deprecate_options(deprecated_options);
	modem = 0;

	lcp_allowoptions[0].neg_accompression = 0;
	lcp_wantoptions[0].neg_accompression = 0;

	lcp_allowoptions[0].neg_asyncmap = 0;
	lcp_wantoptions[0].neg_asyncmap = 0;

	lcp_allowoptions[0].neg_pcompression = 0;
	lcp_wantoptions[0].neg_pcompression = 0;

	ccp_allowoptions[0].deflate = 0 ;
	ccp_wantoptions[0].deflate = 0 ;

	ipcp_allowoptions[0].neg_vj=0;
	ipcp_wantoptions[0].neg_vj=0;

	ccp_allowoptions[0].bsd_compress = 0;
	ccp_wantoptions[0].bsd_compress = 0;

	init_device_pppoe();

    return ret;
}
Ejemplo n.º 2
0
int setdevname_pppoe(const char *cp)
{
    int ret;
    char dev[IFNAMSIZ+1];
    int addr[ETH_ALEN];
    int sid;

//    char **a;
    ret =sscanf(cp, FMTSTRING(IFNAMSIZ),addr, addr+1, addr+2,
		addr+3, addr+4, addr+5,&sid,dev);
    if( ret != 8 ){

	ret = get_sockaddr_ll(cp,NULL);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");
	if (ret == 1)
	    strncpy(devnam, cp, sizeof(devnam));
    }else{
	/* long form parsed */
	ret = get_sockaddr_ll(dev,NULL);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");

	strncpy(devnam, cp, sizeof(devnam));
	ret = 1;
    }


    if( ret == 1 && the_channel != &pppoe_channel ){

	the_channel = &pppoe_channel;

	{
	    char **a;
	    for (a = bad_options; *a != NULL; a++)
		remove_option(*a);
	}

// cwu
	ipcp_allowoptions[0].default_route = 0 ;
	ipcp_wantoptions[0].default_route = 0 ;

// cwu
#if 0
	modem = 0;
#endif

	lcp_allowoptions[0].neg_accompression = 0;
	lcp_wantoptions[0].neg_accompression = 0;

	lcp_allowoptions[0].neg_asyncmap = 0;
	lcp_wantoptions[0].neg_asyncmap = 0;

	lcp_allowoptions[0].neg_pcompression = 0;
	lcp_wantoptions[0].neg_pcompression = 0;
// cwu
#if 0
	ccp_allowoptions[0].deflate = 0 ;
	ccp_wantoptions[0].deflate = 0 ;
#endif

	ipcp_allowoptions[0].neg_vj=0;
	ipcp_wantoptions[0].neg_vj=0;
// cwu
#if 0
	ccp_allowoptions[0].bsd_compress = 0;
	ccp_wantoptions[0].bsd_compress = 0;
#endif

	init_device_pppoe();
    }
    return ret;
}
Ejemplo n.º 3
0
int client_init_ses (struct session *ses, char* devnam)
{
    int i=0;
    int retval;
    char dev[IFNAMSIZ+1];
    int addr[ETH_ALEN];
    int sid;
    
    /* do error checks here; session name etc are valid */
//    poe_info (ses,"init_ses: creating socket");
    
    /* Make socket if necessary */
    if( disc_sock < 0 ){
        
        disc_sock = socket(PF_PACKET, SOCK_DGRAM, 0);
        if( disc_sock < 0 ){
            poe_fatal(ses,
                      "Cannot create PF_PACKET socket for PPPoE discovery\n");
        }
        
    }
    
    /* Check for long format */
    retval =sscanf(devnam, FMTSTRING(IFNAMSIZ),addr, addr+1, addr+2,
                   addr+3, addr+4, addr+5,&sid,dev);
    if( retval != 8 ){
        /* Verify the device name , construct ses->local */
        retval = get_sockaddr_ll(devnam,&ses->local);
        if (retval < 0)
            poe_fatal(ses, "client_init_ses: "
                      "Cannot create PF_PACKET socket for PPPoE discovery\n");
        
        ses->state = PADO_CODE;

        create_msg(BCM_PPPOE_CLIENT_STATE_PADO);

        memcpy(&ses->remote, &ses->local, sizeof(struct sockaddr_ll) );
        
        memset( ses->remote.sll_addr, 0xff, ETH_ALEN);
    }else{
        /* long form parsed */

        /* Verify the device name , construct ses->local */
        retval = get_sockaddr_ll(dev,&ses->local);
        if (retval < 0)
            poe_fatal(ses,"client_init_ses(2): "
                      "Cannot create PF_PACKET socket for PPPoE discovery\n");
        ses->state = PADS_CODE;

        create_msg(BCM_PPPOE_CLIENT_STATE_PADS);

        ses->sp.sa_family = AF_PPPOX;
        ses->sp.sa_protocol = PX_PROTO_OE;
        ses->sp.sa_addr.pppoe.sid = sid;
        
        memcpy(&ses->remote, &ses->local, sizeof(struct sockaddr_ll) );
        
        for(; i < ETH_ALEN ; ++i ){
            ses->sp.sa_addr.pppoe.remote[i] = addr[i];
            ses->remote.sll_addr[i]=addr[i];
        }
        memcpy(ses->sp.sa_addr.pppoe.dev, dev, IFNAMSIZ);
        
        
        
    }
    if( retval < 0 )
        error("bad device name: %s",devnam);
    
    
    retval = bind( disc_sock ,
                   (struct sockaddr*)&ses->local,
                   sizeof(struct sockaddr_ll));
    
    
    if( retval < 0 ){
        error("bind to PF_PACKET socket failed: %m");
    }
    
    ses->fd = socket(AF_PPPOX,SOCK_STREAM,PX_PROTO_OE);
    if(ses->fd < 0)
    {
        poe_fatal(ses,"Failed to create PPPoE socket: %m");
    }
    
    
    ses->init_disc = std_init_disc;
    ses->rcv_pado  = std_rcv_pado;
    ses->rcv_pads  = std_rcv_pads;
    ses->rcv_padt  = std_rcv_padt;
    
    /* this should be filter overridable */
    ses->retries = 10;
    
    return ses->fd;
}
Ejemplo n.º 4
0
int setdevname_pppoe(const char *cp)
{
    int ret;
    char dev[IFNAMSIZ+1];
    int addr[ETH_ALEN];
    int sid;
    option_t *opt;
    //info("setdevname_pppoe  //cd===");//add by HQS
    ret =sscanf(cp, FMTSTRING(IFNAMSIZ),addr, addr+1, addr+2,
		addr+3, addr+4, addr+5,&sid,dev);
    if( ret != 8 ){

	ret = get_sockaddr_ll(cp,NULL);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");
	if (ret == 1)
	    strncpy(devnam, cp, sizeof(devnam));
    }else{
	/* long form parsed */
	ret = get_sockaddr_ll(dev,NULL);
        if (ret < 0)
	    fatal("PPPoE: Cannot create PF_PACKET socket for PPPoE discovery\n");

	strncpy(devnam, cp, sizeof(devnam));
	ret = 1;
    }

    info("PPPoE: Use %s for PPPoE discovery\n", devnam);

    if( ret == 1 && the_channel != &pppoe_channel ){

	the_channel = &pppoe_channel;

	lcp_allowoptions[0].neg_accompression = 0;
	lcp_wantoptions[0].neg_accompression = 0;

	lcp_allowoptions[0].neg_asyncmap = 0;
	lcp_wantoptions[0].neg_asyncmap = 0;

	lcp_allowoptions[0].neg_pcompression = 0;
	lcp_wantoptions[0].neg_pcompression = 0;

	ipcp_allowoptions[0].neg_vj=0;
	ipcp_wantoptions[0].neg_vj=0;

	ipcp_allowoptions[0].default_route=1;
	
	/* remove for add -R parameter set default route. by tallest.*/
	//ipcp_wantoptions[0].default_route=0;
	
	for (opt = ipcp_protent.options; opt->name != NULL; ++opt) {
		if (!strncmp(opt->name, "usepeerdns", 10)) {
			*(bool *)(opt->addr) = 1;
			break;
		}
	}
    //info("PPPoE: Use %s for PPPoE discovery 001\n", devnam);

#ifdef CCP_SUPPORT
	ccp_allowoptions[0].deflate = 0 ;
	ccp_wantoptions[0].deflate = 0 ;

	ccp_allowoptions[0].bsd_compress = 0;
	ccp_wantoptions[0].bsd_compress = 0;
#endif
    //info("PPPoE: Use %s for PPPoE discovery 002\n", devnam);
	init_device_pppoe();
    }
    return ret;
}