someip-sd-wire
A no_std Rust crate for parsing and serializing SOME/IP Service Discovery (SOME/IP-SD) wire protocol packets. This crate is inspired by the smoltcp architecture.
Based on the AUTOSAR SOME/IP Service Discovery Protocol Specification.
Disclaimer
This crate is intended for educational and research purposes to study the SOME/IP-SD protocol.
The SOME/IP-SD protocol is an AUTOSAR standard. AUTOSAR claims intellectual property rights over their specifications.
Scope
This crate handles SOME/IP Service Discovery message parsing and serialization.
SOME/IP-SD is used for dynamic service discovery in automotive networks. The crate parses the 12-byte SD header, service/eventgroup entries, and various option types (endpoints, configuration, load balancing). It provides zero-copy access to the wire format data.
Usage
Add this to your Cargo.toml:
[]
= "0.1.1"
Examples
Parsing a SOME/IP-SD packet
use *;
let buffer = ;
let packet = new_checked.unwrap;
let repr = parse.unwrap;
assert_eq!;
assert_eq!;
// Parse service entry
let service_entry = new_checked.unwrap;
assert_eq!; // FindService
assert_eq!;
Creating a SOME/IP-SD OfferService message
use *;
// Create high-level representations
let service_entry = ServiceEntryRepr ;
let endpoint_option = IPv4EndpointOptionRepr ;
// Emit to buffers
let mut entry_buf = ;
let mut entry = new_unchecked;
service_entry.emit;
let mut option_buf = ;
endpoint_option.emit;
// Create packet representation and emit
let repr = new;
let mut packet_buf = ;
let mut packet = new_unchecked;
repr.emit;
Working with Configuration Options
Configuration options follow DNS-SD TXT record format for key-value pairs:
use *;
// Parse configuration data
let data = b"\x07enabled\x0cversion=1.0a\x00";
for result in parse
// Create configuration entries
let entries = ;
let mut buf = ;
let size = serialize.unwrap;
Architecture
The crate follows the smoltcp zero-copy architecture with representation types for high-level API:
- Packet layer (
packetmodule) - Zero-copy wrapper around the 12-byte SD header - Representation layer (
reprmodule) - High-level packet representation with validated entries/options slices - Entry wrappers (
entriesmodule) - Zero-copy accessors (ServiceEntry, EventGroupEntry) and high-level representations (ServiceEntryRepr, EventGroupEntryRepr) - Option wrappers (
optionsmodule) - Zero-copy accessors and high-level representations for various option types
Two-Layer Design
Each major type has two layers:
- Zero-copy wrapper - Works directly on byte slices without allocation (e.g.,
ServiceEntry,IPv4EndpointOption) - Representation struct - High-level builder with typed fields for easy construction (e.g.,
ServiceEntryRepr,IPv4EndpointOptionRepr)
Use zero-copy wrappers for parsing received data. Use representation types for constructing messages to send.
Key Components
- Entries - Service entries (FindService, OfferService) and EventGroup entries (Subscribe, SubscribeAck)
- Options - IPv4/IPv6 endpoints, load balancing, configuration, multicast, and SD endpoint options
- Configuration - DNS-SD TXT record style key-value pairs for service metadata
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.