Skip to content

Commit

Permalink
loosely coupled refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Oct 15, 2020
1 parent 2bf0bf6 commit a30b021
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 118 deletions.
119 changes: 119 additions & 0 deletions capture/capture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
openapi: 3.1.0

info:
title: Capture models
version: ^0.0.0

components:
schemas:
Capture:
description: >-
Container for capture settings.
type: object
required: [name, choice]
properties:
name: '../common/common.yaml#/components/x-inline/UniqueName'
port_names:
description: >-
The unique names of ports that the capture settings will apply to.
type: array
items:
type: string
x-constraint:
- '/components/schemas/Port/properties/name'
choice:
description: >-
The type of filter.
type: string
enum: [basic, pcap]
basic:
description: >-
An array of basic filters.
The filters supported are source address, destination address and
custom.
type: array
items:
$ref: '#/components/schemas/Capture.BasicFilter'
pcap:
description: >-
The content of this property must be of pcap filter syntax.
https://www.tcpdump.org/manpages/pcap-filter.7.html
type: string
enable:
description: >-
Enable capture on the port.
type: boolean
default: True
overwrite:
description: >-
Overwrite the capture buffer.
type: boolean
default: false
format:
description: >-
The format of the capture file.
type: string
enum: [pcap, pcapng]
default: pcap

Capture.BasicFilter:
description: >-
A container for different types of basic capture filters.
type: object
required: [choice]
properties:
choice:
type: string
enum: [mac_address, custom]
mac_address:
$ref: '#/components/schemas/Capture.MacAddressFilter'
custom:
$ref: '#/components/schemas/Capture.CustomFilter'
and_operator:
type: boolean
default: true
not_operator:
type: boolean
default: false

Capture.MacAddressFilter:
description: >-
A container for a mac address capture filter.
type: object
required: [mac, filter]
properties:
mac:
description: >-
The type of mac address filters.
This can be either source or destination.
type: string
enum: [source, destination]
filter:
description: >-
The value of the mac address.
type: string
mask:
description: >-
The value of the mask to be applied to the mac address.
type: string

Capture.CustomFilter:
description: >-
A container for a custom capture filter.
type: object
required: [filter, offset]
properties:
filter:
description: >-
The value to filter on.
type: string
mask:
description: >-
The mask to be applied to the filter.
type: string
offset:
description: >-
The offset in the packet to filter at.
type: integer


24 changes: 18 additions & 6 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ components:
type: array
items:
$ref: '../port/port.yaml#/components/schemas/Port'
flows:
description: >-
The flows that will be configured on the traffic generator.
type: array
items:
$ref: '../flow/flow.yaml#/components/schemas/Flow'
layer1:
description: >-
The layer1 settings that will be configured on the traffic generator.
type: array
items:
$ref: '../layer1/layer1.yaml#/components/schemas/Layer1'
captures:
description: >-
The capture settings that will be configured on the traffic generator.
type: array
items:
$ref: '../capture/capture.yaml#/components/schemas/Capture'
devices:
description: >-
The emulated device settings that will be configured on the traffic generator.
type: array
items:
$ref: '../device/device.yaml#/components/schemas/Device'
flows:
description: >-
The flows that will be configured on the traffic generator.
type: array
items:
$ref: '../flow/flow.yaml#/components/schemas/Flow'
options:
$ref: '#/components/schemas/Config.Options'

Expand Down
18 changes: 13 additions & 5 deletions device/device.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.1.0

info:
title: Emulated device model
title: Emulated device/interface models
version: ^0.0.0

components:
Expand All @@ -10,14 +10,17 @@ components:
description: >-
A container for emulated protocol devices.
type: object
required: [name, choice]
required: [name, container_name, choice]
properties:
name: '../common/common.yaml#/components/x-inline/UniqueName'
choice:
container_name:
description: >-
The type of emulated protocol interface or device.
The unique name of a Port or Lag object that will contain the
emulated interfaces and/or devices.
type: string
enum: [ethernet, ipv4, ipv6, bgpv4]
x-constraint:
- '/components/schemas/Port/properties/name'
- '/components/schemas/Lag/properties/name'
device_count:
description: >-
The number of emulated protocol devices or interfaces per port.
Expand All @@ -39,6 +42,11 @@ components:
default: 1
minimum: 1
maximum: 100000000
choice:
description: >-
The type of emulated protocol interface or device.
type: string
enum: [ethernet, ipv4, ipv6, bgpv4]
ethernet:
$ref: './ethernet.yaml#/components/schemas/Device.Ethernet'
ipv4:
Expand Down
107 changes: 0 additions & 107 deletions port/port.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,113 +30,6 @@ components:
Get the configured location state by using the /results/port API.
type: string
devices:
type: array
items:
$ref: '../device/device.yaml#/components/schemas/Device'
capture:
$ref: '#/components/schemas/Port.Capture'

Port.Capture:
description: >-
Container for capture filter information.
type: object
required: [choice]
properties:
choice:
description: >-
The type of filter.
type: string
enum: [basic, pcap]
basic:
description: >-
An array of basic filters.
The filters supported are source address, destination address and
custom.
type: array
items:
$ref: '#/components/schemas/Port.BasicFilter'
pcap:
description: >-
The content of this property must be of pcap filter syntax.
https://www.tcpdump.org/manpages/pcap-filter.7.html
type: string
enable:
description: >-
Enable capture on the port.
type: boolean
default: True
overwrite:
description: >-
Overwrite the capture buffer.
type: boolean
default: false
format:
description: >-
The format of the capture file.
type: string
enum: [pcap, pcapng]
default: pcap

Port.BasicFilter:
description: >-
A container for different types of basic capture filters.
type: object
required: [choice]
properties:
choice:
type: string
enum: [mac_address, custom]
mac_address:
$ref: '#/components/schemas/Port.MacAddressFilter'
custom:
$ref: '#/components/schemas/Port.CustomFilter'
and_operator:
type: boolean
default: true
not_operator:
type: boolean
default: false

Port.MacAddressFilter:
description: >-
A container for a mac address capture filter.
type: object
required: [mac, filter]
properties:
mac:
description: >-
The type of mac address filters.
This can be either source or destination.
type: string
enum: [source, destination]
filter:
description: >-
The value of the mac address.
type: string
mask:
description: >-
The value of the mask to be applied to the mac address.
type: string

Port.CustomFilter:
description: >-
A container for a custom capture filter.
type: object
required: [filter, offset]
properties:
filter:
description: >-
The value to filter on.
type: string
mask:
description: >-
The mask to be applied to the filter.
type: string
offset:
description: >-
The offset in the packet to filter at.
type: integer

Port.Options:
description: >-
Expand Down

0 comments on commit a30b021

Please sign in to comment.