-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpppoe-serial-bridge.py
executable file
·49 lines (42 loc) · 1.58 KB
/
pppoe-serial-bridge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3
# PPPoE to serial PPP bridge
# See RFC1662 for ppp serial framing
# See RFC2516 for PPPoE
import argparse
import pppoe.ac
import pppoe.serial
import selectors
import logging
from typing import List
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Bridge serial ppp to ethernet")
parser.add_argument('--ac-name',
default="pppoe-serial-bridge",
help="name of access concentrator")
parser.add_argument('--chatscript', metavar="FILENAME",
default=None, help="path to chatscript")
parser.add_argument('serial_device', metavar='serial-device',
help="path to serial device")
parser.add_argument('service_name', metavar='service-name',
help="name of service")
parser.add_argument('interface', help="ethernet interface")
args = parser.parse_args()
logging.basicConfig(level=logging.INFO)
log = logging.getLogger('pppoe-serial')
sel = selectors.DefaultSelector()
services: List[pppoe.ac.Service] = [
pppoe.serial.SerialService(log, sel, args.service_name,
args.serial_device, args.chatscript),
# Service(log, sel, "null"),
]
acs = [pppoe.ac.AC(log, sel, args.interface, args.ac_name, services)]
try:
while True:
events = sel.select()
for key, mask in events:
key.data(mask)
finally:
# Send PADT for all known sessions
for ac in acs:
ac.shutdown("Shutting down")