2022-09-25 10:54:31 +00:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, lib
|
|
|
|
, ppp
|
|
|
|
, pppoe
|
2022-09-25 20:12:23 +00:00
|
|
|
, writeAshScript
|
2023-02-25 22:53:06 +00:00
|
|
|
, serviceFns
|
2022-09-25 10:54:31 +00:00
|
|
|
} :
|
2023-08-10 21:53:45 +00:00
|
|
|
{ interface, ppp-options }:
|
2022-09-25 10:54:31 +00:00
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun;
|
2024-07-01 22:32:37 +00:00
|
|
|
lcp-echo-interval = 4;
|
|
|
|
lcp-echo-failure = 3;
|
2023-08-27 22:20:58 +00:00
|
|
|
name = "${interface.name}.pppoe";
|
2022-09-25 20:12:23 +00:00
|
|
|
ip-up = writeAshScript "ip-up" {} ''
|
2023-02-25 22:53:06 +00:00
|
|
|
. ${serviceFns}
|
2023-03-03 23:06:18 +00:00
|
|
|
(in_outputs ${name}
|
2023-02-25 22:53:06 +00:00
|
|
|
echo $1 > ifname
|
|
|
|
echo $2 > tty
|
|
|
|
echo $3 > speed
|
|
|
|
echo $4 > address
|
|
|
|
echo $5 > peer-address
|
|
|
|
echo $DNS1 > ns1
|
|
|
|
echo $DNS2 > ns2
|
2022-09-25 20:12:23 +00:00
|
|
|
)
|
|
|
|
echo >/proc/self/fd/10
|
|
|
|
'';
|
2023-05-24 22:01:50 +00:00
|
|
|
ip6-up = writeAshScript "ip6-up" {} ''
|
|
|
|
. ${serviceFns}
|
|
|
|
(in_outputs ${name}
|
|
|
|
echo $4 > ipv6-address
|
|
|
|
echo $5 > ipv6-peer-address
|
|
|
|
)
|
|
|
|
echo >/proc/self/fd/10
|
|
|
|
'';
|
2022-09-25 20:12:23 +00:00
|
|
|
ppp-options' = ppp-options ++ [
|
|
|
|
"ip-up-script" ip-up
|
2023-05-24 22:01:50 +00:00
|
|
|
"ipv6-up-script" ip6-up
|
2022-09-25 20:12:23 +00:00
|
|
|
"ipparam" name
|
|
|
|
"nodetach"
|
2023-02-25 20:31:41 +00:00
|
|
|
"usepeerdns"
|
2024-07-01 22:32:37 +00:00
|
|
|
"lcp-echo-interval" (builtins.toString lcp-echo-interval)
|
|
|
|
"lcp-echo-failure" (builtins.toString lcp-echo-failure)
|
2022-09-27 21:57:06 +00:00
|
|
|
"logfd" "2"
|
2022-09-25 20:12:23 +00:00
|
|
|
];
|
|
|
|
in
|
|
|
|
longrun {
|
|
|
|
inherit name;
|
2023-08-27 22:20:58 +00:00
|
|
|
run = ''
|
2024-07-01 22:32:37 +00:00
|
|
|
. ${serviceFns}
|
|
|
|
echo Starting pppoe, pppd pid is $$
|
|
|
|
exec ${ppp}/bin/pppd pty "${pppoe}/bin/pppoe -T ${builtins.toString (4 * lcp-echo-interval)} -I $(output ${interface} ifname)" ${lib.concatStringsSep " " ppp-options'}
|
2023-08-27 22:20:58 +00:00
|
|
|
'';
|
2022-09-25 20:12:23 +00:00
|
|
|
notification-fd = 10;
|
2024-07-01 22:32:37 +00:00
|
|
|
timeout-up = (10 + lcp-echo-failure * lcp-echo-interval) * 1000;
|
2022-09-25 20:12:23 +00:00
|
|
|
dependencies = [ interface ];
|
2022-09-25 10:54:31 +00:00
|
|
|
}
|