Skip to content

Commit

Permalink
Merge pull request #6 from jamores/develop
Browse files Browse the repository at this point in the history
Develop to Master
  • Loading branch information
jamores authored May 2, 2019
2 parents 7128602 + ee93737 commit 37dbe8f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# eth-ws-someip
Automotive Ethernet SOME/IP-SD Wireshark LUA dissectors (Autosar 4.2)
Automotive Ethernet SOME/IP and SOME/IP-SD Wireshark LUA dissectors (Autosar CP & AP, Foundation 1.5.0)

## Installation
In order to use this LUA plugins, they need to be added to Wireshark's 'personal plugins' folder.
Expand Down
25 changes: 17 additions & 8 deletions sd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ local tohex = bit.tohex
-- SD protocol
p_sd = Proto("sd","SD")

local f_flags = ProtoField.uint8("sd.flags","Flags",base.HEX)
local f_res = ProtoField.uint24("sd.res","Reserved",base.HEX)
local f_ents_len = ProtoField.uint32("sd.len_ent","LengthEntries",base.HEX)
local f_ents = ProtoField.bytes("sd.ent","EntriesArray")
local f_opts_len = ProtoField.uint32("sd.len_opt","LengthOptions",base.HEX)
local f_opts = ProtoField.bytes("sd.opt","OptionsArray")
local f_flags = ProtoField.uint8("sd.flags","Flags",base.HEX)
local f_flags_reboot = ProtoField.bool("sd.flags.reboot", "Reboot Flag")
local f_flags_unicast = ProtoField.bool("sd.flags.unicast", "Unicast Flag")
local f_flags_init_data = ProtoField.bool("sd.flags.init_data", "Explicit Initial Data Control Flag")

p_sd.fields = {f_flags,f_res,f_ents_len,f_ents,f_opts_len,f_opts}
local f_res = ProtoField.uint24("sd.res","Reserved",base.HEX)
local f_ents_len = ProtoField.uint32("sd.len_ent","LengthEntries",base.HEX)
local f_ents = ProtoField.bytes("sd.ent","EntriesArray")
local f_opts_len = ProtoField.uint32("sd.len_opt","LengthOptions",base.HEX)
local f_opts = ProtoField.bytes("sd.opt","OptionsArray")

p_sd.fields = {f_flags,f_flags_reboot,f_flags_unicast,f_flags_init_data,f_res,f_ents_len,f_ents,f_opts_len,f_opts}

function p_sd.dissector(buf,pinfo,root)
pinfo.cols.protocol = "SOME-IP/SD"
Expand All @@ -30,8 +34,13 @@ function p_sd.dissector(buf,pinfo,root)
local offset = 0

-- Flags
subtree:add(f_flags,buf(offset,1))
flags_tree = subtree:add(f_flags,buf(offset,1))
flags_tree:add(f_flags_reboot,buf(0,1):bitfield(0,1))
flags_tree:add(f_flags_unicast,buf(0,1):bitfield(1,1))
flags_tree:add(f_flags_init_data,buf(0,1):bitfield(2,1))

offset = offset+1

-- Reserved
subtree:add(f_res,buf(offset,3))
offset = offset+3
Expand Down
19 changes: 13 additions & 6 deletions sd_entries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ local f_e_inst_id = ProtoField.uint16("sd.e.inst_id","Instance ID",base.HEX)
local f_e_v_major = ProtoField.uint8("sd.e.v_major","MajorVersion",base.HEX)
local f_e_ttl = ProtoField.uint24("sd.e.ttl","TTL",base.DEC)
local f_e_v_minor = ProtoField.uint32("sd.e.v_minor","MinorVersion",base.HEX)
local f_e_cnt = ProtoField.uint8("sd.e.cnt","Counter",base.DEC)
local f_e_egrp_id = ProtoField.uint8("sd.e.egrp_id","EventGroup_ID",base.HEX)
local f_e_reserved = ProtoField.uint8("sd.e.reserved","Reserved",base.HEX)
local f_e_init_req = ProtoField.bool("sd.e.init_req","Initial Data Requested Flag")
local f_e_reserved2 = ProtoField.uint8("sd.e.reserved2","Reserved2",base.HEX,nil,0x07)
local f_e_cnt = ProtoField.uint8("sd.e.cnt","Counter",base.DEC,nil,0x0f)
local f_e_egrp_id = ProtoField.uint8("sd.e.egrp_id","EventGroup_ID",base.HEX)

local e_types = {
[0] = "FIND_SERVICE", -- 0x00
Expand All @@ -24,7 +27,7 @@ local e_types = {
[7] = "SUBSCRIBE_ACK" -- 0x07
}

p_sd_ents.fields = {f_e_type,f_e_o1_i,f_e_o2_i,f_e_o1_n,f_e_o2_n,f_e_srv_id,f_e_inst_id,f_e_v_major,f_e_ttl,f_e_v_minor,f_e_cnt,f_e_egrp_id}
p_sd_ents.fields = {f_e_type,f_e_o1_i,f_e_o2_i,f_e_o1_n,f_e_o2_n,f_e_srv_id,f_e_inst_id,f_e_v_major,f_e_ttl,f_e_v_minor,f_e_reserved,f_e_init_req,f_e_reserved2,f_e_cnt,f_e_egrp_id}

function p_sd_ents.dissector(buf,pinfo,root)
local offset = 0
Expand Down Expand Up @@ -103,8 +106,13 @@ function parse_entries(subtree,buf)
offset = offset + 4
else
-- EVENTGROUP
-- Counter
offset = offset +1 -- skip reserved
-- Reserved
e_subtree:add(f_e_reserved,buf(offset,1))
offset = offset +1

--Initial Data Requested Flag && Reserved2 && Counter
e_subtree:add(f_e_init_req,buf(offset,1):bitfield(0,1))
e_subtree:add(f_e_reserved2,buf(offset,1))
e_subtree:add(f_e_cnt,buf(offset,1))
offset = offset + 1

Expand All @@ -115,4 +123,3 @@ function parse_entries(subtree,buf)

return(offset)
end

5 changes: 5 additions & 0 deletions sd_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ function parse_options(subtree,buf)
end

-- Port
if o_l4[l4_u8] == "TCP" then
DissectorTable.get("tcp.port"):add(buf(offset,2):uint(),Dissector.get("someip"))
elseif o_l4[l4_u8] == "UDP" then
DissectorTable.get("udp.port"):add(buf(offset,2):uint(),Dissector.get("someip"))
end
o_subtree:add(f_o_port,buf(offset,2))
offset = offset + 2
end
Expand Down
4 changes: 3 additions & 1 deletion someip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function field_msgid(subtree,buf)
":"..tohex(band(msg_id_uint,0x7fff),4)..")")

msg_id:add("service_id : "..tohex(buf(0,2):uint(),4))
if band(buf(0,2):uint(),0x80) == 0 then
if band(buf(2,1):uint(),0x80) == 0 then
msg_id:add("method_id : "..tohex(band(msg_id_uint,0x7fff),4))
else
msg_id:add("event_id : "..tohex(band(msg_id_uint,0x7fff),4))
Expand Down Expand Up @@ -149,6 +149,8 @@ function p_someip.dissector(buf,pinfo,root)
--
if (buf(0,4):uint() == 0xffff8100) and (buf:len() > SOMEIP_SD_OFFSET) then
Dissector.get("sd"):call(buf(SOMEIP_SD_OFFSET):tvb(),pinfo,root)
elseif (buf:len() > SOMEIP_LENGTH) then
Dissector.get("data"):call(buf(SOMEIP_LENGTH):tvb(),pinfo,root)
end

end
Expand Down
Binary file added specs/AUTOSAR_PRS_SOMEIPProtocol.pdf
Binary file not shown.
Binary file not shown.
Binary file removed specs/AUTOSAR_TR_SomeIpExample.pdf
Binary file not shown.

0 comments on commit 37dbe8f

Please sign in to comment.