@@ -24,7 +24,7 @@ For example::
24
24
print("Waiting for connection...")
25
25
while not nic.isconnected():
26
26
time.sleep(1)
27
- print(nic.ifconfig( ))
27
+ print(nic.ipconfig("addr4" ))
28
28
29
29
# now use socket as usual
30
30
import socket
@@ -35,6 +35,8 @@ For example::
35
35
data = s.recv(1000)
36
36
s.close()
37
37
38
+ .. _AbstractnNIC :
39
+
38
40
Common network adapter interface
39
41
================================
40
42
@@ -113,8 +115,49 @@ parameter should be `id`.
113
115
connected to the AP. The list contains tuples of the form
114
116
(MAC, RSSI).
115
117
118
+ .. _AbstractNIC.ipconfig :
119
+ .. method :: AbstractNIC.ipconfig('param')
120
+ AbstractNIC.ipconfig(param=value, ...)
121
+
122
+ Get or set interface-specific IP-configuration interface parameters.
123
+ Supported parameters are the following (availability of a particular
124
+ parameter depends on the port and the specific network interface):
125
+
126
+ * ``dhcp4 `` (``True/False ``) obtain an IPv4 address, gateway and dns
127
+ server via DHCP. This method does not block and wait for an address
128
+ to be obtained. To check if an address was obtained, use the read-only
129
+ property ``has_dhcp4 ``.
130
+ * ``gw4 `` Get/set the IPv4 default-gateway.
131
+ * ``dhcp6 `` (``True/False ``) obtain a DNS server via stateless DHCPv6.
132
+ Obtaining IP Addresses via DHCPv6 is currently not implemented.
133
+ * ``autoconf6 `` (``True/False ``) obtain a stateless IPv6 address via
134
+ the network prefix shared in router advertisements. To check if a
135
+ stateless address was obtained, use the read-only
136
+ property ``has_autoconf6 ``.
137
+ * ``addr4 `` (e.g. ``192.168.0.4/24 ``) obtain the current IPv4 address
138
+ and network mask as ``(ip, subnet) ``-tuple, regardless of how this
139
+ address was obtained. This method can be used to set a static IPv4
140
+ address either as ``(ip, subnet) ``-tuple or in CIDR-notation.
141
+ * ``addr6 `` (e.g. ``fe80::1234:5678 ``) obtain a list of current IPv6
142
+ addresses as ``(ip, state, preferred_lifetime, valid_lifetime) ``-tuple.
143
+ This include link-local, slaac and static addresses.
144
+ ``preferred_lifetime `` and ``valid_lifetime `` represent the remaining
145
+ valid and preferred lifetime of each IPv6 address, in seconds.
146
+ ``state `` indicates the current state of the address:
147
+
148
+ * ``0x08 `` - ``0x0f `` indicates the address is tentative, counting the
149
+ number of probes sent.
150
+ * ``0x10 `` The address is deprecated (but still valid)
151
+ * ``0x30 `` The address is preferred (and valid)
152
+ * ``0x40 `` The address is duplicated and can not be used.
153
+
154
+ This method can be used to set a static IPv6
155
+ address, by setting this parameter to the address, like ``fe80::1234:5678 ``.
156
+
116
157
.. method :: AbstractNIC.ifconfig([(ip, subnet, gateway, dns)])
117
158
159
+ .. note :: This function is deprecated, use `ipconfig()` instead.
160
+
118
161
Get/set IP-level network interface parameters: IP address, subnet mask,
119
162
gateway and DNS server. When called with no arguments, this method returns
120
163
a 4-tuple with the above information. To set the above values, pass a
@@ -127,7 +170,7 @@ parameter should be `id`.
127
170
128
171
Get or set general network interface parameters. These methods allow to work
129
172
with additional parameters beyond standard IP configuration (as dealt with by
130
- `ifconfig () `). These include network-specific and hardware-specific
173
+ `ipconfig () `). These include network-specific and hardware-specific
131
174
parameters. For setting parameters, the keyword argument
132
175
syntax should be used, and multiple parameters can be set at once. For
133
176
querying, a parameter name should be quoted as a string, and only one
@@ -195,6 +238,20 @@ The following are functions available in the network module.
195
238
196
239
The default hostname is typically the name of the board.
197
240
241
+ .. function :: ipconfig('param')
242
+ ipconfig(param=value, ...)
243
+
244
+ Get or set global IP-configuration parameters.
245
+ Supported parameters are the following (availability of a particular
246
+ parameter depends on the port and the specific network interface):
247
+
248
+ * ``dns `` Get/set DNS server. This method can support both, IPv4 and
249
+ IPv6 addresses.
250
+ * ``prefer `` (``4/6 ``) Specify which address type to return, if a domain
251
+ name has both A and AAAA records. Note, that this does not clear the
252
+ local DNS cache, so that any previously obtained addresses might not
253
+ change.
254
+
198
255
.. function :: phy_mode([mode])
199
256
200
257
Get or set the PHY mode.
0 commit comments