|
5 | 5 | -- See license file (dsV2Gshark_LICENSE.txt) |
6 | 6 | -- |
7 | 7 |
|
8 | | -p_sdpreq = Proto("v2gsdp-req","V2G SECC Discovery Protocol Request") |
9 | | -p_sdpres = Proto("v2gsdp-res","V2G SECC Discovery Protocol Response") |
| 8 | +p_sdpreq = Proto("v2gsdp-req", "V2G SECC Discovery Protocol Request") |
| 9 | +p_sdpres = Proto("v2gsdp-res", "V2G SECC Discovery Protocol Response") |
10 | 10 | local p_v2gsdp_info = { |
11 | 11 | version = DS_V2GSHARK_VERSION, |
12 | | - author = "dSPACE GmbH", |
| 12 | + author = "dSPACE GmbH" |
13 | 13 | } |
14 | 14 | set_plugin_info(p_v2gsdp_info) |
15 | 15 |
|
16 | | - |
17 | 16 | -- V2G SDP Request |
18 | | -local f_req_sec = ProtoField.uint8("v2gsdp-req.security","Security",base.HEX) |
19 | | -local f_req_tp = ProtoField.uint8("v2gsdp-req.transportprotocol","Transport Protocol",base.HEX) |
| 17 | +local f_req_sec = ProtoField.uint8("v2gsdp-req.security", "Security", base.HEX) |
| 18 | +local f_req_tp = ProtoField.uint8("v2gsdp-req.transportprotocol", "Transport Protocol", base.HEX) |
20 | 19 | local f_req_emsp_ids = ProtoField.string("v2gsdp-req.emsp", "EMSP IDs") |
21 | 20 |
|
22 | 21 | local WITH_TLS = 0 |
23 | 22 | local NO_TLS = 16 |
24 | 23 |
|
25 | 24 | local sec_types = { |
26 | | - [WITH_TLS] = "Secured with TLS", -- 0x00 |
27 | | - [NO_TLS] = "No transport layer security", -- 0x10 |
| 25 | + [WITH_TLS] = "Secured with TLS", -- 0x00 |
| 26 | + [NO_TLS] = "No transport layer security" -- 0x10 |
28 | 27 | } |
29 | 28 |
|
30 | | -p_sdpreq.fields = {f_req_sec,f_req_tp,f_req_emsp_ids} |
| 29 | +p_sdpreq.fields = {f_req_sec, f_req_tp, f_req_emsp_ids} |
31 | 30 |
|
32 | 31 | -- SDP Request dissection function |
33 | | -function p_sdpreq.dissector(buf,pinfo,root) |
| 32 | +function p_sdpreq.dissector(buf, pinfo, root) |
34 | 33 | pinfo.cols.protocol = "V2GMSG (SDP)" |
35 | 34 |
|
36 | 35 | -- create subtree |
37 | | - subtree = root:add(p_sdpreq,buf(0)) |
| 36 | + subtree = root:add(p_sdpreq, buf(0)) |
38 | 37 |
|
39 | 38 | -- add protocol fields to subtree |
40 | 39 |
|
41 | 40 | local emsp = pinfo.private["SDP_ESMP"] |
42 | 41 | if emsp ~= nil and emsp == true then |
| 42 | + -- else: emsp list is empty |
43 | 43 | -- Note: the SDP_RES_EMSP misses the fields 'Security' and 'Transport Protocol', |
44 | 44 | -- since EMPS is only useful with PnC (TCP + TLS) |
45 | 45 | if buf:len() > 0 then |
46 | | - subtree:add(f_req_emsp_ids, buf(0)) |
| 46 | + subtree:add(f_req_emsp_ids, buf(0)) |
47 | 47 | end |
48 | | - -- else: emsp list is empty |
49 | 48 | else |
50 | 49 | -- Security |
51 | | - local sec_num = buf(0,1):uint() |
52 | | - local sec = subtree:add(f_req_sec,buf(0,1)) |
| 50 | + local sec_num = buf(0, 1):uint() |
| 51 | + local sec = subtree:add(f_req_sec, buf(0, 1)) |
53 | 52 | if sec_types[sec_num] ~= nil then |
54 | | - sec:append_text(" (" .. sec_types[sec_num] ..")") |
| 53 | + sec:append_text(" (" .. sec_types[sec_num] .. ")") |
55 | 54 | -- Concatenate the info of v2g |
56 | 55 | pinfo.cols.info = tostring(pinfo.cols.info) .. ", " .. sec_types[sec_num] |
57 | 56 | end |
58 | 57 |
|
59 | 58 | -- Transport Protocol |
60 | | - local tp = subtree:add(f_req_tp,buf(1,1)) |
61 | | - if buf(1,1):uint() == 0 then |
| 59 | + local tp = subtree:add(f_req_tp, buf(1, 1)) |
| 60 | + if buf(1, 1):uint() == 0 then |
62 | 61 | tp:append_text(" (TCP)") |
63 | 62 | end |
64 | 63 | end |
65 | 64 | end |
66 | 65 |
|
67 | 66 | -- V2G SDP Response |
68 | | -local f_res_ipv6 = ProtoField.ipv6("v2gsdp-res.ipv6","SECC IP Address") |
69 | | -local f_res_port = ProtoField.uint16("v2gsdp-res.port","SECC Port") |
70 | | -local f_res_sec = ProtoField.uint8("v2gsdp-res.security","Security",base.HEX) |
71 | | -local f_res_tp = ProtoField.uint8("v2gsdp-res.transportprotocol","Transport Protocol",base.HEX) |
| 67 | +local f_res_ipv6 = ProtoField.ipv6("v2gsdp-res.ipv6", "SECC IP Address") |
| 68 | +local f_res_port = ProtoField.uint16("v2gsdp-res.port", "SECC Port") |
| 69 | +local f_res_sec = ProtoField.uint8("v2gsdp-res.security", "Security", base.HEX) |
| 70 | +local f_res_tp = ProtoField.uint8("v2gsdp-res.transportprotocol", "Transport Protocol", base.HEX) |
72 | 71 | local f_res_emsp_ids = ProtoField.string("v2gsdp-res.emsp", "EMSP IDs") |
73 | 72 |
|
74 | | -p_sdpres.fields = {f_res_ipv6,f_res_port,f_res_sec,f_res_tp,f_res_emsp_ids} |
| 73 | +p_sdpres.fields = {f_res_ipv6, f_res_port, f_res_sec, f_res_tp, f_res_emsp_ids} |
75 | 74 |
|
76 | 75 | -- SDP Response dissection function |
77 | | -function p_sdpres.dissector(buf,pinfo,root) |
| 76 | +function p_sdpres.dissector(buf, pinfo, root) |
78 | 77 | pinfo.cols.protocol = "V2GMSG (SDP)" |
79 | 78 |
|
80 | 79 | -- create subtree |
81 | | - local subtree = root:add(p_sdpres,buf(0)) |
| 80 | + local subtree = root:add(p_sdpres, buf(0)) |
82 | 81 |
|
83 | 82 | -- add protocol fields to subtree |
84 | 83 | -- SECC IPv6 |
85 | | - subtree:add(f_res_ipv6,buf(0,16)) |
| 84 | + subtree:add(f_res_ipv6, buf(0, 16)) |
86 | 85 | -- SECC Port |
87 | | - subtree:add(f_res_port,buf(16,2)) |
88 | | - |
| 86 | + subtree:add(f_res_port, buf(16, 2)) |
89 | 87 |
|
90 | 88 | local emsp = pinfo.private["SDP_ESMP"] |
91 | 89 | if emsp ~= nil and emsp == true and buf:len() > 18 then |
92 | 90 | -- Note: the SDP_RES_EMSP misses the fields 'Security' and 'Transport Protocol', |
93 | 91 | -- since EMPS is only useful with PnC (TCP + TLS) |
94 | | - subtree:add(f_req_emsp_ids, buf(18)) |
| 92 | + subtree:add(f_req_emsp_ids, buf(18)) |
95 | 93 | else |
96 | 94 | -- Security |
97 | | - local sec_num = buf(18,1):uint() |
98 | | - local sec = subtree:add(f_res_sec,buf(18,1)) |
| 95 | + local sec_num = buf(18, 1):uint() |
| 96 | + local sec = subtree:add(f_res_sec, buf(18, 1)) |
99 | 97 | if sec_types[sec_num] ~= nil then |
100 | | - sec:append_text(" (" .. sec_types[sec_num] ..")") |
| 98 | + sec:append_text(" (" .. sec_types[sec_num] .. ")") |
101 | 99 | -- Concatenate the info of v2g |
102 | 100 | pinfo.cols.info = tostring(pinfo.cols.info) .. ", " .. sec_types[sec_num] |
103 | 101 | end |
104 | 102 |
|
105 | 103 | -- Transport Protocol |
106 | | - local tp = subtree:add(f_res_tp,buf(19,1)) |
107 | | - if buf(19,1):uint() == 0 then |
| 104 | + local tp = subtree:add(f_res_tp, buf(19, 1)) |
| 105 | + if buf(19, 1):uint() == 0 then |
108 | 106 | tp:append_text(" (TCP)") |
109 | 107 | if sec_num == NO_TLS then |
110 | | - DissectorTable.get("tcp.port"):add(buf(16,2):uint(),Dissector.get("v2gtp")) |
| 108 | + DissectorTable.get("tcp.port"):add(buf(16, 2):uint(), Dissector.get("v2gtp")) |
111 | 109 | elseif sec_num == WITH_TLS then |
112 | | - DissectorTable.get("tls.port"):add(buf(16,2):uint(),Dissector.get("v2gtp")) |
| 110 | + DissectorTable.get("tls.port"):add(buf(16, 2):uint(), Dissector.get("v2gtp")) |
113 | 111 | end |
114 | 112 | end |
115 | 113 | end |
|
0 commit comments