mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
improved PPP default interface management, added ppp_set_default() API call
This commit is contained in:
parent
78565026ac
commit
9e021cd1a8
@ -58,6 +58,26 @@ ppp_pcb *pppapi_new(void) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call ppp_set_default() inside the tcpip_thread context.
|
||||
*/
|
||||
static void pppapi_do_ppp_set_default(struct pppapi_msg_msg *msg) {
|
||||
ppp_set_default(msg->ppp);
|
||||
TCPIP_PPPAPI_ACK(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call ppp_set_default() in a thread-safe way by running that function inside the
|
||||
* tcpip_thread context.
|
||||
*/
|
||||
void pppapi_set_default(ppp_pcb *pcb) {
|
||||
struct pppapi_msg msg;
|
||||
msg.function = pppapi_do_ppp_set_default;
|
||||
msg.msg.ppp = pcb;
|
||||
TCPIP_PPPAPI(&msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call ppp_set_auth() inside the tcpip_thread context.
|
||||
*/
|
||||
|
@ -110,6 +110,7 @@ struct pppapi_msg {
|
||||
|
||||
/* API for application */
|
||||
ppp_pcb *pppapi_new(void);
|
||||
void pppapi_set_default(ppp_pcb *pcb);
|
||||
void pppapi_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd);
|
||||
#if PPPOS_SUPPORT
|
||||
int pppapi_over_serial_open(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx);
|
||||
|
@ -619,9 +619,10 @@ static void ipcp_init(ppp_pcb *pcb) {
|
||||
wo->maxslotindex = MAX_STATES - 1; /* really max index */
|
||||
wo->cflag = 1;
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/* wanting default route by default */
|
||||
/* FIXME: should be configurable */
|
||||
wo->default_route = 1;
|
||||
#endif /* UNUSED */
|
||||
|
||||
/* max slots and slot-id compression are currently hardwired in */
|
||||
/* ppp_if.c to 16 and 1, this needs to be changed (among other */
|
||||
@ -632,12 +633,14 @@ static void ipcp_init(ppp_pcb *pcb) {
|
||||
ao->maxslotindex = MAX_STATES - 1;
|
||||
ao->cflag = 1;
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/*
|
||||
* XXX These control whether the user may use the proxyarp
|
||||
* and defaultroute options.
|
||||
*/
|
||||
ao->proxy_arp = 1;
|
||||
ao->default_route = 1;
|
||||
#endif /* UNUSED */
|
||||
}
|
||||
|
||||
|
||||
@ -1737,10 +1740,12 @@ ip_demand_conf(u)
|
||||
return 0;
|
||||
if (!sifnpmode(pcb, PPP_IP, NPMODE_QUEUE))
|
||||
return 0;
|
||||
#if 0 /* UNUSED */
|
||||
if (wo->default_route)
|
||||
if (sifdefaultroute(pcb, wo->ouraddr, wo->hisaddr,
|
||||
wo->replace_default_route))
|
||||
default_route_set[u] = 1;
|
||||
#endif /* UNUSED */
|
||||
if (wo->proxy_arp)
|
||||
if (sifproxyarp(pcb, wo->hisaddr))
|
||||
proxy_arp_set[u] = 1;
|
||||
@ -1914,11 +1919,13 @@ static void ipcp_up(fsm *f) {
|
||||
#endif
|
||||
sifnpmode(pcb, PPP_IP, NPMODE_PASS);
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/* assign a default route through the interface if required */
|
||||
if (wo->default_route)
|
||||
if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr,
|
||||
wo->replace_default_route))
|
||||
pcb->default_route_set = 1;
|
||||
#endif /* UNUSED */
|
||||
|
||||
/* Make a proxy ARP entry if requested. */
|
||||
if (ho->hisaddr != 0 && wo->proxy_arp)
|
||||
@ -2020,6 +2027,7 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re
|
||||
cifproxyarp(pcb, hisaddr);
|
||||
pcb->proxy_arp_set = 0;
|
||||
}
|
||||
#if 0 /* UNUSED */
|
||||
/* If replacedefaultroute, sifdefaultroute will be called soon
|
||||
* with replacedefaultroute set and that will overwrite the current
|
||||
* default route. This is the case only when doing demand, otherwise
|
||||
@ -2032,6 +2040,7 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re
|
||||
cifdefaultroute(pcb, ouraddr, hisaddr);
|
||||
pcb->default_route_set = 0;
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
cifaddr(pcb, ouraddr, hisaddr);
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,10 @@ typedef struct ipcp_options {
|
||||
unsigned int neg_addr :1; /* Negotiate IP Address? */
|
||||
unsigned int old_addrs :1; /* Use old (IP-Addresses) option? */
|
||||
unsigned int req_addr :1; /* Ask peer to send IP address? */
|
||||
#if 0 /* UNUSED */
|
||||
unsigned int default_route :1; /* Assign default route through interface? */
|
||||
unsigned int replace_default_route :1; /* Replace default route through interface? */
|
||||
#endif /* UNUSED */
|
||||
unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */
|
||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||
unsigned int old_vj :1; /* use old (short) form of VJ option? */
|
||||
@ -85,7 +87,7 @@ typedef struct ipcp_options {
|
||||
unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */
|
||||
unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */
|
||||
unsigned int cflag :1;
|
||||
unsigned int :3; /* 3 bits of padding to round out to 16 bits */
|
||||
unsigned int :5; /* 3 bits of padding to round out to 16 bits */
|
||||
|
||||
u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
|
@ -294,6 +294,10 @@ ppp_pcb *ppp_new(void) {
|
||||
return pcb;
|
||||
}
|
||||
|
||||
void ppp_set_default(ppp_pcb *pcb) {
|
||||
netif_set_default(&pcb->netif);
|
||||
}
|
||||
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, char *user, char *passwd) {
|
||||
|
||||
#if PAP_SUPPORT
|
||||
@ -2190,41 +2194,6 @@ int netif_get_mtu(ppp_pcb *pcb) {
|
||||
return pcb->mtu;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* sifdefaultroute - assign a default route through the address given.
|
||||
*
|
||||
* If the global default_rt_repl_rest flag is set, then this function
|
||||
* already replaced the original system defaultroute with some other
|
||||
* route and it should just replace the current defaultroute with
|
||||
* another one, without saving the current route. Use: demand mode,
|
||||
* when pppd sets first a defaultroute it it's temporary ppp0 addresses
|
||||
* and then changes the temporary addresses to the addresses for the real
|
||||
* ppp connection when it has come up.
|
||||
*/
|
||||
int sifdefaultroute(ppp_pcb *pcb, u32_t ouraddr, u32_t gateway, u8_t replace) {
|
||||
|
||||
LWIP_UNUSED_ARG(ouraddr);
|
||||
LWIP_UNUSED_ARG(gateway);
|
||||
LWIP_UNUSED_ARG(replace);
|
||||
|
||||
netif_set_default(&pcb->netif);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* cifdefaultroute - delete a default route through the address given.
|
||||
*/
|
||||
int cifdefaultroute(ppp_pcb *pcb, u32_t ouraddr, u32_t gateway) {
|
||||
|
||||
LWIP_UNUSED_ARG(ouraddr);
|
||||
LWIP_UNUSED_ARG(gateway);
|
||||
|
||||
netif_set_default(NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* sifproxyarp - Make a proxy ARP entry for the peer.
|
||||
|
@ -294,7 +294,6 @@ struct ppp_pcb_s {
|
||||
unsigned int if_up :1; /* True when the interface is up. */
|
||||
unsigned int pcomp :1; /* Does peer accept protocol compression? */
|
||||
unsigned int accomp :1; /* Does peer accept addr/ctl compression? */
|
||||
unsigned int default_route_set :1; /* Have set up a default route */
|
||||
unsigned int proxy_arp_set :1; /* Have created proxy arp entry */
|
||||
unsigned int ipcp_is_open :1; /* haven't called np_finished() */
|
||||
unsigned int ipcp_is_up :1; /* have called ipcp_up() */
|
||||
@ -310,7 +309,7 @@ struct ppp_pcb_s {
|
||||
#else
|
||||
unsigned int :1; /* 1 bit of padding */
|
||||
#endif /* PPPOS_SUPPORT && VJ_SUPPORT */
|
||||
unsigned int :5; /* 5 bits of padding to round out to 16 bits */
|
||||
unsigned int :6; /* 5 bits of padding to round out to 16 bits */
|
||||
|
||||
ppp_settings settings;
|
||||
|
||||
@ -421,6 +420,12 @@ int ppp_init(void);
|
||||
*/
|
||||
ppp_pcb *ppp_new(void);
|
||||
|
||||
/*
|
||||
* Set a PPP interface as the default network interface
|
||||
* (used to output all packets for which no specific route is found).
|
||||
*/
|
||||
void ppp_set_default(ppp_pcb *pcb);
|
||||
|
||||
/*
|
||||
* Set auth helper, optional, you can either fill ppp_pcb->settings.
|
||||
*
|
||||
|
@ -416,9 +416,6 @@ int sifnpmode(ppp_pcb *pcb, int proto, enum NPmode mode);
|
||||
void netif_set_mtu(ppp_pcb *pcb, int mtu);
|
||||
int netif_get_mtu(ppp_pcb *pcb);
|
||||
|
||||
int sifdefaultroute(ppp_pcb *pcb, u32_t ouraddr, u32_t gateway, u8_t replace);
|
||||
int cifdefaultroute(ppp_pcb *pcb, u32_t ouraddr, u32_t gateway);
|
||||
|
||||
int sifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
int cifproxyarp(ppp_pcb *pcb, u32_t his_adr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user