Skip to content

Commit 808713b

Browse files
committedOct 31, 2021
Fixing import/exports
1 parent 47e2929 commit 808713b

File tree

10 files changed

+57
-146
lines changed

10 files changed

+57
-146
lines changed
 

‎src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PCCC from './layers/pccc/index.js';
55
import CIP from './layers/cip/index.js';
66
import Extras from './layers/extras/index.js';
77

8-
export default {
8+
export {
99
TCP,
1010
UDP,
1111
Modbus,
+4-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
1-
import {
2-
ClassCodes,
3-
ClassNames,
4-
} from './classes.js';
5-
6-
import {
7-
CommonServiceCodes,
8-
CommonServiceNames,
9-
} from './services.js';
10-
11-
import {
12-
GeneralStatusCodes,
13-
GeneralStatusNames,
14-
GeneralStatusDescriptions,
15-
} from './statuses.js';
16-
17-
import * as Vendors from './vendors.js';
18-
// asdf.default.VendorNames
19-
20-
export default {
21-
ClassCodes,
22-
ClassNames,
23-
CommonServiceCodes,
24-
CommonServiceNames,
25-
GeneralStatusCodes,
26-
GeneralStatusNames,
27-
GeneralStatusDescriptions,
28-
VendorNames: Vendors.default.VendorNames,
29-
};
1+
export * from './classes.js';
2+
export * from './services.js';
3+
export * from './statuses.js';
4+
export * from './vendors.js';

‎src/layers/cip/core/constants/vendors.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** https://github.com/boundary/wireshark/blob/07eade8124fd1d5386161591b52e177ee6ea849f/epan/dissectors/packet-cip.c#L1174 */
2-
const VendorNames = {
2+
export const VendorNames = {
33
0: 'Reserved',
44
1: 'Rockwell Automation/Allen-Bradley',
55
2: 'Namco Controls Corp.',
@@ -1222,7 +1222,3 @@ const VendorNames = {
12221222
1239: 'ALTE Transportation, S.L.',
12231223
1240: 'Penko Engineering B.V.',
12241224
};
1225-
1226-
export default {
1227-
VendorNames,
1228-
};

‎src/layers/cip/core/datatypes/decoding.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
decodeUnsignedInteger,
99
} from '../../../../utils.js';
1010

11-
function DecodeTypedData(buffer, offsetRef, dataType, ctx) {
11+
export function DecodeTypedData(buffer, offsetRef, dataType, ctx) {
1212
if (Array.isArray(dataType)) {
1313
return dataType.map((dataTypeItem) => DecodeTypedData(buffer, offsetRef, dataTypeItem, ctx));
1414
}
@@ -165,8 +165,4 @@ function DecodeTypedData(buffer, offsetRef, dataType, ctx) {
165165
}
166166

167167
return value;
168-
}
169-
170-
export default {
171-
DecodeTypedData,
172-
};
168+
}
+4-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
1-
import { DataType } from './types.js';
2-
import { DataTypeCodes, DataTypeNames } from './codes.js';
3-
4-
import {
5-
Decode,
6-
} from './decoding.js';
7-
8-
import {
9-
EncodeSize,
10-
Encode,
11-
EncodeTo,
12-
} from './encoding.js';
13-
14-
export default {
15-
DataType,
16-
DataTypeNames,
17-
DataTypeCodes,
18-
Decode,
19-
EncodeSize,
20-
Encode,
21-
EncodeTo,
22-
};
1+
export * from './types.js';
2+
export * from './codes.js';
3+
export * from './decoding.js';
4+
export * from './encoding.js';

‎src/layers/cip/core/datatypes/types.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DataTypeCodes } from './codes.js';
22

3-
const DataType = Object.freeze({
3+
export const DataType = Object.freeze({
44
UNKNOWN(length) {
55
return { type: DataType.UNKNOWN, code: DataTypeCodes.UNKNOWN, length };
66
},
@@ -199,8 +199,4 @@ const DataType = Object.freeze({
199199
encodeTransform,
200200
};
201201
},
202-
});
203-
204-
export default {
205-
DataType,
206-
};
202+
});

‎src/layers/cip/core/index.js

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
import Request from './request.js';
2-
import Objects from './objects/index.js';
3-
import EPath from './epath/index.js';
4-
import Constants from './constants/index.js';
5-
import DataTypes from './datatypes/index.js';
6-
import Attribute from './attribute.js';
7-
8-
export default {
9-
Request,
10-
Objects,
11-
EPath,
12-
Constants,
13-
DataTypes,
14-
Attribute,
15-
};
1+
export * as Request from './request.js';
2+
export * as Objects from './objects/index.js';
3+
export * as EPath from './epath/index.js';
4+
export * as Constants from './constants/index.js';
5+
export * as DataTypes from './datatypes/index.js';
6+
export * as Attribute from './attribute.js';

‎src/layers/cip/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import CIPInternalLayer from './layers/internal/CIPInternalLayer.js';
22
import EIP from './layers/EIP/index.js';
33
import Logix5000 from './layers/Logix5000/index.js';
4-
import Core from './core/index.js';
4+
import * as Core from './core/index.js';
55

66
class CIPLayer extends CIPInternalLayer {}
77

‎src/layers/cip/layers/Logix5000/constants.js

+20-45
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import {
99
InvertKeyValues,
1010
} from '../../../../utils.js';
1111

12-
const Logix5000DataTypeCodes = Object.freeze({
12+
export const Logix5000DataTypeCodes = Object.freeze({
1313
Program: 0x68,
1414
Map: 0x69,
1515
Routine: 0x6D,
1616
Task: 0x70,
1717
Cxn: 0x7E,
1818
});
1919

20-
const Logix5000DatatypeNames = InvertKeyValues(Logix5000DataTypeCodes);
20+
export const Logix5000DatatypeNames = InvertKeyValues(Logix5000DataTypeCodes);
2121

22-
const Logix5000DataType = Object.freeze({
22+
export const Logix5000DataType = Object.freeze({
2323
Program() {
2424
return { type: Logix5000DataType.Program, code: Logix5000DataTypeCodes.Program };
2525
},
@@ -37,14 +37,14 @@ const Logix5000DataType = Object.freeze({
3737
},
3838
});
3939

40-
const Logix5000ClassCodes = Object.freeze({
40+
export const Logix5000ClassCodes = Object.freeze({
4141
Symbol: 0x6B,
4242
Template: 0x6C,
4343
Controller: 0xAC,
4444
});
4545

4646
/** 1756-PM020, pg. 16 */
47-
const SymbolServiceCodes = Object.freeze({
47+
export const SymbolServiceCodes = Object.freeze({
4848
Read: 0x4C,
4949
ReadFragmented: 0x52,
5050
WriteTag: 0x4D,
@@ -53,9 +53,9 @@ const SymbolServiceCodes = Object.freeze({
5353
GetInstanceAttributeList: 0x55,
5454
});
5555

56-
const SymbolServiceNames = InvertKeyValues(SymbolServiceCodes);
56+
export const SymbolServiceNames = InvertKeyValues(SymbolServiceCodes);
5757

58-
const SymbolInstanceAttributeCodes = Object.freeze({
58+
export const SymbolInstanceAttributeCodes = Object.freeze({
5959
Name: 0x01,
6060
Type: 0x02,
6161
Bytes: 0x07,
@@ -68,7 +68,7 @@ const SymbolInstanceAttributeCodes = Object.freeze({
6868
Unknown11: 11,
6969
});
7070

71-
const SymbolInstanceAttributeNames = InvertKeyValues(SymbolInstanceAttributeCodes);
71+
export const SymbolInstanceAttributeNames = InvertKeyValues(SymbolInstanceAttributeCodes);
7272

7373
/**
7474
* Possible remaining attributes:
@@ -84,7 +84,7 @@ const SymbolInstanceAttributeNames = InvertKeyValues(SymbolInstanceAttributeCode
8484
* Defines whether a tag value remains constant. Tags with this attribute
8585
* set cannot be changed programmatically.)
8686
*/
87-
const SymbolInstanceAttributeDataTypes = Object.freeze({
87+
export const SymbolInstanceAttributeDataTypes = Object.freeze({
8888
[SymbolInstanceAttributeCodes.Name]: DataType.STRING,
8989
[SymbolInstanceAttributeCodes.Type]: DataType.TRANSFORM(
9090
DataType.UINT,
@@ -100,57 +100,57 @@ const SymbolInstanceAttributeDataTypes = Object.freeze({
100100
[SymbolInstanceAttributeCodes.Unknown11]: DataType.UNKNOWN(1),
101101
});
102102

103-
const TemplateServiceCodes = Object.freeze({
103+
export const TemplateServiceCodes = Object.freeze({
104104
Read: 0x4C,
105105
});
106106

107-
const TemplateInstanceAttributeCodes = Object.freeze({
107+
export const TemplateInstanceAttributeCodes = Object.freeze({
108108
StructureHandle: 0x01, /** Calculated CRC value for members of the structure */
109109
MemberCount: 0x02, /** Number of members defined in the structure */
110110
DefinitionSize: 0x04, /** Size of the template definition structure */
111111
StructureSize: 0x05, /** Number of bytes transferred on the wire when the structure is read using the Read Tag service */
112112
});
113113

114-
const TemplateInstanceAttributeDataTypes = Object.freeze({
114+
export const TemplateInstanceAttributeDataTypes = Object.freeze({
115115
[TemplateInstanceAttributeCodes.StructureHandle]: DataType.UINT,
116116
[TemplateInstanceAttributeCodes.MemberCount]: DataType.UINT,
117117
[TemplateInstanceAttributeCodes.DefinitionSize]: DataType.UDINT,
118118
[TemplateInstanceAttributeCodes.StructureSize]: DataType.UDINT,
119119
});
120120

121-
const TemplateClassAttributeCodes = Object.freeze({
121+
export const TemplateClassAttributeCodes = Object.freeze({
122122
Unknown1: 1,
123123
Unknown2: 2,
124124
Unknown3: 3,
125125
Unknown8: 8,
126126
});
127127

128-
const TemplateClassAttributeDataTypes = Object.freeze({
128+
export const TemplateClassAttributeDataTypes = Object.freeze({
129129
[TemplateClassAttributeCodes.Unknown1]: DataType.UNKNOWN(2),
130130
[TemplateClassAttributeCodes.Unknown2]: DataType.UNKNOWN(4),
131131
[TemplateClassAttributeCodes.Unknown3]: DataType.UNKNOWN(4),
132132
[TemplateClassAttributeCodes.Unknown8]: DataType.UNKNOWN(4),
133133
});
134134

135-
const ControllerInstanceAttributeCodes = Object.freeze({
135+
export const ControllerInstanceAttributeCodes = Object.freeze({
136136
Unknown1: 1,
137137
Unknown2: 2,
138138
Unknown3: 3,
139139
Unknown4: 4,
140140
Unknown10: 10,
141141
});
142142

143-
const ControllerInstanceAttributeNames = InvertKeyValues(ControllerInstanceAttributeCodes);
143+
export const ControllerInstanceAttributeNames = InvertKeyValues(ControllerInstanceAttributeCodes);
144144

145-
const ControllerInstanceAttributeDataTypes = Object.freeze({
145+
export const ControllerInstanceAttributeDataTypes = Object.freeze({
146146
[ControllerInstanceAttributeCodes.Unknown1]: DataType.UINT,
147147
[ControllerInstanceAttributeCodes.Unknown2]: DataType.UINT,
148148
[ControllerInstanceAttributeCodes.Unknown3]: DataType.UDINT,
149149
[ControllerInstanceAttributeCodes.Unknown4]: DataType.UDINT,
150150
[ControllerInstanceAttributeCodes.Unknown10]: DataType.UDINT,
151151
});
152152

153-
const GenericServiceStatusDescriptions = {
153+
export const GenericServiceStatusDescriptions = {
154154
0x04: 'A syntax error was detected decoding the Request Path',
155155
0x05: 'Request Path destination unknown',
156156
0x06: 'Insufficient Packet Space: Not enough room in the response buffer for all the data',
@@ -169,7 +169,7 @@ const GenericServiceStatusDescriptions = {
169169
},
170170
};
171171

172-
class SymbolType {
172+
export class SymbolType {
173173
constructor(code) {
174174
this.code = code;
175175
this.atomic = getBits(code, 15, 16) === 0;
@@ -203,7 +203,7 @@ class SymbolType {
203203
}
204204
}
205205

206-
class Member {
206+
export class Member {
207207
constructor(typeCode, info, offset, name, host) {
208208
this.type = new SymbolType(typeCode);
209209
this.info = info;
@@ -212,28 +212,3 @@ class Member {
212212
this.host = !!host;
213213
}
214214
}
215-
216-
export default {
217-
Logix5000DataTypeCodes,
218-
Logix5000DatatypeNames,
219-
Logix5000DataType,
220-
Logix5000ClassCodes,
221-
SymbolServiceCodes,
222-
SymbolServiceNames,
223-
SymbolInstanceAttributeCodes,
224-
SymbolInstanceAttributeNames,
225-
SymbolInstanceAttributeDataTypes,
226-
// SymbolServiceErrorDescriptions,
227-
TemplateServiceCodes,
228-
TemplateClassAttributeCodes,
229-
TemplateClassAttributeDataTypes,
230-
TemplateInstanceAttributeCodes,
231-
TemplateInstanceAttributeDataTypes,
232-
// TemplateServiceErrorDescriptions,
233-
GenericServiceStatusDescriptions,
234-
Member,
235-
SymbolType,
236-
ControllerInstanceAttributeCodes,
237-
ControllerInstanceAttributeDataTypes,
238-
ControllerInstanceAttributeNames,
239-
};

0 commit comments

Comments
 (0)