|
55 | 55 |
|
56 | 56 | @click.command() |
57 | 57 | @click.option( |
58 | | - "--interface", |
| 58 | + "--stack-interface", |
| 59 | + "stack__interface", |
59 | 60 | default="tap7", |
60 | 61 | help="Name of the interface to be used by the stack.", |
61 | 62 | ) |
62 | 63 | @click.option( |
63 | | - "--mac-address", |
| 64 | + "--stack-mac-address", |
| 65 | + "stack__mac_address", |
64 | 66 | type=ClickTypeMacAddress(), |
65 | 67 | default=None, |
66 | | - help="MAC address to be assigned to the interface.", |
| 68 | + help="MAC address to be assigned to the stack interface.", |
67 | 69 | ) |
68 | 70 | @click.option( |
69 | 71 | "--ip6-address", |
70 | | - "ip6_host", |
| 72 | + "stack__ip6_host", |
71 | 73 | type=ClickTypeIp6Host(), |
72 | 74 | default=None, |
73 | | - help="IPv6 address/mask to be assigned to the interface.", |
| 75 | + help="IPv6 address/mask to be assigned to the stack interface.", |
74 | 76 | ) |
75 | 77 | @click.option( |
76 | 78 | "--ip6-gateway", |
| 79 | + "stack__ip6_gateway", |
77 | 80 | type=ClickTypeIp6Address(), |
78 | 81 | default=None, |
79 | | - help="IPv6 gateway address to be assigned to the interface.", |
| 82 | + help="IPv6 gateway address to be assigned to the stack interface.", |
80 | 83 | ) |
81 | 84 | @click.option( |
82 | 85 | "--ip4-address", |
83 | | - "ip4_host", |
| 86 | + "stack__ip4_host", |
84 | 87 | type=ClickTypeIp4Host(), |
85 | 88 | default=None, |
86 | | - help="IPv4 address/mask to be assigned to the interface.", |
| 89 | + help="IPv4 address/mask to be assigned to the stack interface.", |
87 | 90 | ) |
88 | 91 | @click.option( |
89 | 92 | "--ip4-gateway", |
| 93 | + "stack__ip4_gateway", |
90 | 94 | type=ClickTypeIp4Address(), |
91 | 95 | default=None, |
92 | | - help="IPv4 gateway address to be assigned to the interface.", |
| 96 | + help="IPv4 gateway address to be assigned to the stack interface.", |
93 | 97 | ) |
94 | 98 | def cli( |
95 | 99 | *, |
96 | | - interface: str, |
97 | | - mac_address: MacAddress | None, |
98 | | - ip6_host: Ip6Host | None, |
99 | | - ip6_gateway: Ip6Address | None, |
100 | | - ip4_host: Ip4Host | None, |
101 | | - ip4_gateway: Ip4Address | None, |
| 100 | + stack__interface: str, |
| 101 | + stack__mac_address: MacAddress | None, |
| 102 | + stack__ip6_host: Ip6Host | None, |
| 103 | + stack__ip6_gateway: Ip6Address | None, |
| 104 | + stack__ip4_host: Ip4Host | None, |
| 105 | + stack__ip4_gateway: Ip4Address | None, |
102 | 106 | ) -> None: |
103 | 107 | """ |
104 | 108 | Start PyTCP stack and stop it when user presses Ctrl-C. |
105 | 109 | """ |
106 | 110 |
|
107 | | - if ip6_host: |
108 | | - ip6_host.gateway = ip6_gateway |
| 111 | + if stack__ip6_host: |
| 112 | + stack__ip6_host.gateway = stack__ip6_gateway |
109 | 113 |
|
110 | | - if ip4_host: |
111 | | - ip4_host.gateway = ip4_gateway |
| 114 | + if stack__ip4_host: |
| 115 | + stack__ip4_host.gateway = stack__ip4_gateway |
112 | 116 |
|
113 | 117 | stack.init( |
114 | | - *stack.initialize_interface(interface), |
115 | | - mac_address=mac_address, |
116 | | - ip6_host=ip6_host, |
117 | | - ip4_host=ip4_host, |
| 118 | + *stack.initialize_interface(stack__interface), |
| 119 | + mac_address=stack__mac_address, |
| 120 | + ip6_host=stack__ip6_host, |
| 121 | + ip4_host=stack__ip4_host, |
118 | 122 | ) |
119 | 123 |
|
| 124 | + stack.start() |
| 125 | + |
120 | 126 | try: |
121 | | - stack.start() |
122 | 127 | while True: |
123 | | - time.sleep(60) |
124 | | - |
| 128 | + time.sleep(1) |
125 | 129 | except KeyboardInterrupt: |
126 | 130 | stack.stop() |
127 | 131 |
|
|
0 commit comments