PPP notifier support is now a compile time option

However, as of now, the notify() function is empty, so it requires
some work if someone want to use it.

The notify feature allows someone to be able to follow the
state of the PPP stack (auth ok, ipcp up, initialise, ...), this
is like the callback feature set by pppOverEthernetOpen() and others,
but with more details.
This commit is contained in:
Sylvain Rochet
2012-06-02 14:48:04 +02:00
parent 55c1ec2925
commit 6727c43441
7 changed files with 69 additions and 5 deletions

View File

@@ -203,12 +203,14 @@ int (*allowed_address_hook) __P((u_int32_t addr)) = NULL;
void (*multilink_join_hook) __P((void)) = NULL;
#endif
#if PPP_NOTIFY
/* A notifier for when the peer has authenticated itself,
and we are proceeding to the network phase. */
struct notifier *auth_up_notifier = NULL;
/* A notifier for when the link goes down. */
struct notifier *link_down_notifier = NULL;
#endif /* PPP_NOTIFY */
/*
* Option variables.
@@ -567,7 +569,9 @@ void start_link(unit)
char *msg;
status = EXIT_NEGOTIATION_FAILED;
#if PPP_NOTIFY
new_phase(PHASE_SERIALCONN);
#endif /* PPP_NOTIFY */
hungup = 0;
devfd = the_channel->connect();
@@ -603,18 +607,24 @@ void start_link(unit)
notice("Starting negotiation on %s", ppp_devnam);
add_fd(fd_ppp);
#if PPP_NOTIFY
new_phase(PHASE_ESTABLISH);
#endif /* PPP_NOTIFY */
lcp_lowerup(0);
return;
disconnect:
#if PPP_NOTIFY
new_phase(PHASE_DISCONNECT);
#endif /* PPP_NOTIFY */
if (the_channel->disconnect)
the_channel->disconnect();
fail:
#if PPP_NOTIFY
new_phase(PHASE_DEAD);
#endif /* PPP_NOTIFY */
if (the_channel->cleanup)
(*the_channel->cleanup)();
}
@@ -630,7 +640,9 @@ link_terminated(unit)
{
if (phase == PHASE_DEAD || phase == PHASE_MASTER)
return;
#if PPP_NOTIFY
new_phase(PHASE_DISCONNECT);
#endif /* PPP_NOTIFY */
#if 0 /* UNUSED */
if (pap_logout_hook) {
@@ -647,6 +659,10 @@ link_terminated(unit)
lcp_lowerdown(0);
#if PPP_NOTIFY
new_phase(PHASE_DEAD);
#endif /* PPP_NOTIFY */
#if 0
/*
* Delete pid files before disestablishing ppp. Otherwise it
@@ -702,12 +718,16 @@ void
link_down(unit)
int unit;
{
#if PPP_NOTIFY
notify(link_down_notifier, 0);
#endif /* #if PPP_NOTIFY */
if (!doing_multilink) {
upper_layers_down(unit);
#if PPP_NOTIFY
if (phase != PHASE_DEAD && phase != PHASE_MASTER)
new_phase(PHASE_ESTABLISH);
#endif /* PPP_NOTIFY */
}
/* XXX if doing_multilink, should do something to stop
network-layer traffic on the link */
@@ -796,7 +816,9 @@ link_established(unit)
}
#endif /* UNUSED */
#if PPP_NOTIFY
new_phase(PHASE_AUTHENTICATE);
#endif /* PPP_NOTIFY */
auth = 0;
#if EAP_SUPPORT
if (go->neg_eap) {
@@ -860,6 +882,7 @@ network_phase(unit)
notice("peer from calling number %q authorized", remote_number);
#endif /* UNUSED */
#if PPP_NOTIFY
/*
* If the peer had to authenticate, notify it now.
*/
@@ -876,13 +899,16 @@ network_phase(unit)
) {
notify(auth_up_notifier, 0);
}
#endif /* PPP_NOTIFY */
#if CBCP_SUPPORT
/*
* If we negotiated callback, do it now.
*/
if (go->neg_cbcp) {
#if PPP_NOTIFY
new_phase(PHASE_CALLBACK);
#endif /* PPP_NOTIFY */
(*cbcp_protent.open)(unit);
return;
}
@@ -914,7 +940,9 @@ start_networks(unit)
int mppe_required;
#endif /* MPPE */
#if PPP_NOTIFY
new_phase(PHASE_NETWORK);
#endif /* PPP_NOTIFY */
#ifdef HAVE_MULTILINK
if (multilink) {
@@ -1165,7 +1193,9 @@ np_up(unit, proto)
*/
status = EXIT_OK;
unsuccess = 0;
#if PPP_NOTIFY
new_phase(PHASE_RUNNING);
#endif /* PPP_NOTIFY */
#if 0 /* UNUSED */
if (idle_time_hook != 0)
@@ -1211,8 +1241,10 @@ np_down(unit, proto)
UNTIMEOUT(connect_time_expired, NULL);
#ifdef MAXOCTETS
UNTIMEOUT(check_maxoctets, NULL);
#endif
#endif
#if PPP_NOTIFY
new_phase(PHASE_NETWORK);
#endif /* PPP_NOTIFY */
}
}