scapy icon indicating copy to clipboard operation
scapy copied to clipboard

SOMEIP / SD - the sub_id field is altering the value of the method/event id

Open public-src-code opened this issue 3 years ago • 5 comments

Brief description

The field sub_id is only used to differentiate between METHOD_ID and EVENT_ID. The value of the METHOD/EVENT id should still be calculated on 16bits and not on 15bits This makes the usage for the end user more complex. example: event id = 0x8100 is dissected: sub_id=EVENT_ID, event_id=0x100 event id = 0xa100 is dissected: sub_id=EVENT_ID, event_id=0x2100

The users have to take scapy logic into consideration and this makes the usage more complex. Is it possible to check the first bit without moving the offset and then read the value of the method/event id on 16bit?

Scapy version

all

Python version

any

Operating system

any

Additional environment information

No response

How to reproduce

frame = Ether(raw(payload)) print(frame)

The payload is a list of bytes from Wireshark.

Actual result

No response

Expected result

No response

Related resources

No response

public-src-code avatar Oct 04 '22 09:10 public-src-code

Thanks for your request. Could you please provide a reference to the standard, which describes the usage of the MSB to distinguish between EVENT_ID and MEHTOD_ID

polybassa avatar Oct 04 '22 09:10 polybassa

The current implementation is following the requirement AUTOSAR_PRS_SOMEIPProtocol.pdf section 4.1.2.2 and 4.1.2.3

But users are always focusing on the fact that Message ID = (Service ID / Method ID) [32 bit] (= 0xFFFF 8100 ) https://www.autosar.org/fileadmin/user_upload/standards/foundation/1-2/AUTOSAR_PRS_SOMEIPServiceDiscoveryProtocol.pdf section 4.1.2.1 / Figure 4.1: SOME/IP-SD Header Format and [PRS_SOMEIPSD_00152] d Service Discovery messages shall use the Method-ID (16 Bits) of 0x8100.

public-src-code avatar Oct 04 '22 10:10 public-src-code

I don't see a simple solution to make your change possible in Scapy.

One possibility would be, to remove the field "event_id" or "method_id" entirely and only support one or the other.

In this way, you obtain one 16bit wide field. This sub_id field could be removed. Is this a desired change, in your opinion?

polybassa avatar Oct 04 '22 11:10 polybassa

Quick solution for other readers

METHOD_ID = 0
EVENT_ID = 1

def compute_meth_id (s_id, ev_id):
    #Event ID from 0x8000 = 32768  
    if (s_id == EVENT_ID):
        return ev_id + 0x8000
    elif (s_id == METHOD_ID):
        return ev_id 
    raise ValueError('Packet had unknown sub_id value!')

gitbelg avatar Oct 06 '23 13:10 gitbelg

@polybassa Hi, what's the state of this issue?

gpotter2 avatar Feb 03 '24 16:02 gpotter2