Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import org.apache.plc4x.java.api.exceptions.*;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.api.value.*;

import java.io.*;
import java.time.*;
import java.util.*;
import java.math.BigInteger;
Expand Down Expand Up @@ -623,8 +624,15 @@ ${helper.getExternalTypeImports()}
<#assign arrayElementTypeReference = arrayField.type.asArrayTypeReference().orElseThrow().getElementTypeReference()>

<#if arrayElementTypeReference.isByteBased()>
<#if !field.isCountArrayField() && !field.isLengthArrayField()>${helper.fail("array fields of type byte only support 'count' and 'length' loop-types.")}</#if>
byte[] ${namedField.name} = readBuffer.readByteArray("${namedField.name}", Math.toIntExact(${helper.toParseExpression(arrayField, helper.intTypeReference, arrayField.loopExpression, parserArguments)})${helper.getFieldOptions(typedField, parserArguments)});
<#if field.isCountArrayField() || field.isLengthArrayField()>
byte[] ${namedField.name} = readBuffer.readByteArray("${namedField.name}", Math.toIntExact(${helper.toParseExpression(arrayField, helper.intTypeReference, arrayField.loopExpression, parserArguments)})${helper.getFieldOptions(typedField, parserArguments)});
<#else>
ByteArrayOutputStream ${namedField.name}Buffer = new ByteArrayOutputStream();
while (${helper.toParseExpression(arrayField, helper.boolTypeReference, arrayField.loopExpression, parserArguments)}) {
${namedField.name}Buffer.write(readBuffer.readByte("${namedField.name}"${helper.getFieldOptions(typedField, parserArguments)}));
}
byte[] ${namedField.name} = ${namedField.name}Buffer.toByteArray();
</#if>
<#else>
<#-- If this is a count array, we can directly initialize an array with the given size -->
<#if field.isCountArrayField()>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,22 @@ BOOLEAN_LITERAL

STRING_LITERAL
: '"' STRING_CHARACTERS? '"'
| SINGLE_LINE_STRING
| MULTI_LINE_STRING
;

SINGLE_LINE_STRING : '"' ( ESCAPE | '\\"' | ~[\\"])* '"';
MULTI_LINE_STRING : '"""' .*? '"""';

// As we're generating property names and class names from these,
// we have to put more restrictions on them.

IDENTIFIER_LITERAL
: [A-Za-z0-9_-]+
;

fragment ESCAPE: '\\' ( [\\abdefnrstv0] | 'x' HEX_LITERAL HEX_LITERAL | 'u' HEX_LITERAL HEX_LITERAL HEX_LITERAL HEX_LITERAL | 'u{' HEX_LITERAL+ '}');

fragment
STRING_CHARACTERS
: STRING_CHARACTER+
Expand Down
1 change: 1 addition & 0 deletions plc4j/drivers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<module>profinet</module>
<module>profinet-ng</module>
<module>s7</module>
<module>sip</module>
<module>simulated</module>
<module>all</module>
</modules>
Expand Down
238 changes: 238 additions & 0 deletions plc4j/drivers/sip/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-drivers</artifactId>
<version>0.14.0-SNAPSHOT</version>
</parent>

<artifactId>plc4j-driver-sip</artifactId>

<name>PLC4J: Driver: SIP</name>
<description>Implementation of a PLC4X driver for the SIP protocol.</description>

<properties>
<project.build.outputTimestamp>2025-08-02T13:55:11Z</project.build.outputTimestamp>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-feature-xml</id>
<phase>compile</phase>
<goals>
<!-- Generate the feature.xml -->
<goal>features-generate-descriptor</goal>
<!-- Check the feature.xml -->
<goal>verify</goal>
</goals>
<configuration>
<enableGeneration>true</enableGeneration>
<aggregateFeatures>true</aggregateFeatures>
</configuration>
</execution>
<execution>
<id>build-kar</id>
<phase>package</phase>
<goals>
<!--
Build a kar archive (Jar containing the feature.xml
as well as the module content and it's dependencies.
-->
<goal>kar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.apache.plc4x.java.osgi.DriverActivator</Bundle-Activator>
<Export-Service>org.apache.plc4x.java.api.PlcDriver,org.apache.plc4x.java.sip.readwrite.sipDriver
</Export-Service>
<Import-Package>
*
</Import-Package>
<SPI-consumer>*</SPI-consumer>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-api</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-spi</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-transport-udp</artifactId>
<version>0.14.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-core</artifactId>
<!-- Override the "provided" scope -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.pcap4j</groupId>
<artifactId>pcap4j-packetfactory-static</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-utils-test-utils</artifactId>
<version>0.14.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-sip</artifactId>
<version>0.14.0-SNAPSHOT</version>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>update-generated-code</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-driver</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>sip</protocolName>
<languageName>java</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>src/main/generated</outputDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<usedDependencies combine.children="append">
<usedDependency>org.apache.plc4x:plc4x-code-generation-language-java</usedDependency>
<usedDependency>org.apache.plc4x:plc4x-protocols-sip</usedDependency>
</usedDependencies>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-code-generation-language-java</artifactId>
<version>0.14.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-sip</artifactId>
<version>0.14.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>

</project>
Loading
Loading