Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ad25a82
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 23:12:30 2021 +0100

    v0.3.0

commit a2d0765
Merge: 3d91c52 7793b27
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 23:06:31 2021 +0100

    Merge pull request #18 from jamores/feature/readme

    Feature/readme

commit 7793b27
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 23:04:11 2021 +0100

    configuration section

commit 3d91c52
Merge: 1b4b0f8 0db26db
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 22:38:27 2021 +0100

    Merge pull request #17 from jamores/feature/toxini

    Feature/toxini

commit 0db26db
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 22:37:04 2021 +0100

    typo, remove redundant stuff

commit 0d5847c
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 22:30:20 2021 +0100

    cleanup

commit 1b4b0f8
Merge: 1547dec a6a8b4b
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 17:05:21 2021 +0100

    Merge pull request #16 from jamores/feature/examples

    Feature/examples

commit 1547dec
Merge: 16e72b2 ac0b50e
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 17:04:33 2021 +0100

    Merge pull request #15 from jamores/feature/python3

    Feature/python3

commit a6a8b4b
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 3 16:05:52 2021 +0100

    examples executed with py27 and py38

commit c487b24
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 11:27:04 2021 +0100

    enable all examples

commit 7c885a8
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 3 11:26:34 2021 +0100

    correct SOMEIP method_id field

commit 44c0996
Author: Jose Amores <biomol@gmail.com>
Date:   Tue Feb 2 11:32:29 2021 +0100

    examples 101

commit ac0b50e
Author: Jose Amores <biomol@gmail.com>
Date:   Mon Feb 1 15:35:19 2021 +0100

    UTs passing py27 & py38

commit 7ac63df
Author: Jose Amores <biomol@gmail.com>
Date:   Mon Feb 1 12:19:06 2021 +0100

    replace xrange

commit 16e72b2
Merge: eb07683 1f96ee2
Author: Jose Amores <biomol@gmail.com>
Date:   Mon Feb 1 10:09:42 2021 +0100

    Merge pull request #14 from jamores/feature/test

    Feature/test

commit 1f96ee2
Author: Jose Amores <biomol@gmail.com>
Date:   Mon Feb 1 10:05:31 2021 +0100

    some comments

commit 48bed7f
Author: Jose Amores <biomol@gmail.com>
Date:   Mon Feb 1 00:20:25 2021 +0100

    test_sd coverage 100%

commit eb07683
Merge: 74b9953 a1989d9
Author: Jose Amores <biomol@gmail.com>
Date:   Fri Jan 29 16:30:21 2021 +0100

    Merge pull request #13 from jamores/feature/scapy_241

    scapy to v2.4.1 or higher

commit a1989d9
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 16:28:59 2021 +0100

    scapy to v2.4.1 or higher

commit 74b9953
Merge: 8f5a999 a7543f6
Author: Jose Amores <biomol@gmail.com>
Date:   Fri Jan 29 16:06:44 2021 +0100

    Merge pull request #12 from jamores/feature/pytest

    Feature/pytest

commit a7543f6
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 15:56:32 2021 +0100

    remove old UT

commit 6990d56
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 15:43:56 2021 +0100

    pytest with coverage

commit 17a54a1
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 15:04:36 2021 +0100

    someip_sd tests to pytest

commit 57bf441
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 14:58:35 2021 +0100

    sd test to pytest

commit d41cc4a
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 14:46:43 2021 +0100

    someip test collection to pytest

commit f017f3b
Author: jamores <biomol@gmail.com>
Date:   Fri Jan 29 14:46:25 2021 +0100

    pytest-cov working

commit 1ff9b72
Author: Jose Amores <biomol@gmail.com>
Date:   Fri Jan 29 11:40:17 2021 +0100

    pytest skeleton

commit 8f5a999
Merge: 065e99d d71901c
Author: Jose Amores <biomol@gmail.com>
Date:   Thu Mar 21 09:06:04 2019 +0100

    Merge pull request #3 from geynis/feature/someip_tp

    SOME/IP-TP

commit d71901c
Author: Amit Geynis <amit.geynis@argus-sec.com>
Date:   Wed Jan 9 10:49:49 2019 +0200

    1. Added SOME/IP-TP support
    2. Added UT for SOME/IP-TP
    3. PEP 8 code style to the changed files
    4. Increased Version

commit 065e99d
Author: jamores <biomol@gmail.com>
Date:   Tue Dec 25 11:53:52 2018 +0100

    increase version

commit 4489deb
Merge: 4bc8224 435f485
Author: jamores <biomol@gmail.com>
Date:   Sat Dec 22 00:10:20 2018 +0100

    Merge branch 'geynis-AmitG/scapy2.4'

commit 435f485
Author: Amit Geynis <amit.geynis@argus-sec.com>
Date:   Wed Oct 3 10:44:25 2018 +0300

    1. support for scapy 2.4.0 ("explicit" var is instance variable now)
    2. some PEP8 fixes

commit 4bc8224
Author: jamores <biomol@gmail.com>
Date:   Wed Mar 21 23:10:56 2018 +0100

    some typos

commit 4044e06
Merge: cc0708d 039f177
Author: jamores <biomol@gmail.com>
Date:   Wed Mar 21 23:08:00 2018 +0100

    merge readme, contents for release

commit 039f177
Author: jamores <biomol@gmail.com>
Date:   Wed Mar 21 22:59:26 2018 +0100

    alpha release

commit d42bb2b
Author: jamores <biomol@gmail.com>
Date:   Wed Mar 21 22:56:37 2018 +0100

    candidate relase

commit c26acec
Author: jamores <biomol@gmail.com>
Date:   Tue Mar 20 23:07:40 2018 +0100

    SD example

commit 6a30d7b
Author: jamores <biomol@gmail.com>
Date:   Mon Mar 19 23:01:00 2018 +0100

    some examples (initial)

commit 6de2c3a
Author: jamores <biomol@gmail.com>
Date:   Mon Mar 5 23:01:46 2018 +0100

    examples with HTML report

commit b615932
Author: jamores <biomol@gmail.com>
Date:   Mon Mar 5 23:00:44 2018 +0100

    layer binding

commit f63f1a8
Author: jamores <biomol@gmail.com>
Date:   Sat Mar 3 22:49:02 2018 +0100

    sudo UTs mit TOX

commit a9c76bd
Author: jamores <biomol@gmail.com>
Date:   Thu Mar 1 23:26:21 2018 +0100

    examples with UTscapy 101

commit 3814638
Author: jamores <biomol@gmail.com>
Date:   Tue Feb 27 22:34:27 2018 +0100

    UT SD.GetSomeipPacket

commit 672bcd2
Author: jamores <biomol@gmail.com>
Date:   Sun Feb 25 23:10:23 2018 +0100

    UTs look ready

commit 1718051
Author: jamores <biomol@gmail.com>
Date:   Thu Feb 22 23:25:19 2018 +0100

    SD ut

commit dad904f
Author: jamores <biomol@gmail.com>
Date:   Tue Feb 13 22:54:47 2018 +0100

    fields tuple within SD class

commit 5e902e8
Author: jamores <biomol@gmail.com>
Date:   Mon Feb 12 23:36:05 2018 +0100

    better flags

commit 3383844
Author: jamores <biomol@gmail.com>
Date:   Sat Feb 10 23:46:31 2018 +0100

    SD package ready for UT

commit bdc38a2
Author: jamores <biomol@gmail.com>
Date:   Thu Feb 8 23:45:02 2018 +0100

    wheel dist created OK

commit cc0708d
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:35:58 2018 +0100

    readme updated

commit 1b6d691
Merge: 9e0078f 5c31646
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:35:16 2018 +0100

    Merge branch 'develop' of https://github.com/jamores/eth-scapy-someip into develop

commit 3e673ee
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:33:08 2018 +0100

    readme updated

commit 9e0078f
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:31:17 2018 +0100

    SD packet

commit 5c31646
Author: Jose Amores <biomol@gmail.com>
Date:   Wed Feb 7 23:30:23 2018 +0100

    Update README.md

commit 4f5e32a
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:24:06 2018 +0100

    initial readme

commit 2ec0f39
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 23:04:57 2018 +0100

    docs added

commit 4c010fe
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 06:19:23 2018 +0100

    SDOptions UT completed

commit 8ebd7d6
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 01:05:47 2018 +0100

    SD UT : guess payload

commit 4667496
Author: jamores <biomol@gmail.com>
Date:   Wed Feb 7 00:28:38 2018 +0100

    SOME/IP UT, SD.Entries UT

commit 65435d2
Author: jamores <biomol@gmail.com>
Date:   Mon Feb 5 23:13:18 2018 +0100

    SOME/IP ut

commit f5f18bf
Author: jamores <biomol@gmail.com>
Date:   Mon Feb 5 18:52:00 2018 +0100

    initial commit, SOME/IP UT
  • Loading branch information
jamores committed Feb 4, 2021
1 parent 148fd45 commit c82985f
Show file tree
Hide file tree
Showing 19 changed files with 1,125 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.tox
.coverage
*.pyc
*.swp
htmlcov/
reports/
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# eth-scapy-someip
Automotive Ethernet SOME/IP-SD Scapy protocol

## 1. Description
**eth-scapy-someip** is a Scapy extension implementing Autosar's SOME/IP-SD protocol, giving any developer with Python knowledge an essential and powerful tool to develop Automotive Ethernet applications for the automotive world.

Test automation, traffic generation, ECU development support or just **_for fun_** fiddling is all possible with *eth-scapy-someip*.

## 2. Configuration

### 2.1 VLAN
In order to configure VLAN (IEEE 802.1q) tagging in your linux machine, Ubuntu's wiki is a good reference : https://wiki.ubuntu.com/vlan.

### 2.1 Interface configuration (Linux)
Feel free to choose your preferred network topology in order to start fiddling with SOME/IP-SD. In our case, we opted for a couple of USB-Ethernet adaptors but that's not strictly necessary.

Just keep in mind that these conventions are used from the _example collection_:
- ETH_IFACE_A (normally acting as _sender_)
- iface name : eth1.10
- iface addr : 192.168.10.2
- iface port : 30490
- ETH_IFACE_B (normally acting as _receiver_)
- iface name : eth2.10
- iface addr : 192.168.10.3
- iface port : 30490

## 3. Examples
This folder contains a (hopefully growing) examples collection, build upon unittest package just for convenience. Just fire Wireshark up and enjoy analyzing generated traffic.

## 4. References
- https://www.autosar.org
- http://www.secdev.org/projects/scapy/
Binary file added dist/eth_scapy_someip-0.0.1-py2-none-any.whl
Binary file not shown.
Binary file added docs/AUTOSAR_TR_SomeIpExample.pdf
Binary file not shown.
Binary file added docs/Scapy.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions eth_scapy_someip/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .eth_scapy_someip import SOMEIP
from .eth_scapy_sd import SD

from scapy.packet import bind_layers

# Layer binding
bind_layers(SOMEIP,SD)
346 changes: 346 additions & 0 deletions eth_scapy_someip/eth_scapy_sd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
from scapy.fields import *
from scapy.packet import *
from scapy.all import *
from scapy.layers.inet6 import IP6Field
import ctypes
import collections
from .eth_scapy_someip import SOMEIP


class _SDPacketBase(Packet):
""" base class to be used among all SD Packet definitions."""
# use this dictionary to set default values for desired fields (mostly on subclasses
# where not all fields are defined locally)
# - key : field_name, value : desired value
# - it will be used from 'init_fields' function, upon packet initialization
#
# example : _defaults = {'field_1_name':field_1_value,'field_2_name':field_2_value}
_defaults = {}

def _set_defaults(self):
""" goes through '_defaults' dict setting field default values (for those that have been defined)."""
for key in self._defaults.keys():
try:
self.get_field(key)
except KeyError:
pass
else:
self.setfieldval(key, self._defaults[key])

def init_fields(self):
""" perform initialization of packet fields with desired values.
NOTE : this funtion will only be called *once* upon class (or subclass) construction
"""
Packet.init_fields(self)
self._set_defaults()


# SD ENTRY
# - Service
# - EventGroup
class _SDEntry(_SDPacketBase):
""" Base class for SDEntry_* packages."""
TYPE_FMT = ">B"
TYPE_PAYLOAD_I = 0
# ENTRY TYPES : SERVICE
TYPE_SRV_FINDSERVICE = 0x00
TYPE_SRV_OFFERSERVICE = 0x01
TYPE_SRV = (TYPE_SRV_FINDSERVICE, TYPE_SRV_OFFERSERVICE)
# ENTRY TYPES : EVENGROUP
TYPE_EVTGRP_SUBSCRIBE = 0x06
TYPE_EVTGRP_SUBSCRIBE_ACK = 0x07
TYPE_EVTGRP = (TYPE_EVTGRP_SUBSCRIBE, TYPE_EVTGRP_SUBSCRIBE_ACK)
# overall len (UT usage)
OVERALL_LEN = 16

fields_desc = [
ByteField("type", 0),
ByteField("index_1", 0),
ByteField("index_2", 0),
BitField("n_opt_1", 0, 4),
BitField("n_opt_2", 0, 4),
ShortField("srv_id", 0),
ShortField("inst_id", 0),
ByteField("major_ver", 0),
X3BytesField("ttl", 0)]

def guess_payload_class(self, payload):
""" decode SDEntry depending on its type."""
pl_type = struct.unpack(_SDEntry.TYPE_FMT, payload[_SDEntry.TYPE_PAYLOAD_I:_SDEntry.TYPE_PAYLOAD_I+1])[0]
if pl_type in _SDEntry.TYPE_SRV:
return SDEntry_Service
elif pl_type in _SDEntry.TYPE_EVTGRP:
return SDEntry_EventGroup


class SDEntry_Service(_SDEntry):
""" Service Entry."""
_defaults = {"type": _SDEntry.TYPE_SRV_FINDSERVICE}

name = "Service Entry"
fields_desc = [
_SDEntry,
IntField("minor_ver", 0)]


class SDEntry_EventGroup(_SDEntry):
""" EventGroup Entry."""
_defaults = {"type": _SDEntry.TYPE_EVTGRP_SUBSCRIBE}

name = "Eventgroup Entry"
fields_desc = [
_SDEntry,
BitField("res", 0, 12),
BitField("cnt", 0, 4),
ShortField("eventgroup_id", 0)]


# SD Option
# - Configuration
# - LoadBalancing
# - IPv4 EndPoint
# - IPv6 EndPoint
# - IPv4 MultiCast
# - IPv6 MultiCast
# - IPv4 EndPoint
# - IPv6 EndPoint
class _SDOption(_SDPacketBase):
""" Base class for SDOption_* packages."""
TYPE_FMT = ">B"
TYPE_PAYLOAD_I = 2

CFG_TYPE = 0x01
CFG_OVERALL_LEN = 4 # overall length of CFG SDOption,empty 'cfg_str' (to be used from UT)
LOADBALANCE_TYPE = 0x02
LOADBALANCE_LEN = 0x05
LOADBALANCE_OVERALL_LEN = 8 # overall length of LB SDOption (to be used from UT)
IP4_ENDPOINT_TYPE = 0x04
IP4_ENDPOINT_LEN = 0x0009
IP4_MCAST_TYPE = 0x14
IP4_MCAST_LEN = 0x0009
IP4_SDENDPOINT_TYPE = 0x24
IP4_SDENDPOINT_LEN = 0x0009
IP4_OVERALL_LEN = 12 # overall length of IP4 SDOption (to be used from UT)
IP6_ENDPOINT_TYPE = 0x06
IP6_ENDPOINT_LEN = 0x0015
IP6_MCAST_TYPE = 0x16
IP6_MCAST_LEN = 0x0015
IP6_SDENDPOINT_TYPE = 0x26
IP6_SDENDPOINT_LEN = 0x0015
IP6_OVERALL_LEN = 24 # overall length of IP6 SDOption (to be used from UT)

def guess_payload_class(self, payload):
""" decode SDOption depending on its type."""
pl_type = struct.unpack(_SDOption.TYPE_FMT, payload[_SDOption.TYPE_PAYLOAD_I:_SDOption.TYPE_PAYLOAD_I+1])[0]

if pl_type == _SDOption.CFG_TYPE:
return SDOption_Config
elif pl_type == self.LOADBALANCE_TYPE:
return SDOption_LoadBalance
elif pl_type == self.IP4_ENDPOINT_TYPE:
return SDOption_IP4_EndPoint
elif pl_type == self.IP4_MCAST_TYPE:
return SDOption_IP4_Multicast
elif pl_type == self.IP4_SDENDPOINT_TYPE:
return SDOption_IP4_SD_EndPoint
elif pl_type == self.IP6_ENDPOINT_TYPE:
return SDOption_IP6_EndPoint
elif pl_type == self.IP6_MCAST_TYPE:
return SDOption_IP6_Multicast
elif pl_type == self.IP6_SDENDPOINT_TYPE:
return SDOption_IP6_SD_EndPoint


class _SDOption_Header(_SDOption):
fields_desc = [
ShortField("len", None),
ByteField("type", 0),
ByteField("res_hdr", 0)]


class _SDOption_Tail(_SDOption):
fields_desc = [
ByteField("res_tail", 0),
ByteEnumField("l4_proto", 0x06, {0x06: "TCP", 0x11: "UDP"}),
ShortField("port", 0)]


class _SDOption_IP4(_SDOption):
fields_desc = [
_SDOption_Header,
IPField("addr", "0.0.0.0"),
_SDOption_Tail]


class _SDOption_IP6(_SDOption):
fields_desc = [
_SDOption_Header,
IP6Field("addr", "2001:cdba:0000:0000:0000:0000:3257:9652"),
_SDOption_Tail]


class SDOption_Config(_SDOption):
# offset to be added upon length calculation (corresponding to header's "Reserved" field)
LEN_OFFSET = 0x01

name = "Config Option"
# default values specification
_defaults = {'type': _SDOption.CFG_TYPE}
# package fields definiton
fields_desc = [
_SDOption_Header,
StrField("cfg_str", "")]

def post_build(self, p, pay):
# length computation excluding 16b_length and 8b_type
l = self.len
if l is None:
l = len(self.cfg_str) + self.LEN_OFFSET
p = struct.pack("!H", l) + p[2:]
return p + pay


class SDOption_LoadBalance(_SDOption):
name = "LoadBalance Option"
# default values specification
_defaults = {'type': _SDOption.LOADBALANCE_TYPE,
'len': _SDOption.LOADBALANCE_LEN}
# package fields definiton
fields_desc = [
_SDOption_Header,
ShortField("priority", 0),
ShortField("weight", 0)]


# SDOPTIONS : IPv4-specific
class SDOption_IP4_EndPoint(_SDOption_IP4):
name = "IP4 EndPoint Option"
# default values specification
_defaults = {'type': _SDOption.IP4_ENDPOINT_TYPE, 'len': _SDOption.IP4_ENDPOINT_LEN}


class SDOption_IP4_Multicast(_SDOption_IP4):
name = "IP4 Multicast Option"
# default values specification
_defaults = {'type': _SDOption.IP4_MCAST_TYPE, 'len': _SDOption.IP4_MCAST_LEN}


class SDOption_IP4_SD_EndPoint(_SDOption_IP4):
name = "IP4 SDEndPoint Option"
# default values specification
_defaults = {'type': _SDOption.IP4_SDENDPOINT_TYPE, 'len': _SDOption.IP4_SDENDPOINT_LEN}


# SDOPTIONS : IPv6-specific
class SDOption_IP6_EndPoint(_SDOption_IP6):
name = "IP6 EndPoint Option"
# default values specification
_defaults = {'type': _SDOption.IP6_ENDPOINT_TYPE, 'len': _SDOption.IP6_ENDPOINT_LEN}


class SDOption_IP6_Multicast(_SDOption_IP6):
name = "IP6 Multicast Option"
# default values specification
_defaults = {'type': _SDOption.IP6_MCAST_TYPE, 'len': _SDOption.IP6_MCAST_LEN}


class SDOption_IP6_SD_EndPoint(_SDOption_IP6):
name = "IP6 SDEndPoint Option"
# default values specification
_defaults = {'type': _SDOption.IP6_SDENDPOINT_TYPE, 'len': _SDOption.IP6_SDENDPOINT_LEN}


#
# SD PACKAGE DEFINITION
#
class SD(_SDPacketBase):
"""
SD Packet
NOTE : when adding 'entries' or 'options', do not use list.append() method but create a new list
e.g. : p = SD()
p.option_array = [SDOption_Config(),SDOption_IP6_EndPoint()]
"""
SOMEIP_MSGID_SRVID = 0xffff
SOMEIP_MSGID_SUBID = 0x1
SOMEIP_MSGID_EVENTID = 0x100
SOMEIP_PROTO_VER = 0x01
SOMEIP_IFACE_VER = 0x01
SOMEIP_MSG_TYPE = SOMEIP.TYPE_NOTIFICATION

name = "SD"
# Flags definition: {"name":(mask,offset)}
_sdFlag = collections.namedtuple('Flag', 'mask offset')
FLAGSDEF = {
"REBOOT": _sdFlag(mask=0x80, offset=7), # ReBoot flag
"UNICAST": _sdFlag(mask=0x40, offset=6) # UniCast flag
}

fields_desc = [
ByteField("flags", 0),
X3BytesField("res", 0),
FieldLenField("len_entry_array", None, length_of="entry_array", fmt="!I"),
PacketListField("entry_array", None, cls=_SDEntry, length_from=lambda pkt:pkt.len_entry_array),
FieldLenField("len_option_array", None, length_of="option_array", fmt="!I"),
PacketListField("option_array", None, cls=_SDOption, length_from=lambda pkt:pkt.len_option_array)]

def __init__(self, *args, **kwargs):
super(SD, self).__init__(*args, **kwargs)
self.explicit = 1

def getFlag(self, name):
""" get particular flag from bitfield."""
name = name.upper()
if name in self.FLAGSDEF:
return (self.flags & self.FLAGSDEF[name].mask) >> self.FLAGSDEF[name].offset
else:
return None

def setFlag(self, name, value):
"""
Set particular flag on bitfield.
:param str name : name of the flag to set (see SD.FLAGSDEF)
:param int value : either 0x1 or 0x0 (provided int will be ANDed with 0x01)
"""
name = name.upper()
if name in self.FLAGSDEF:
self.flags = ((self.flags & ctypes.c_ubyte(~self.FLAGSDEF[name].mask).value) |
(value & 0x01) << self.FLAGSDEF[name].offset)

def setEntryArray(self, entry_list):
"""
Add entries to entry_array.
:param entry_list: list of entries to be added. Single entry object also accepted
"""
if isinstance(entry_list, list):
self.entry_array = entry_list
else:
self.entry_array = [entry_list]

def setOptionArray(self, option_list):
"""
Add options to option_array.
:param option_list: list of options to be added. Single option object also accepted
"""
if isinstance(option_list, list):
self.option_array = option_list
else:
self.option_array = [option_list]

def getSomeip(self, stacked=False):
"""
return SD-initialized SOME/IP packet
:param stacked: boolean. Either just SOME/IP packet or stacked over SD-self
"""
p = SOMEIP()
p.msg_id.srv_id = SD.SOMEIP_MSGID_SRVID
p.msg_id.sub_id = SD.SOMEIP_MSGID_SUBID
p.msg_id.event_id = SD.SOMEIP_MSGID_EVENTID
p.proto_ver = SD.SOMEIP_PROTO_VER
p.iface_ver = SD.SOMEIP_IFACE_VER
p.msg_type = SD.SOMEIP_MSG_TYPE

if stacked:
return p / self
else:
return p
Loading

0 comments on commit c82985f

Please sign in to comment.