Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 26, 2020. It is now read-only.
/JxnetPublic archive

Commit8e6bc91

Browse files
committed
Update lib version
1 parent4425d5a commit8e6bc91

File tree

14 files changed

+104
-113
lines changed

14 files changed

+104
-113
lines changed

‎VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.5.RC2
1+
1.5.5.RC3

‎gradle/configure.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ ext {
3131
PMD_VERION='6.10.0'
3232
JACOCO_VERSION='0.8.2'
3333

34-
COMMON_VERSION='1.2.7.RC2'
35-
JXPACKET_VERSION='1.2.3.RC'
34+
COMMON_VERSION='1.2.7.RC5'
35+
JXPACKET_VERSION='1.2.3.RC4'
3636
REACTOR_VERSION='Californium-RELEASE'
3737
JNR_VERSION='2.1.9'
3838

‎jxnet-example/src/main/java/com/ardikars/jxnet/example/Application.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
importcom.ardikars.common.net.MacAddress;
2727
importcom.ardikars.common.tuple.Pair;
2828
importcom.ardikars.common.tuple.Tuple;
29-
importcom.ardikars.common.util.CommonConsumer;
30-
importcom.ardikars.common.util.Hexs;
3129
importcom.ardikars.common.util.Platforms;
3230
importcom.ardikars.jxnet.DataLinkType;
3331
importcom.ardikars.jxnet.ImmediateMode;
3432
importcom.ardikars.jxnet.Jxnet;
3533
importcom.ardikars.jxnet.Pcap;
3634
importcom.ardikars.jxnet.PcapAddr;
37-
importcom.ardikars.jxnet.PcapHandler;
3835
importcom.ardikars.jxnet.PcapIf;
3936
importcom.ardikars.jxnet.PcapPktHdr;
4037
importcom.ardikars.jxnet.PcapTimestampPrecision;
@@ -46,13 +43,11 @@
4643
importcom.ardikars.jxnet.context.Context;
4744
importcom.ardikars.jxnet.exception.DeviceNotFoundException;
4845
importcom.ardikars.jxnet.exception.PlatformNotSupportedException;
49-
importcom.ardikars.jxpacket.common.AbstractPacket;
5046
importcom.ardikars.jxpacket.common.Packet;
5147
importcom.ardikars.jxpacket.common.UnknownPacket;
5248
importcom.ardikars.jxpacket.common.layer.DataLinkLayer;
5349
importcom.ardikars.jxpacket.common.layer.NetworkLayer;
5450
importcom.ardikars.jxpacket.common.layer.TransportLayer;
55-
importcom.ardikars.jxpacket.common.util.PacketIterator;
5651
importcom.ardikars.jxpacket.core.arp.Arp;
5752
importcom.ardikars.jxpacket.core.ethernet.Ethernet;
5853
importcom.ardikars.jxpacket.core.ethernet.Vlan;
@@ -69,7 +64,6 @@
6964
importcom.ardikars.jxpacket.core.udp.Udp;
7065

7166
importjava.net.SocketException;
72-
importjava.nio.ByteBuffer;
7367
importjava.util.ArrayList;
7468
importjava.util.Iterator;
7569
importjava.util.List;

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/HandlerConfigurer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
importcom.ardikars.jxnet.DataLinkType;
2424
importcom.ardikars.jxnet.context.Context;
2525
importcom.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName;
26+
importcom.ardikars.jxnet.spring.boot.autoconfigure.memory.MemoryConfigurationProperties;
2627
importcom.ardikars.jxpacket.common.Packet;
2728
importcom.ardikars.jxpacket.common.UnknownPacket;
2829
importcom.ardikars.jxpacket.core.ethernet.Ethernet;
@@ -55,13 +56,16 @@ public class HandlerConfigurer<T, V> {
5556
@Autowired
5657
privateHandler<T,V>handler;
5758

59+
@Autowired
60+
privateMemoryConfigurationPropertiesmemoryProperties;
61+
5862
/**
5963
* Decode buffer.
6064
* @param bytes direct byte buffer.
6165
* @return returns {@link Packet}.
6266
*/
6367
publicPacketdecode(ByteBufferbytes) {
64-
returnprocessPacket(Memories.wrap(bytes,false));
68+
returnprocessPacket(Memories.wrap(bytes,memoryProperties.getCheckBounds()));
6569
}
6670

6771
/**
@@ -71,7 +75,7 @@ public Packet decode(ByteBuffer bytes) {
7175
* @return returns {@link Packet}.
7276
*/
7377
publicPacketdecodeRawBuffer(longaddress,intlength) {
74-
returnprocessPacket(Memories.wrap(address,length));
78+
returnprocessPacket(Memories.wrap(address,length,memoryProperties.getCheckBounds()));
7579
}
7680

7781
privatePacketprocessPacket(Memorybuf) {

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
importcom.ardikars.jxnet.exception.NativeException;
5151
importcom.ardikars.jxnet.exception.PlatformNotSupportedException;
5252
importcom.ardikars.jxnet.exception.UnknownNetmaskException;
53+
importcom.ardikars.jxnet.spring.boot.autoconfigure.memory.MemoryConfigurationProperties;
54+
5355
importjava.net.SocketException;
5456
importjava.util.ArrayList;
5557
importjava.util.Iterator;
@@ -75,7 +77,7 @@
7577
@Configuration(JXNET_AUTO_CONFIGURATION_BEAN_NAME)
7678
@ConditionalOnClass({Jxnet.class,Context.class})
7779
@AutoConfigureOrder
78-
@EnableConfigurationProperties(JxnetConfigurationProperties.class)
80+
@EnableConfigurationProperties({JxnetConfigurationProperties.class,MemoryConfigurationProperties.class})
7981
publicclassJxnetAutoConfiguration {
8082

8183
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(JxnetAutoConfiguration.class);

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/JxnetObjectName.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,8 @@ public final class JxnetObjectName {
3939
publicstaticfinalStringJXNET_AUTO_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.jxnetAutoConfiguration";
4040
publicstaticfinalStringJXPACKET_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.jxpacketHandlerConfiguration";
4141
publicstaticfinalStringJXPACKET_RAW_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.jxpacketRawHandlerConfiguration";
42+
publicstaticfinalStringJXPACKET_ASYNC_RAW_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.jxpacketAsyncRawHandlerConfiguration";
4243
publicstaticfinalStringJXPACKET_ASYNC_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.jxpacketAsyncHandlerConfiguration";
43-
publicstaticfinalStringNETTY_BUFFER_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nettyBufferHandlerConfiguration";
44-
publicstaticfinalStringNETTY_BUFFER_ASYCN_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nettyBufferAsycHandlerConfiguration";
45-
publicstaticfinalStringNETTY_RAW_BUFFER_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nettyRawBufferHandlerConfiguration";
46-
publicstaticfinalStringNETTY_RAW_BUFFER_ASYCN_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nettyRawBufferAsycHandlerConfiguration";
47-
publicstaticfinalStringNIO_BUFFER_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nioBufferHandlerConfiguration";
48-
publicstaticfinalStringNIO_BUFFER_ASYNC_HANDLER_CONFIGURATION_BEAN_NAME ="com.ardikras.jxnet.nioBufferAsyncHandlerConfiguration";
4944
publicstaticfinalStringPCAP_BUILDER_BEAN_NAME ="com.ardikras.jxnet.pcapBuilder";
5045
publicstaticfinalStringJVM_BEAN_NAME ="com.ardikras.jxnet.jvm";
5146

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/constant/PacketHandlerType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
*/
2626
publicenumPacketHandlerType {
2727

28-
JXPACKET,JXPACKET_ASYNC,JXPACKET_RAW,NIO_BUFFER,NIO_BUFFER_ASYNC
28+
JXPACKET,JXPACKET_ASYNC,JXPACKET_RAW,JXPACKET_RAW_ASYNC;
2929

3030
}
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,44 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
packagecom.ardikars.jxnet.spring.boot.autoconfigure.nio;
18+
packagecom.ardikars.jxnet.spring.boot.autoconfigure.jxpacket;
1919

20-
importstaticcom.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.NIO_BUFFER_ASYNC_HANDLER_CONFIGURATION_BEAN_NAME;
20+
importstaticcom.ardikars.jxnet.spring.boot.autoconfigure.constant.JxnetObjectName.JXPACKET_ASYNC_RAW_HANDLER_CONFIGURATION_BEAN_NAME;
2121

2222
importcom.ardikars.common.logging.Logger;
2323
importcom.ardikars.common.logging.LoggerFactory;
24+
importcom.ardikars.common.memory.Memory;
2425
importcom.ardikars.common.tuple.Pair;
2526
importcom.ardikars.common.tuple.Tuple;
26-
importcom.ardikars.jxnet.PcapHandler;
2727
importcom.ardikars.jxnet.PcapPktHdr;
28+
importcom.ardikars.jxnet.RawPcapHandler;
2829
importcom.ardikars.jxnet.spring.boot.autoconfigure.HandlerConfigurer;
29-
importjava.nio.ByteBuffer;
30+
importcom.ardikars.jxpacket.common.Packet;
31+
3032
importjava.util.concurrent.ExecutionException;
3133

3234
importorg.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3335
importorg.springframework.context.annotation.Configuration;
3436

3537
/**
36-
*Nio buffer async handler.
37-
* @param <T> type.
38+
*Jxpacket handler.
39+
*
3840
* @author <a href="mailto:contact@ardikars.com">Ardika Rommy Sanjaya</a>
39-
* @since 1.5.3
41+
* @since 1.4.9
4042
*/
41-
@ConditionalOnClass({ByteBuffer.class})
42-
@Configuration(NIO_BUFFER_ASYNC_HANDLER_CONFIGURATION_BEAN_NAME)
43-
publicclassNioBufferAsyncHandlerConfiguration<T>extendsHandlerConfigurer<T,Pair<PcapPktHdr,ByteBuffer>>implementsPcapHandler<T> {
43+
@ConditionalOnClass({Packet.class,Memory.class})
44+
@Configuration(JXPACKET_ASYNC_RAW_HANDLER_CONFIGURATION_BEAN_NAME)
45+
publicclassJxpacketAsyncRawHandlerConfiguration<T>extendsHandlerConfigurer<T,Pair<PcapPktHdr,Packet>>implementsRawPcapHandler<T> {
4446

45-
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(NioBufferAsyncHandlerConfiguration.class);
47+
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(JxpacketAsyncRawHandlerConfiguration.class);
4648

4749
@Override
48-
publicvoidnextPacket(finalTuser,finalPcapPktHdrh,finalByteBufferbytes) {
49-
executorService.submit(newRunnable() {
50+
publicvoidnextPacket(finalTuser,finalintcapLen,finalintlen,finalinttvSec,finallongtvUsec,finallongmemoryAddress) {
51+
executorService.execute(newRunnable() {
5052
@Override
5153
publicvoidrun() {
5254
try {
53-
getHandler().next(user,Tuple.of(h,bytes));
55+
getHandler().next(user,Tuple.of(PcapPktHdr.newInstance(capLen,len,tvSec,tvUsec),decodeRawBuffer(memoryAddress,len)));
5456
}catch (ExecutionExceptione) {
5557
LOGGER.warn(e);
5658
}catch (InterruptedExceptione) {

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/jxpacket/JxpacketAutoconfiguration.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
importcom.ardikars.jxnet.DataLinkType;
3232
importcom.ardikars.jxnet.PcapPktHdr;
3333
importcom.ardikars.jxnet.context.Context;
34+
importcom.ardikars.jxnet.spring.boot.autoconfigure.memory.MemoryConfigurationProperties;
3435
importcom.ardikars.jxpacket.common.Packet;
3536
importcom.ardikars.jxpacket.common.UnknownPacket;
3637
importcom.ardikars.jxpacket.common.layer.DataLinkLayer;
@@ -76,6 +77,7 @@ public class JxpacketAutoconfiguration implements JxpacketContext {
7677
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(JxpacketAutoconfiguration.class);
7778

7879
privatefinalBooleanautoRegister;
80+
privatefinalBooleancheckBounds;
7981

8082
privatefinalContextcontext;
8183
privatefinalExecutorServiceexecutorService;
@@ -89,13 +91,16 @@ public class JxpacketAutoconfiguration implements JxpacketContext {
8991
* @param context application context.
9092
* @param executorService thread pool.
9193
* @param dataLinkType datalink type.
92-
* @param properties jxpacket configuration properties.
94+
* @param jxpacketProperties jxpacket configuration properties.
95+
* @param memoryProperties memory configuration properties.
9396
*/
9497
publicJxpacketAutoconfiguration(@Qualifier(CONTEXT_BEAN_NAME)Contextcontext,
9598
@Qualifier(EXECUTOR_SERVICE_BEAN_NAME)ExecutorServiceexecutorService,
9699
@Qualifier(DATALINK_TYPE_BEAN_NAME)DataLinkTypedataLinkType,
97-
JxpacketConfigurationPropertiesproperties) {
98-
this.autoRegister =properties.getAutoRegister();
100+
JxpacketConfigurationPropertiesjxpacketProperties,
101+
MemoryConfigurationPropertiesmemoryProperties) {
102+
this.autoRegister =jxpacketProperties.getAutoRegister();
103+
this.checkBounds =memoryProperties.getCheckBounds();
99104
register();
100105
this.context =context;
101106
this.executorService =executorService;
@@ -138,8 +143,7 @@ public Pair<PcapPktHdr, Packet> call() throws Exception {
138143
while (bytes ==null) {
139144
bytes =context.pcapNext(pktHdr);
140145
}
141-
Memorybuffer =Memories.allocator().allocate(bytes.capacity());
142-
buffer.setBytes(0,Memories.wrap(bytes,false));
146+
Memorybuffer =Memories.wrap(bytes,checkBounds);
143147
Packetpacket;
144148
if (rawDataLinkType ==1) {
145149
packet =Ethernet.newPacket(buffer);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright (C) 2015-2018 Jxnet
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
packagecom.ardikars.jxnet.spring.boot.autoconfigure.memory;
19+
20+
importcom.ardikars.common.logging.Logger;
21+
importcom.ardikars.common.logging.LoggerFactory;
22+
importcom.ardikars.jxpacket.common.Packet;
23+
importorg.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24+
importorg.springframework.boot.context.properties.ConfigurationProperties;
25+
26+
27+
@ConditionalOnClass(Packet.class)
28+
@ConfigurationProperties(prefix ="jxnet.memory")
29+
publicclassMemoryConfigurationProperties {
30+
31+
privatestaticfinalLoggerLOGGER =LoggerFactory.getLogger(MemoryConfigurationProperties.class);
32+
33+
privateBooleancheckBounds;
34+
35+
/**
36+
* Initialize properties.
37+
*/
38+
publicMemoryConfigurationProperties() {
39+
if (checkBounds ==null) {
40+
this.checkBounds =false;
41+
}
42+
LOGGER.debug("Memory checkBounds: {}",checkBounds);
43+
}
44+
45+
publicBooleangetCheckBounds() {
46+
returncheckBounds;
47+
}
48+
49+
publicvoidsetCheckBounds(BooleancheckBounds) {
50+
this.checkBounds =checkBounds;
51+
}
52+
53+
}

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/nio/NioBufferHandlerConfiguration.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/selector/JxpacketConfigurationSelector.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,17 @@ public String[] selectImports(AnnotationMetadata importingClassMetadata) {
4444
}
4545
PacketHandlerTypetype =attributes.getEnum("packetHandlerType");
4646
switch (type) {
47-
caseNIO_BUFFER:
48-
LOGGER.debug("Applying nio buffer handler configuration.");
49-
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.nio.NioBufferHandlerConfiguration"};
50-
caseNIO_BUFFER_ASYNC:
51-
LOGGER.debug("Applying nio buffer async handler configuration.");
52-
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.nio.NioBufferAsyncHandlerConfiguration"};
5347
caseJXPACKET_ASYNC:
5448
LOGGER.debug("Applying jxpacket async handler configuration.");
5549
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.jxpacket.JxpacketAsyncHandlerConfiguration"};
56-
caseJXPACKET_RAW:
57-
LOGGER.debug("Applying jxpacket raw handler configuration.");
58-
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.jxpacket.JxpacketRawHandlerConfiguration"};
59-
default:
50+
caseJXPACKET:
6051
LOGGER.debug("Applying jxpacket handler configuration.");
6152
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.jxpacket.JxpacketHandlerConfiguration"};
53+
caseJXPACKET_RAW_ASYNC:
54+
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.jxpacket.JxpacketAsyncRawHandlerConfiguration"};
55+
default:
56+
LOGGER.debug("Applying raw jxpacket handler configuration.");
57+
returnnewString[] {"com.ardikars.jxnet.spring.boot.autoconfigure.jxpacket.JxpacketRawHandlerConfiguration"};
6258
}
6359
}
6460

‎jxnet-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@
9595
"type":"java.lang.Boolean",
9696
"description":"Register all supported packet by Jxpacket.",
9797
"defaultValue":false
98+
},
99+
{
100+
"name":"jxnet.memory.checkBounds",
101+
"type":"java.lang.Boolean",
102+
"description":"Check memory bounds.",
103+
"defaultValue":false
98104
}
99105
]
100106
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp