From af6d6404cbe39a62734bf07c71a8163e685a198a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=A5=87=E8=BD=A9?= Date: Mon, 9 Sep 2024 00:49:02 +0800 Subject: [PATCH 1/5] tiny modify --- .../codec/org/bdware/doip/codec/v3/headers/DOLHeader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/codec/org/bdware/doip/codec/v3/headers/DOLHeader.java b/src/main/codec/org/bdware/doip/codec/v3/headers/DOLHeader.java index 43ab592..e42ae85 100644 --- a/src/main/codec/org/bdware/doip/codec/v3/headers/DOLHeader.java +++ b/src/main/codec/org/bdware/doip/codec/v3/headers/DOLHeader.java @@ -33,6 +33,10 @@ public class DOLHeader extends ExtensionPart { } } + public byte[] getDol() { + return dol; + } + @Override public void writeTo(ByteBuf bf) { //keep the correctness of nextType @@ -46,7 +50,7 @@ public class DOLHeader extends ExtensionPart { @Override public int length() { - return 1 + 4 + ((dol == null) ? 0 : dol.length); + return 4 + 4 + ((dol == null) ? 0 : dol.length); } @Override -- Gitee From 1ffc89d315ac83380360b035f0f6ee3b3500fc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=A5=87=E8=BD=A9?= Date: Wed, 11 Sep 2024 10:33:17 +0800 Subject: [PATCH 2/5] add TOKENHeader --- build.gradle | 2 +- .../org/bdware/doip/codec/v3/DOIPV3Codec.java | 2 +- .../doip/codec/v3/ExtensionPartFactory.java | 2 + .../doip/codec/v3/headers/ExtensionType.java | 5 +- .../doip/codec/v3/headers/TOKENHeader.java | 50 +++++++++++++++++++ 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/main/codec/org/bdware/doip/codec/v3/headers/TOKENHeader.java diff --git a/build.gradle b/build.gradle index 643f0d3..6f925af 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { group 'org.bdware.doip' -version '1.5.5' +version '1.5.6' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 repositories { diff --git a/src/main/codec/org/bdware/doip/codec/v3/DOIPV3Codec.java b/src/main/codec/org/bdware/doip/codec/v3/DOIPV3Codec.java index 785ad0b..d1716cf 100644 --- a/src/main/codec/org/bdware/doip/codec/v3/DOIPV3Codec.java +++ b/src/main/codec/org/bdware/doip/codec/v3/DOIPV3Codec.java @@ -15,7 +15,7 @@ public class DOIPV3Codec extends ByteToMessageCodec { @Override protected void encode(ChannelHandlerContext ctx, DOIPV3Message msg, ByteBuf out) throws Exception { - LOGGER.info("[DOIPV3Codec Send] " + msg.prettyPrint() + " from:" + ctx.channel().remoteAddress().toString()); + LOGGER.info("[DOIPV3Codec Send] " + msg.prettyPrint() + " to:" + ctx.channel().remoteAddress().toString()); msg.writeTo(out); } @Override diff --git a/src/main/codec/org/bdware/doip/codec/v3/ExtensionPartFactory.java b/src/main/codec/org/bdware/doip/codec/v3/ExtensionPartFactory.java index dc40a89..87fe4b8 100644 --- a/src/main/codec/org/bdware/doip/codec/v3/ExtensionPartFactory.java +++ b/src/main/codec/org/bdware/doip/codec/v3/ExtensionPartFactory.java @@ -15,6 +15,8 @@ public class ExtensionPartFactory { return new VDNHeader(bf); case ExceptionHead: return new ExceptionHead(bf); + case TOKENHeader: + return new TOKENHeader(bf); default: return null; } diff --git a/src/main/codec/org/bdware/doip/codec/v3/headers/ExtensionType.java b/src/main/codec/org/bdware/doip/codec/v3/headers/ExtensionType.java index 88ed9f0..a2a29c4 100644 --- a/src/main/codec/org/bdware/doip/codec/v3/headers/ExtensionType.java +++ b/src/main/codec/org/bdware/doip/codec/v3/headers/ExtensionType.java @@ -1,7 +1,8 @@ package org.bdware.doip.codec.v3.headers; public enum ExtensionType { - DOLHeader(0), ENVELOPE(1), VDNHeader(2), ExceptionHead(3), UNKNOWN((-1)); + DOLHeader(0), ENVELOPE(1), VDNHeader(2), ExceptionHead(3), UNKNOWN(-1), + TOKENHeader(4); public final int value; ExtensionType(int i) { @@ -18,6 +19,8 @@ public enum ExtensionType { return VDNHeader; case 3: return ExceptionHead; + case 4: + return TOKENHeader; default: return UNKNOWN; } diff --git a/src/main/codec/org/bdware/doip/codec/v3/headers/TOKENHeader.java b/src/main/codec/org/bdware/doip/codec/v3/headers/TOKENHeader.java new file mode 100644 index 0000000..ed9503b --- /dev/null +++ b/src/main/codec/org/bdware/doip/codec/v3/headers/TOKENHeader.java @@ -0,0 +1,50 @@ +package org.bdware.doip.codec.v3.headers; + +import io.netty.buffer.ByteBuf; + +public class TOKENHeader extends ExtensionPart { + public int nextHeader; + public int tokenLength; + public byte[] token; //string to byte[] + public TOKENHeader(ByteBuf bf) { + super(); + nextHeader = bf.readInt(); + nextType = ExtensionType.fromInt(nextHeader); + tokenLength = bf.readInt(); + if (tokenLength > 0) { + token = new byte[tokenLength]; + bf.readBytes(token); + } + } + + public TOKENHeader() { + } + + @Override + public void writeTo(ByteBuf bf) { + //keep the correctness of nextType + nextHeader = nextType.value; + bf.writeInt(nextHeader); + if (token != null && token.length > 0) { + bf.writeInt(token.length); + bf.writeBytes(token); + } else bf.writeInt(0); + } + + @Override + public int length() { + return 4 + 4 + ((token == null) ? 0 : token.length); + } + + + @Override + public ExtensionType getType() { + return ExtensionType.TOKENHeader; + } + + @Override + public String prettyPrint() { + return getType().name() + " token:" + token; + } + +} -- Gitee From 75bcad91843a7b9e8070c0a9ccb21e97710999b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=A5=87=E8=BD=A9?= Date: Wed, 11 Sep 2024 19:20:05 +0800 Subject: [PATCH 3/5] tiny modify --- .../org/bdware/doip/codec/operations/BasicOperations.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java b/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java index c38fb96..3be50ae 100644 --- a/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java +++ b/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java @@ -21,7 +21,9 @@ public enum BasicOperations { Subscribe("0.DOIP/Op.Subscribe"), Publish("0.DOIP/Op.Publish"), Extension("0.DOIP/Op.Extension"), - Unknown("0.DOIP/Op.Unknown"); + Unknown("0.DOIP/Op.Unknown"), + CreateVDN("0.DOIP/Op.CreateVDN"), + RetrieveVDN("0.DOIP/Op.RetrieveVDN"); private final String name; -- Gitee From 30496c807641a557d22db556f32b08bddcd659fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=A5=87=E8=BD=A9?= Date: Thu, 12 Sep 2024 16:28:20 +0800 Subject: [PATCH 4/5] add OperationsV3 --- .../codec/operations/BasicOperations.java | 4 +-- .../v3/operations/BasicOperationsV3.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java diff --git a/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java b/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java index 3be50ae..c38fb96 100644 --- a/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java +++ b/src/main/codec/org/bdware/doip/codec/operations/BasicOperations.java @@ -21,9 +21,7 @@ public enum BasicOperations { Subscribe("0.DOIP/Op.Subscribe"), Publish("0.DOIP/Op.Publish"), Extension("0.DOIP/Op.Extension"), - Unknown("0.DOIP/Op.Unknown"), - CreateVDN("0.DOIP/Op.CreateVDN"), - RetrieveVDN("0.DOIP/Op.RetrieveVDN"); + Unknown("0.DOIP/Op.Unknown"); private final String name; diff --git a/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java b/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java new file mode 100644 index 0000000..6e64a34 --- /dev/null +++ b/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java @@ -0,0 +1,26 @@ +package org.bdware.doip.codec.v3.operations; +public enum BasicOperationsV3 { + CreateVPN("0.DOIP/Op.CreateVPN"), + RetrieveVPN("0.DOIP/Op.UpdateVPN"), + Unknown("0.DOIP/Op.Unknown"); + + private final String name; + + BasicOperationsV3(String displayName) { + this.name = displayName; + } + + public static BasicOperationsV3 getDoOp(String opStr) { + for (BasicOperationsV3 op : BasicOperationsV3.values()) { + if (op.getName().equals(opStr)) { + return op; + } + } + return Unknown; + } + + public String getName() { + return name; + } +} + -- Gitee From bb3a88019af1812731bdb648f807e3b9a3eee19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=A5=87=E8=BD=A9?= Date: Sat, 14 Sep 2024 15:44:45 +0800 Subject: [PATCH 5/5] add V3Op --- .../doip/codec/v3/operations/BasicOperationsV3.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java b/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java index 6e64a34..4e467ee 100644 --- a/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java +++ b/src/main/codec/org/bdware/doip/codec/v3/operations/BasicOperationsV3.java @@ -1,7 +1,14 @@ package org.bdware.doip.codec.v3.operations; public enum BasicOperationsV3 { - CreateVPN("0.DOIP/Op.CreateVPN"), + CreateVPN("0.DOIP/Op.CreateVPN"), //todo: VPN->VDN RetrieveVPN("0.DOIP/Op.UpdateVPN"), + InitVDN("0.DOIP/Op.InitVDN"), + UpdateVDN("0.DOIP/Op.UpdateVDN"), + AddGWToVDN("0.DOIP/Op.AddGWToVDN"), + DeleteGWFromVDN("0.DOIP/Op.DeleteGWFromVDN"), + DeleteVDN("0.DOIP/Op.DeleteVDN"), + InquireVDN("0.DOIP/Op.InquireVDN"), + SearchVDN("0.DOIP/Op.InitVDN"), Unknown("0.DOIP/Op.Unknown"); private final String name; -- Gitee