Skip to content

Commit 6a50eb7

Browse files
committed
Working on examples.
1 parent 4fa4c2f commit 6a50eb7

File tree

2 files changed

+35
-31
lines changed

2 files changed

+35
-31
lines changed

examples/icmp_echo_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,35 +223,35 @@ def _thread__client__receiver(self) -> None:
223223
"stack__mac_address",
224224
type=ClickTypeMacAddress(),
225225
default=None,
226-
help="MAC address to be assigned to the interface.",
226+
help="MAC address to be assigned to the stack interface.",
227227
)
228228
@click.option(
229229
"--stack-ip6-address",
230230
"stack__ip6_host",
231231
type=ClickTypeIp6Host(),
232232
default=None,
233-
help="IPv6 address/mask to be assigned to the interface.",
233+
help="IPv6 address/mask to be assigned to the stack interface.",
234234
)
235235
@click.option(
236236
"--stack-ip6-gateway",
237237
"stack__ip6_gateway",
238238
type=ClickTypeIp6Address(),
239239
default=None,
240-
help="IPv6 gateway address to be assigned to the interface.",
240+
help="IPv6 gateway address to be assigned to the stack interface.",
241241
)
242242
@click.option(
243243
"--stack-ip4-address",
244244
"stack__ip4_host",
245245
type=ClickTypeIp4Host(),
246246
default=None,
247-
help="IPv4 address/mask to be assigned to the interface.",
247+
help="IPv4 address/mask to be assigned to the stack interface.",
248248
)
249249
@click.option(
250250
"--stack-ip4-gateway",
251251
"stack__ip4_gateway",
252252
type=ClickTypeIp4Address(),
253253
default=None,
254-
help="IPv4 gateway address to be assigned to the interface.",
254+
help="IPv4 gateway address to be assigned to the stack interface.",
255255
)
256256
@click.argument(
257257
"remote_ip_address",

examples/run_stack.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -55,73 +55,77 @@
5555

5656
@click.command()
5757
@click.option(
58-
"--interface",
58+
"--stack-interface",
59+
"stack__interface",
5960
default="tap7",
6061
help="Name of the interface to be used by the stack.",
6162
)
6263
@click.option(
63-
"--mac-address",
64+
"--stack-mac-address",
65+
"stack__mac_address",
6466
type=ClickTypeMacAddress(),
6567
default=None,
66-
help="MAC address to be assigned to the interface.",
68+
help="MAC address to be assigned to the stack interface.",
6769
)
6870
@click.option(
6971
"--ip6-address",
70-
"ip6_host",
72+
"stack__ip6_host",
7173
type=ClickTypeIp6Host(),
7274
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.",
7476
)
7577
@click.option(
7678
"--ip6-gateway",
79+
"stack__ip6_gateway",
7780
type=ClickTypeIp6Address(),
7881
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.",
8083
)
8184
@click.option(
8285
"--ip4-address",
83-
"ip4_host",
86+
"stack__ip4_host",
8487
type=ClickTypeIp4Host(),
8588
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.",
8790
)
8891
@click.option(
8992
"--ip4-gateway",
93+
"stack__ip4_gateway",
9094
type=ClickTypeIp4Address(),
9195
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.",
9397
)
9498
def cli(
9599
*,
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,
102106
) -> None:
103107
"""
104108
Start PyTCP stack and stop it when user presses Ctrl-C.
105109
"""
106110

107-
if ip6_host:
108-
ip6_host.gateway = ip6_gateway
111+
if stack__ip6_host:
112+
stack__ip6_host.gateway = stack__ip6_gateway
109113

110-
if ip4_host:
111-
ip4_host.gateway = ip4_gateway
114+
if stack__ip4_host:
115+
stack__ip4_host.gateway = stack__ip4_gateway
112116

113117
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,
118122
)
119123

124+
stack.start()
125+
120126
try:
121-
stack.start()
122127
while True:
123-
time.sleep(60)
124-
128+
time.sleep(1)
125129
except KeyboardInterrupt:
126130
stack.stop()
127131

0 commit comments

Comments
 (0)