Subject: Re: poor man's demand-dial
To: None <current-users@NetBSD.ORG>
From: Greg A. Woods <woods@kuma.web.net>
List: current-users
Date: 03/20/1995 11:10:53
[ On Mon, March 20, 1995 at 04:05:29 (-0500), Roland McGrath wrote: ]
> Subject: poor man's demand-dial
>
I've been reading these posts with interest, but I'm confused that
nobody's thought of an obvious solution.....
By using a special line discipline, control of the PPP connection can be
done via special ioctl()'s, and the messy stuff can
For example (some ugly pseudo-code):
while (dialing) {
if ((ppp_if = allocate_ppp_interface(dest_host)) == EOF) {
print_no_interface_msg();
continue;
}
if (interface_config(ppp_if) == EOF) {
print_interface_config_failed_msg();
continue;
}
wait_for_packet_on_ppp_if(ppp_if);
if ((outdial_port = find_free_port(ppp_if)) == EOF) {
print_ports_busy_msg();
cleanup();
continue;
}
if (do_dial(outdial_port) == EOF) {
print_dial_failed_msg();
cleanup();
continue;
}
if (do_login(outdial_port) == EOF) {
print_login_failed_msg();
cleanup();
continue;
}
old_line_discipline = LINE0;
(void) ioctl(outdial_port.fd, TIOCGETD, &old_line_discipline);
ppp_line_discipline = PPP0;
if (ioctl(outdial_port.fd, TIOCSETD, &ppp_line_discipline) == EOF) {
print_setd_failed_msg();
cleanup();
continue;
}
/* here we hand the connection over to the ppp interface */
if (ioctl(outdial_port.fd, PPP_START_PROTO, &ppp_if) == EOF) {
print_cant_ppp_on_if_msg();
cleanup();
contine;
}
/* now we wait for the interface to drop the connection,
* either through losing the line, or through a manual
* "ifconfig pppIF down", or by giving it up because it
* has been idle for too long....
*/
if (ioctl(outdial_port.fd, PPP_WAIT_END_OF_SESS) == EOF) {
print_wait_eos_failed_msg();
cleanup();
continue;
}
if (ioctl(outdial_port.fd, TIOSETD, &old_line_discipline) == EOF) {
print_setd_old_ld_failed_msg();
cleanup();
continue;
}
if (close(outdial_port.fd) == EOF) {
print_cant_hangup_msg();
cleanup();
continue;
}
continue;
}
--
Greg A. Woods
+1 416 443-1734 VE3TCP robohack!woods
Planix, Inc. <woods@planix.com>; Secrets Of The Weird <woods@weird.com>