Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit a5f55dc

Browse files
committed
Improving documentation
1 parent e4f89d2 commit a5f55dc

18 files changed

Lines changed: 121 additions & 99 deletions

pyof/v0x01/controller2switch/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def unpack(self, buff, offset=0):
230230
Keep buff and offset just for compability with other unpack methods.
231231
232232
Args:
233-
buff: Buffer where data is located.
233+
buff (bytes): Buffer where data is located.
234234
offset (int): Where data stream begins.
235235
"""
236236
self.length = UBInt16()
@@ -397,7 +397,7 @@ def __init__(self, port_no=None, queue_id=None):
397397
Args:
398398
port_no (:class:`int`, :class:`~pyof.v0x01.common.phy_port.Port`):
399399
All ports if :attr:`.Port.OFPP_ALL`.
400-
queue_id (int): All queues if OFPQ_ALL.
400+
queue_id (int): All queues if OFPQ_ALL (``0xfffffff``).
401401
"""
402402
super().__init__()
403403
self.port_no = port_no

pyof/v0x01/controller2switch/stats_reply.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def pack(self, value=None):
3838
StatsReply object, then will return this struct as a binary data.
3939
4040
Returns:
41-
stats_reply_packed (bytes): Binary data with StatsReply packed.
41+
bytes: Binary data with StatsReply packed.
4242
"""
4343
buff = self.body
4444
if not value:

pyof/v0x04/common/action.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ActionExperimenterHeader(GenericStruct):
8585
experimenter = UBInt32()
8686

8787
def __init__(self, length=None, experimenter=None):
88-
"""Action structure for OFPAT_EXPERIMENTER.
88+
"""The constructor just assigns parameters to object attributes.
8989
9090
Args:
9191
experimenter (int): The experimenter field is the Experimenter ID,
@@ -107,7 +107,7 @@ class ActionGroup(GenericStruct):
107107
group_id = UBInt32()
108108

109109
def __init__(self, group_id=None):
110-
"""Action structure for OFPAT_GROUP.
110+
"""The constructor just assigns parameters to object attributes.
111111
112112
Args:
113113
group_id (int): The group_id indicates the group used to process
@@ -135,7 +135,7 @@ class ActionHeader(GenericStruct):
135135
pad = Pad(4)
136136

137137
def __init__(self, action_type=None, length=None):
138-
"""The following constructor parameters are optional.
138+
"""The constructor just assigns parameters to object attributes.
139139
140140
Args:
141141
action_type (~pyof.v0x04.common.action.ActionType):
@@ -160,7 +160,7 @@ class ActionMPLSTTL(GenericStruct):
160160
pad = Pad(3)
161161

162162
def __init__(self, mpls_ttl=None):
163-
"""Action structure for OFPAT_SET_MPLS_TTL.
163+
"""The constructor just assigns parameters to object attributes.
164164
165165
Args:
166166
mpls_ttl (int): The mpls_ttl field is the MPLS TTL to set.
@@ -182,7 +182,7 @@ class ActionNWTTL(GenericStruct):
182182
pad = Pad(3)
183183

184184
def __init__(self, nw_ttl=None):
185-
"""Action structure for OFPAT_SET_NW_TTL.
185+
"""The constructor just assigns parameters to object attributes.
186186
187187
Args:
188188
nw_ttl (int): the TTL address to set in the IP header.
@@ -214,7 +214,7 @@ class ActionOutput(GenericStruct):
214214

215215
def __init__(self, action_type=None, length=None, port=None,
216216
max_length=None):
217-
"""The following constructor parameters are optional.
217+
"""The constructor just assigns parameters to object attributes.
218218
219219
Args:
220220
port (:class:`Port` or :class:`int`): Output port.
@@ -240,7 +240,7 @@ class ActionPopMPLS(GenericStruct):
240240
pad = Pad(2)
241241

242242
def __init__(self, ethertype=None):
243-
"""Action structure for OFPAT_POP_MPLS.
243+
"""The constructor just assigns parameters to object attributes.
244244
245245
Args:
246246
ethertype (int): indicates the Ethertype of the payload.
@@ -262,7 +262,7 @@ class ActionPush(GenericStruct):
262262
pad = Pad(2)
263263

264264
def __init__(self, ethertype=None):
265-
"""Action structure for OFPAT_PUSH_VLAN/MPLS/PBB.
265+
"""The constructor just assigns parameters to object attributes.
266266
267267
Args:
268268
ethertype (int): indicates the Ethertype of the new tag.
@@ -286,7 +286,7 @@ class ActionSetField(GenericStruct):
286286

287287
def __init__(self, length=None, field1=None, field2=None, field3=None,
288288
field4=None):
289-
"""Action structure for OFPAT_SET_FIELD.
289+
"""The constructor just assigns parameters to object attributes.
290290
291291
Args:
292292
length (int): length padded to 64 bits, followed by exactly
@@ -317,7 +317,7 @@ class ActionSetQueue(GenericStruct):
317317
queue_id = UBInt32()
318318

319319
def __init__(self, queue_id=None):
320-
"""Action structure for OFPAT_SET_QUEUE.
320+
"""The constructor just assigns parameters to object attributes.
321321
322322
Args:
323323
queue_id (int): The queue_id send packets to given queue on port.

pyof/v0x04/common/flow_instructions.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ class InstructionApplyAction(Instruction):
112112
actions = ListOfActions()
113113

114114
def __init__(self, actions=None):
115-
"""Instruction structure for OFPIT_APPLY_ACTIONS.
115+
"""The constructor just assigns parameters to object attributes.
116116
117117
Args:
118-
- actions (:class:`~.actions.ListOfActions`): Actions associated
119-
with OFPIT_APPLY_ACTIONS.
118+
actions (:class:`~.actions.ListOfActions`):
119+
Actions associated with OFPIT_APPLY_ACTIONS.
120120
"""
121121
super().__init__(InstructionType.OFPIT_APPLY_ACTIONS)
122122
self.actions = actions if actions else []
@@ -135,11 +135,11 @@ class InstructionClearAction(Instruction):
135135
actions = ListOfActions()
136136

137137
def __init__(self, actions=None):
138-
"""Instruction structure for OFPIT_CLEAR_ACTIONS.
138+
"""The constructor just assigns parameters to object attributes.
139139
140140
Args:
141-
- actions (:class:`~.actions.ListOfActions`): Actions associated
142-
with OFPIT_CLEAR_ACTIONS.
141+
actions (:class:`~.actions.ListOfActions`):
142+
Actions associated with OFPIT_CLEAR_ACTIONS.
143143
"""
144144
super().__init__(InstructionType.OFPIT_CLEAR_ACTIONS)
145145
self.actions = actions if actions else []
@@ -155,11 +155,11 @@ class InstructionGotoTable(Instruction):
155155
pad = Pad(3)
156156

157157
def __init__(self, table_id=Meter.OFPM_ALL):
158-
"""Instruction structure for OFPIT_GOTO_TABLE.
158+
"""The constructor just assigns parameters to object attributes.
159159
160160
Args:
161-
- length (int): Length of this struct in bytes.
162-
- table_id (int): set next table in the lookup pipeline.
161+
length (int): Length of this struct in bytes.
162+
table_id (int): set next table in the lookup pipeline.
163163
"""
164164
super().__init__(InstructionType.OFPIT_GOTO_TABLE)
165165
self.table_id = table_id
@@ -176,10 +176,10 @@ class InstructionMeter(Instruction):
176176
meter_id = UBInt32()
177177

178178
def __init__(self, meter_id=Meter.OFPM_ALL):
179-
"""Instruction structure for OFPIT_METER.
179+
"""The constructor just assigns parameters to object attributes.
180180
181181
Args:
182-
- meter_id (int): Meter instance.
182+
meter_id (int): Meter instance.
183183
"""
184184
super().__init__(InstructionType.OFPIT_METER)
185185
self.meter_id = meter_id
@@ -198,11 +198,11 @@ class InstructionWriteAction(Instruction):
198198
actions = ListOfActions()
199199

200200
def __init__(self, actions=None):
201-
"""Instruction structure for OFPIT_WRITE_ACTIONS.
201+
"""The constructor just assigns parameters to object attributes.
202202
203203
Args:
204-
- actions (:class:`~.actions.ListOfActions`): Actions associated
205-
with OFPIT_WRITE_ACTIONS.
204+
actions (:class:`~.actions.ListOfActions`):
205+
Actions associated with OFPIT_WRITE_ACTIONS.
206206
"""
207207
super().__init__(InstructionType.OFPIT_WRITE_ACTIONS)
208208
self.actions = actions if actions else []
@@ -220,11 +220,11 @@ class InstructionWriteMetadata(Instruction):
220220
metadata_mask = UBInt64()
221221

222222
def __init__(self, metadata=0, metadata_mask=0):
223-
"""Instruction structure for OFPIT_WRITE_METADATA.
223+
"""The constructor just assigns parameters to object attributes.
224224
225225
Args:
226-
- metadata (int): Metadata value to write.
227-
- metadata_mask (int): Metadata write bitmask.
226+
metadata (int): Metadata value to write.
227+
metadata_mask (int): Metadata write bitmask.
228228
"""
229229
super().__init__(InstructionType.OFPIT_WRITE_METADATA)
230230
self.metadata = metadata
@@ -242,6 +242,7 @@ def __init__(self, items=None):
242242
"""The constructor just assigns parameters to object attributes.
243243
244244
Args:
245-
items (Instruction): Instance or a list of instances.
245+
items (:class:`~pyof.v0x04.common.flow_instructions.Instruction`):
246+
Instance or a list of instances.
246247
"""
247248
super().__init__(pyof_class=Instruction, items=items)

pyof/v0x04/common/flow_match.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,11 @@ class OxmExperimenterHeader(OxmHeader):
246246
experimenter = UBInt32()
247247

248248
def __init__(self, experimenter=None):
249-
"""Header for OXM experimenter match fields.
249+
"""The constructor just assigns parameters to object attributes.
250250
251251
Args:
252-
- experimenter (int): Experimenter ID which takes the same form as
253-
in struct ofp_experimenter_header
252+
experimenter (int): Experimenter ID which takes the same form as
253+
in struct ofp_experimenter_header
254254
"""
255255
super().__init__()
256256
self.experimenter = experimenter

pyof/v0x04/common/table_feature.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,13 @@ class InstructionsProperty(Property):
142142

143143
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_INSTRUCTIONS,
144144
instruction_ids=None):
145-
"""Constructor of InstructionProperty receives the parameters bellow.
145+
"""Constructor of NextTablesProperty receives the parameters bellow.
146146
147147
Args:
148148
type(~pyof.v0x04.controller2switch.common.TableFeaturePropType):
149149
Property Type value of this instance.
150-
instruction_ids(ListOfInstruction): List of Instruction instances.
150+
next_table_ids(:class:`ListOfInstruction`):
151+
List of InstructionGotoTable instances.
151152
"""
152153
super().__init__(property_type=property_type)
153154
self.instruction_ids = instruction_ids if instruction_ids else []
@@ -171,8 +172,9 @@ def __init__(self, property_type=TableFeaturePropType.OFPTFPT_NEXT_TABLES,
171172
Args:
172173
type(~pyof.v0x04.controller2switch.common.TableFeaturePropType):
173174
Property Type value of this instance.
174-
next_table_ids(ListOfInstruction): List of InstructionGotoTable
175-
instances.
175+
next_table_ids \
176+
(:class:`~pyof.v0x04.common.flow_instructions.ListOfInstruction`):
177+
List of InstructionGotoTable instances.
176178
"""
177179
super().__init__(property_type)
178180
self.next_table_ids = next_table_ids

pyof/v0x04/controller2switch/common.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ def __init__(self, packet_count=None, byte_count=None):
234234
"""The constructor just assigns parameters to object attributes.
235235
236236
Args:
237-
packet_count: Number of packets processed by bucket.
238-
byte_count: Number of bytes processed by bucket.
237+
packet_count (int): Number of packets processed by bucket.
238+
byte_count (int): Number of bytes processed by bucket.
239239
"""
240240
super().__init__()
241241
self.packet_count = packet_count
@@ -445,14 +445,13 @@ class InstructionsProperty(Property):
445445

446446
def __init__(self, property_type=TableFeaturePropType.OFPTFPT_INSTRUCTIONS,
447447
instruction_ids=None):
448-
"""Constructor of InstructionProperty receives the parameters bellow.
448+
r"""Constructor of InstructionProperty receives the parameters bellow.
449449
450450
Args:
451451
type(~pyof.v0x04.controller2switch.common.TableFeaturePropType):
452452
Property Type value of this instance.
453-
instruction_ids
454-
(~pyof.v0x04.common.flow_instructions.ListOfInstruction):
455-
List of Instruction instances.
453+
instruction_ids (:class:`ListOfInstruction`):
454+
List of Instruction instances.
456455
"""
457456
super().__init__(property_type=property_type)
458457
self.instruction_ids = instruction_ids if instruction_ids else []
@@ -476,9 +475,8 @@ def __init__(self, property_type=TableFeaturePropType.OFPTFPT_NEXT_TABLES,
476475
Args:
477476
type(~pyof.v0x04.controller2switch.common.TableFeaturePropType):
478477
Property Type value of this instance.
479-
next_table_ids
480-
(~pyof.v0x04.common.flow_instructions.ListOfInstruction):
481-
List of InstructionGotoTable instances.
478+
next_table_ids (:class:`ListOfInstruction`):
479+
List of InstructionGotoTable instances.
482480
"""
483481
super().__init__(property_type)
484482
self.next_table_ids = next_table_ids
@@ -591,16 +589,16 @@ def __init__(self, table_id=Table.OFPTT_ALL, name="",
591589
592590
Args:
593591
table_id(int): Indetifier of table.The default value
594-
OFPTT_ALL(0xff) will apply the configuration to all tables in
595-
the switch.
592+
OFPTT_ALL(``0xff``) will apply the configuration to all tables
593+
in the switch.
596594
name(Char): Characters representing the table name.
597595
metadata_match(int): Indicate the bits of the metadata field that
598-
the table can match on.The default value 0xFFFFFFFFFFFFFFFF
596+
the table can match on.The default value ``0xFFFFFFFFFFFFFFFF``
599597
indicates that the table can match the full metadata field.
600598
metadata_write(int): Indicates the bits of the metadata field that
601599
the table can write using the OFPIT_WRITE_METADATA instruction.
602-
The default value 0xFFFFFFFFFFFFFFFF indicates that the table
603-
can write the full metadata field.
600+
The default value ``0xFFFFFFFFFFFFFFFF`` indicates that the
601+
table can write the full metadata field.
604602
config(int): Field reseved for future use.
605603
max_entries(int): Describe the maximum number of flow entries that
606604
can be inserted into that table.

pyof/v0x04/controller2switch/get_async_reply.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ def __init__(self, xid=None, packet_in_mask1=None, packet_in_mask2=None,
2727
2828
Args:
2929
xid (int): xid to be used on the message header.
30-
packet_in_mask1
30+
packet_in_mask1 \
3131
(~pyof.v0x04.asynchronous.packet_in.PacketInReason):
3232
A instance of PacketInReason
33-
packet_in_mask2
33+
packet_in_mask2 \
3434
(~pyof.v0x04.asynchronous.packet_in.PacketInReason):
3535
A instance of PacketInReason
36-
port_status_mask1
36+
port_status_mask1 \
3737
(~pyof.v0x04.asynchronous.port_status.PortReason):
3838
A instance of PortReason
39-
port_status_mask2
39+
port_status_mask2 \
4040
(~pyof.v0x04.asynchronous.port_status.PortReason):
4141
A instance of PortReason
42-
flow_removed_mask1
42+
flow_removed_mask1 \
4343
(~pyof.v0x04.asynchronous.flow_removed.FlowRemoved):
4444
A instance of FlowRemoved.
45-
flow_removed_mask2
45+
flow_removed_mask2 \
4646
(~pyof.v0x04.asynchronous.flow_removed.FlowRemoved):
4747
A instance of FlowRemoved.
4848
"""

pyof/v0x04/controller2switch/group_mod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class Group(IntEnum):
14-
"""Group numbering. Groups can use any number up to OFPG_MAX."""
14+
"""Group numbering. Groups can use any number up to attr:`OFPG_MAX`."""
1515

1616
#: Last usable group number.
1717
OFPG_MAX = 0xffffff00

0 commit comments

Comments
 (0)