diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 00a51af..0000000 --- a/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -# -# https://help.github.com/articles/dealing-with-line-endings/ -# -# These are explicitly windows files and should use crlf -*.bat text eol=crlf - diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 58e1c59..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build diff --git a/.gitignore b/.gitignore index 821a4e0..70171ae 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,9 @@ gradle-app.setting # Ignore Gradle build output directory build +.settings/ +bin/ +.project +.classpath +.asciidoctorconfig.adoc +.vscode/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..21227d9 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,59 @@ +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + +before_script: + - source "/home/gitlab-runner/.sdkman/bin/sdkman-init.sh" + - sdk u java 11.0.12-open + +stages: + - build + - test + - docs + - analysis + - publish + +Build Application: + stage: build + script: ./gradlew --build-cache compileJava + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle + +Create Documentation: + stage: build + script: ./gradlew asciidoctorPdf + +Test Application: + stage: test + script: ./gradlew check + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle + +sonarqube-check: + stage: analysis + variables: + SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "${CI_JOB_NAME}" + paths: + - .sonar/cache + script: ./gradlew sonarqube + allow_failure: true + +Publish Artifacts: + stage: publish + script: ./gradlew publish + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle diff --git a/build.gradle b/build.gradle index 15952d8..94a07a9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,29 +1,114 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * This generated file contains a sample Java Library project to get you started. - * For more details take a look at the Java Libraries chapter in the Gradle - * User Manual available at https://docs.gradle.org/6.3/userguide/java_library_plugin.html - */ - plugins { - // Apply the java-library plugin to add support for Java Library id 'java-library' + id 'jacoco' + id "org.sonarqube" version "3.3" + id 'org.asciidoctor.jvm.pdf' version '3.3.2' + id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'org.asciidoctor.jvm.gems' version '3.3.2' + id 'maven-publish' } repositories { - // Use jcenter for resolving dependencies. - // You can declare any Maven/Ivy/file repository here. jcenter() + ruby.gems() } dependencies { - // This dependency is exported to consumers, that is to say found on their compile classpath. - api 'org.apache.commons:commons-math3:3.6.1' - - // This dependency is used internally, and not exposed to consumers on their own compile classpath. - implementation 'com.google.guava:guava:28.2-jre' - - // Use JUnit test framework - testImplementation 'junit:junit:4.12' + asciidoctorGems 'rubygems:rouge:3.15.0' + asciidoctorGems 'rubygems:asciidoctor-diagram:2.2.2' + testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' +} + +final BUILD_DATE = new Date().format('dd.MM.yyyy').toString() +def pdfFile = layout.buildDirectory.file("docs/asciidocPdf/" + project.name + ".pdf") +def pdfArtifact = artifacts.add('archives', pdfFile.get().asFile) { + type 'pdf' + builtBy asciidoctorPdf +} +sourceCompatibility = 1.8 + +publishing { + publications { + maven(MavenPublication) { + group = group + '.docs' + artifactId = project.name + artifact pdfArtifact + } + } + publications { + osistacklibrary(MavenPublication) { + from components.java + } + } + + repositories { + maven { + url "https://gitlab.thpeetz.de/api/v4/projects/${projectId}/packages/maven" + credentials(HttpHeaderCredentials) { + name = "Private-Token" + value = gitLabPrivateToken + } + authentication { + header(HttpHeaderAuthentication) + } + } + } +} + +test { + useJUnitPlatform() + testLogging { + events "passed", "skipped", "failed" + } +} + +jacocoTestReport { + reports { + xml.enabled true + } +} + +test.finalizedBy jacocoTestReport + +sonarqube { + properties { + property "sonar.projectKey", "github_osi-stack_AYBw4khXuGIZKMqU5_ed" + property "sonar.host.url", "https://sonar.thpeetz.de" + property "sonar.login", "71bff82090aff3503c20d5070949c3bba548c51e" + property "sonar.qualitygate.wait", true + property "sonar.sourceEncoding", "UTF-8" + } +} + +tasks.named('sonarqube').configure { + dependsOn test +} + +asciidoctorPdf { + dependsOn asciidoctorGemsPrepare + + baseDirFollowsSourceFile() + + asciidoctorj { + requires 'rouge', 'asciidoctor-diagram' + attributes 'build-gradle': file('build.gradle'), + 'endpoint-url': 'https://www.thpeetz.de', + 'source-highlighter': 'rouge', + 'imagesdir': './images', + 'toc': 'left', + 'toc-title': 'Inhaltsverzeichnis', + 'revdate': BUILD_DATE, + 'revnumber': { project.version.toString() }, + 'revremark': 'Entwurf', + 'chapter-label': '', + 'icons': 'font', + 'idprefix': 'id_', + 'idseparator': '-', + 'docinfo1': '' + } +} + +wrapper { + gradleVersion = "6.3" } diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..9faab50 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,6 @@ +description='OSI Stack Library' +version=0.1.0-SNAPSHOT +group=de.thpeetz.network +gitLabPrivateToken=bFcsw1ebNhoFgKysksU1 +projectId=168 + diff --git a/settings.gradle b/settings.gradle index 8e7bbf6..da09192 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user manual at https://docs.gradle.org/6.3/userguide/multi_project_builds.html - */ - rootProject.name = 'osi-stack' diff --git a/src/docs/asciidoc/osi-stack.adoc b/src/docs/asciidoc/osi-stack.adoc new file mode 100644 index 0000000..0b507b0 --- /dev/null +++ b/src/docs/asciidoc/osi-stack.adoc @@ -0,0 +1,93 @@ += Projektbeschreibung osi-stack: Pflichtenheft und Projektbeschreibung +:author: Thomas Peetz +:email: +:doctype: article +:sectnums: +:sectnumlevels: 4 +:toc: +:toclevels: 4 +:table-caption!: +:counter: table-number: 0 + + +//[title="Dokumenthistorie", caption="Tabelle {counter:table-number} ", id="Tabelle-{counter:table-number}", options="header"] +//[title="Dokumenthistorie", id="Table-{counter:table-number}", options="header", cols="4"] +[title="Dokumenthistorie", id="Table-{counter:table-number}", options="header"] +|=== +| Version | Datum | Autor | Änderungsgrund / Bemerkungen +| 0.0.1 | 28.04.2022 | Thomas Peetz | Ersterstellung +|=== + +== Einführung + +=== Zweck + +Implementierung der OSI Layer 4 bis 7 in Java. + +=== Stakeholder des Systems + +=== Systemumfang + +==== Zielsetzung des Systems + +=== Systemübersicht + +==== Systemkontext + +==== Systemarchitektur + +===== Systemkomponente 1 + +===== Systemkomponente 2 + +==== Systemschnittstellen + +===== Realisierte Schnittstellen + +===== Verwendete Schnittstellen + +==== Logisches Datenmodell + +==== Einschränkungen + +== Anforderungen der Domäne + +=== Systemfunktionen + +==== Anwendungsfälle + +==== Akteure + +==== Zielgruppen + +=== Anforderungen + +==== Anforderungen an externe Schnittstellen + +==== Funktionale Anforderungen + +==== Qualitätsanforderungen + +==== Randbedingungen + +==== Weitere Anforderungen + +==== Wartungs- und Supportinformationen + +=== Verifikation + +[bibliography] +== Referenzen + +- [[[1]]] http://www.gitlab.org + +[glossary] +== Glossar + +== Verzeichnisse + +=== Abbildungsverzeichnis + +=== Tabellenverzeichnis + +<> <> diff --git a/src/main/java/com/ibtp/network/osi/Library.java b/src/main/java/com/ibtp/network/osi/Library.java deleted file mode 100644 index b555b0c..0000000 --- a/src/main/java/com/ibtp/network/osi/Library.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * This Java source file was generated by the Gradle 'init' task. - */ -package com.ibtp.network.osi; - -public class Library { - public boolean someLibraryMethod() { - return true; - } -} diff --git a/src/main/java/de/thpeetz/network/osi/AccessPoint.java b/src/main/java/de/thpeetz/network/osi/AccessPoint.java new file mode 100644 index 0000000..cef3fd6 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/AccessPoint.java @@ -0,0 +1,62 @@ +package de.thpeetz.network.osi; + +/** + * AccessPoint + * @author Thomas Peetz + * + */ +public class AccessPoint +{ + /** + * byte[] accessPoint + */ + private byte[] accessPoint; + + /** + * String accessPointString + */ + private String accessPointString; + + /** + * Standard constructor + */ + public AccessPoint() + { + } + + /** + * Constructor to initialize member accessPoint + */ + public AccessPoint(String ap) + { + this.accessPointString = ap; + this.accessPoint = ap.getBytes(); + } + + /** + * Return byte array as string. + * @return + */ + public final String getString() + { + return this.accessPointString; + } + + /** + * Return byte array. + * @return + */ + public final byte[] getData() + { + return this.accessPoint; + } + + /** + * Return length of byte array. + * @return + */ + public final byte getLength() + { + return (byte)this.accessPoint.length; + } +} diff --git a/src/main/java/de/thpeetz/network/osi/DataService.java b/src/main/java/de/thpeetz/network/osi/DataService.java new file mode 100644 index 0000000..3253934 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/DataService.java @@ -0,0 +1,22 @@ +package de.thpeetz.network.osi; + +public interface DataService +{ + /** + * + * @param telegram + */ + void eventReceive(DataUnit telegram); + + /** + * eventSessionDown + * + */ + void eventSessionDown(); + + /** + * + * + */ + void eventClose(); +} diff --git a/src/main/java/de/thpeetz/network/osi/DataUnit.java b/src/main/java/de/thpeetz/network/osi/DataUnit.java new file mode 100644 index 0000000..a432f9e --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/DataUnit.java @@ -0,0 +1,239 @@ +package de.thpeetz.network.osi; + +/** + * @author Thomas Peetz + * + */ +public class DataUnit +{ + /** + * Contains the telegram as array of byte. + */ + private byte[] buffer; + + /** + * Contains the position. + */ + private int pointer; + + /** + * Contains the length of the actual telegram. + */ + private int length; + + /** + * Indicates whether the buffer is in READ or WRITE mode. + */ + private boolean writeMode = false; + + /** + * Class constructor + * + */ + public DataUnit() + { + this.buffer = new byte[1024]; + } + + /** + * Initializes DataUnit with given array. The position is set to the first + * byte and the length is set to the length of the given array. + * + * @param telegram Telegram to decode + */ + public void initialize(byte[] telegram) + { + if (telegram.length > this.buffer.length) this.buffer = new byte[telegram.length]; + System.arraycopy(telegram, 0, this.buffer, 0, telegram.length); + this.length = telegram.length; + setToRead(); + } + + /** + * initialize + * + */ + public void initialize() + { + this.length = 0; + setToRead(); + } + + /** + * addBuffer + * + * @param telegram parameter for addBuffer + */ + public void addBuffer(byte[] telegram) + { + if (telegram.length + this.length > this.buffer.length) { + byte[] tmp = new byte[telegram.length + this.length]; + System.arraycopy(this.buffer,0,tmp,0,this.buffer.length); + this.buffer = tmp; + } + System.arraycopy(telegram,0,this.buffer,this.length,telegram.length); + this.length += telegram.length; + } + + /** + * setToWrite + * + */ + public void setToWrite() + { + this.pointer = this.buffer.length; + this.length = 0; + this.writeMode = true; + } + + /** + * setToRead + * + */ + public void setToRead() + { + this.pointer = 0; + this.writeMode = false; + } + + /** + * write + * + * @param data parameter for write + */ + public void write(byte[] data) + { + if (!this.writeMode) return; + if (data.length+this.length > this.buffer.length) + { + byte[] tmp = this.buffer; + this.buffer = new byte[data.length+this.length]; + int diff = this.buffer.length-tmp.length; + this.pointer += diff; + System.arraycopy(tmp,0,this.buffer,diff,tmp.length); + } + this.pointer = this.pointer-data.length; + System.arraycopy(data,0,this.buffer,this.pointer,data.length); + this.length = this.length+data.length; + } + + /** + * write + * + * @param data parameter for write + */ + public void write(byte data) + { + if (!this.writeMode) return; + if (this.length+1 > this.buffer.length) + { + byte[] tmp = this.buffer; + this.buffer = new byte[this.buffer.length+10]; + int diff = this.buffer.length-tmp.length; + this.pointer += diff; + System.arraycopy(tmp,0,this.buffer,diff,tmp.length); + } + this.buffer[--this.pointer] = data; this.length++; + } + + /** + * write + * + * @param data parameter for write + */ + public void write(int data) + { + if (!this.writeMode) return; + if (this.length+2 > this.buffer.length) + { + byte[] tmp = this.buffer; + this.buffer = new byte[this.buffer.length+10]; + int diff = this.buffer.length-tmp.length; + this.pointer += diff; + System.arraycopy(tmp,0,this.buffer,diff,tmp.length); + } + this.buffer[--this.pointer] = (byte)(0xff & data); this.length++; + this.buffer[--this.pointer] = (byte)( (0xff & (data >> 8)) ); this.length++; + } + + /** + * Read next byte. + * @return Returns byte at the current position. + */ + public final byte read() + { + this.length--; + return this.buffer[this.pointer++]; + } + + /** + * Reads next size bytes from buffer. + * + * @param size Length of bytes to be read from buffer + * @return Returns array of byte of length size + */ + public final byte[] read(int size) + { + byte[] tmp = new byte[size]; + System.arraycopy(this.buffer, this.pointer, tmp, 0, size); + this.pointer += size; this.length -= size; + return tmp; + } + + /** + * Read next two bytes from buffer. The first byte is considered as HIGH BYTE + * the second as LOW BYTE. + * + * @return Returns int value. + */ + public final int readInt() + { + int highbyte = ((0xff & this.buffer[this.pointer++]) << 8); + int lowbyte = (0xff & this.buffer[this.pointer++]); + //int tmp = (0xff & this.buffer[this.pointer++]) & ((0xff & this.buffer[this.pointer++]) << 8); + int tmp = lowbyte | highbyte; + this.length -= 2; + return tmp; + } + + /** + * getBuffer + * + * @return the returned byte[] + */ + public final byte[] getBuffer() { + byte[] tmp = new byte[this.length]; + try { + System.arraycopy(this.buffer, this.pointer, tmp, 0, this.length); + } catch (ArrayIndexOutOfBoundsException exception) { + //System.out.println(buffer.length + " " + pointer + " " + tmp.length + " " + length); + } + return tmp; + } + + /** + * getBuffer + * + * @param count parameter for getBuffer + * @return the returned byte[] + */ + public final byte[] getBuffer(int count) { + byte[] tmp = new byte[count]; + try { + System.arraycopy(this.buffer, this.pointer, tmp, 0, count); + this.length -= count; this.pointer += count; + } catch (ArrayIndexOutOfBoundsException exception) { + //System.out.println(buffer.length + " " + pointer + " " + tmp.length + " " + length); + } + return tmp; + } + + /** + * getLength + * + * @return the returned int + */ + public final int getLength() { + return this.length; + } +} diff --git a/src/main/java/de/thpeetz/network/osi/DataUnitManager.java b/src/main/java/de/thpeetz/network/osi/DataUnitManager.java new file mode 100644 index 0000000..89e4acc --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/DataUnitManager.java @@ -0,0 +1,63 @@ +package de.thpeetz.network.osi; + +import de.thpeetz.tools.ObjectPool; + +/** + * @author Thomas Peetz + * + */ +public class DataUnitManager +{ + /** + * DataUnitManager self + */ + private static DataUnitManager self = null; + + /** + * ObjectPool objectPool + */ + private ObjectPool objectPool; + + /************************************************************************** + * Class constructor + * + ***************************************************************************/ + protected DataUnitManager() + { + this.objectPool = new ObjectPool(DataUnit.class, 5); + for (int i=0; i <5; i++) { + this.objectPool.freeInstance(this.objectPool.getInstance()); + } + } + + /************************************************************************** + * getManager + * + * @return the returned DataUnitManager + ***************************************************************************/ + protected static DataUnitManager getManager() + { + if (self == null) self = new DataUnitManager(); + return self; + } + + /************************************************************************** + * getInstance + * + * @return the returned DataUnit + ***************************************************************************/ + public static synchronized DataUnit getInstance() + { + return getManager().objectPool.getInstance(); + } + + /************************************************************************** + * freeInstance + * + * @param object parameter for freeInstance + ***************************************************************************/ + public static synchronized void freeInstance(DataUnit object) + { + getManager().objectPool.freeInstance(object); + } +} diff --git a/src/main/java/de/thpeetz/network/osi/presentation/PresentationLayer.java b/src/main/java/de/thpeetz/network/osi/presentation/PresentationLayer.java new file mode 100644 index 0000000..2fb11ed --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/presentation/PresentationLayer.java @@ -0,0 +1,421 @@ +package de.thpeetz.network.osi.presentation; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.session.SessionLayer; +import de.thpeetz.network.osi.session.SessionProvider; + +/** + * @author Thomas Peetz + * + */ +public class PresentationLayer implements PresentationProvider, PresentationUser { + private SessionProvider provider; + + public PresentationLayer(boolean manager, AccessPoint ssap, AccessPoint tsap) { + this.provider = new SessionLayer(manager, this, ssap, tsap); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationProvider#connectRequest(com. + * peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, + * com.peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, + * com.peetz.network.osi.AccessPoint, int, com.peetz.network.osi.DataUnit) + */ + public void connectRequest(AccessPoint calledNSAP, AccessPoint calledTSAP, AccessPoint calledSSAP, + AccessPoint callerPSAP, AccessPoint calledPSAP, int qualityOfService, DataUnit userData) { + this.provider.connectRequest(calledNSAP, calledTSAP, 1, null, calledSSAP, qualityOfService, 1, 1, 1, 1, + userData); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationProvider#releaseRequest(com. + * peetz.network.osi.DataUnit) + */ + public void releaseRequest(DataUnit userData) { + this.provider.releaseRequest(userData); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationProvider#dataRequest(com.peetz + * .network.osi.DataUnit) + */ + public void dataRequest(DataUnit userData) { + this.provider.dataRequest(userData); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationProvider#userAbortRequest(com. + * peetz.network.osi.DataUnit) + */ + public void userAbortRequest(DataUnit userData) { + this.provider.userAbortRequest(userData); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#connectIndication(com. + * peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, int, int, + * int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void connectIndication(AccessPoint callingAddress, AccessPoint calledAddress, int qualityOfService, + int representationRequirements, int mode, int sessionRequirements, int initialSPSerialNumber, + int assignmentOfTokens, int sessionConnectionIdentifier, DataUnit userData) { + System.out.println("PresentationLayer#connectIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#connectConfirm(com.peetz. + * network.osi.AccessPoint, int, int, int, int, int, int, + * com.peetz.network.osi.DataUnit) + */ + public void connectConfirm(AccessPoint respondingAddress, int qualityOfService, int representationRequirements, + int sessionRequirements, int initialSPSerialNumber, int assignmentOfTokens, int sessionConnectionIdentifier, + DataUnit userData) { + System.out.println("PresentationLayer#connectConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#userAbortIndication(com. + * peetz.network.osi.DataUnit) + */ + public void userAbortIndication(DataUnit userData) { + System.out.println("PresentationLayer#userAbortIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#providerAbortIndication( + * int) + */ + public void providerAbortIndication(int providerReason) { + System.out.println("PresentationLayer#providerAbortIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#alterContextIndication( + * int, int, int, com.peetz.network.osi.DataUnit) + */ + public void alterContextIndication(int additionList, int deletionList, int additionResultList, DataUnit userData) { + System.out.println("PresentationLayer#alterContextIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#alterContextConfirm(int, + * int, com.peetz.network.osi.DataUnit) + */ + public void alterContextConfirm(int additionResultList, int deletionResultList, DataUnit userData) { + System.out.println("PresentationLayer#alterContextConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#typedDataIndication(com. + * peetz.network.osi.DataUnit) + */ + public void typedDataIndication(DataUnit userData) { + System.out.println("PresentationLayer#typedDataIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#dataIndication(com.peetz. + * network.osi.DataUnit) + */ + public void dataIndication(DataUnit userData) { + System.out.println("PresentationLayer#dataIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#resynchronizeIndication( + * int, int, int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeIndication(int type, int sPSerialNumber, int tokens, DataUnit userData) { + System.out.println("PresentationLayer#resynchronizeIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#resynchronizeConfirm(int, + * int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeConfirm(int sPSerialNumber, int tokens, DataUnit userData) { + System.out.println("PresentationLayer#resynchronizeConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityStartIndication( + * int, com.peetz.network.osi.DataUnit) + */ + public void activityStartIndication(int activityIdentifier, DataUnit userData) { + System.out.println("PresentationLayer#activityStartIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityResumeIndication( + * int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void activityResumeIndication(int activityIdentifier, int oldActivityIdentifier, int sPSerialNumber, + int oldSessionIdentifier, DataUnit userData) { + System.out.println("PresentationLayer#activityResumeIndication"); + } + + /* + * (non-Javadoc) + * + * @see com.peetz.network.osi.presentation.PresentationUser# + * activityInterruptIndication(int, com.peetz.network.osi.DataUnit) + */ + public void activityInterruptIndication(int reason, DataUnit userData) { + System.out.println("PresentationLayer#activityInterruptIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityInterruptConfirm( + * com.peetz.network.osi.DataUnit) + */ + public void activityInterruptConfirm(DataUnit userData) { + System.out.println("PresentationLayer#activityInterruptConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityDiscardIndication + * (int, com.peetz.network.osi.DataUnit) + */ + public void activityDiscardIndication(int reason, DataUnit userData) { + System.out.println("PresentationLayer#activityDiscardIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityDiscardConfirm( + * com.peetz.network.osi.DataUnit) + */ + public void activityDiscardConfirm(DataUnit userData) { + System.out.println("PresentationLayer#activityDiscardConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityEndIndication( + * int, com.peetz.network.osi.DataUnit) + */ + public void activityEndIndication(int sPSerialNumber, DataUnit userData) { + System.out.println("PresentationLayer#activityEndIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#activityEndConfirm(com. + * peetz.network.osi.DataUnit) + */ + public void activityEndConfirm(DataUnit userData) { + System.out.println("PresentationLayer#activityEndConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#capabilityDataIndication( + * com.peetz.network.osi.DataUnit) + */ + public void capabilityDataIndication(DataUnit userData) { + System.out.println("PresentationLayer#capabilityDataIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#capabilityDataConfirm(com + * .peetz.network.osi.DataUnit) + */ + public void capabilityDataConfirm(DataUnit userData) { + System.out.println("PresentationLayer#capabilityDataConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#controlGiveIndication(com + * .peetz.network.osi.DataUnit) + */ + public void controlGiveIndication(DataUnit userData) { + System.out.println("PresentationLayer#controlGiveIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#tokenGiveIndication(com. + * peetz.network.osi.DataUnit) + */ + public void tokenGiveIndication(DataUnit userData) { + System.out.println("PresentationLayer#tokenGiveIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#tokenPleaseIndication( + * int, com.peetz.network.osi.DataUnit) + */ + public void tokenPleaseIndication(int tokens, DataUnit userData) { + System.out.println("PresentationLayer#tokenPleaseIndication"); + } + + /* + * (non-Javadoc) + * + * @see com.peetz.network.osi.presentation.PresentationUser# + * userExceptionReportIndication(int, com.peetz.network.osi.DataUnit) + */ + public void userExceptionReportIndication(int reason, DataUnit userData) { + System.out.println("PresentationLayer#userExceptionReportIndication"); + } + + /* + * (non-Javadoc) + * + * @see com.peetz.network.osi.presentation.PresentationUser# + * providerExceptionReportIndication(int) + */ + public void providerExceptionReportIndication(int reason) { + System.out.println("PresentationLayer#providerExceptionReportIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#expeditedDataIndication( + * com.peetz.network.osi.DataUnit) + */ + public void expeditedDataIndication(DataUnit userData) { + System.out.println("PresentationLayer#expeditedDataIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#syncMinorIndication(int, + * int, com.peetz.network.osi.DataUnit) + */ + public void syncMinorIndication(int type, int sPSerialNumber, DataUnit userData) { + System.out.println("PresentationLayer#syncMinorIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#syncMinorConfirm(int, + * com.peetz.network.osi.DataUnit) + */ + public void syncMinorConfirm(int sPSerialNumber, DataUnit userData) { + System.out.println("PresentationLayer#syncMinorConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#syncMajorIndication(int, + * com.peetz.network.osi.DataUnit) + */ + public void syncMajorIndication(int sPSerialNumber, DataUnit userData) { + System.out.println("PresentationLayer#syncMajorIndication"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#syncMajorConfirm(com. + * peetz.network.osi.DataUnit) + */ + public void syncMajorConfirm(DataUnit userData) { + System.out.println("PresentationLayer#syncMajorConfirm"); + } + + /* + * (non-Javadoc) + * + * @see + * com.peetz.network.osi.presentation.PresentationUser#releaseIndication(com. + * peetz.network.osi.DataUnit) + */ + public void releaseIndication(DataUnit userData) { + System.out.println("PresentationLayer#releaseIndication"); + } + + /* + * (non-Javadoc) + * + * @see com.peetz.network.osi.presentation.PresentationUser#releaseConfirm(int, + * com.peetz.network.osi.DataUnit) + */ + public void releaseConfirm(int result, DataUnit userData) { + System.out.println("PresentationLayer#releaseConfirm"); + } +} diff --git a/src/main/java/de/thpeetz/network/osi/presentation/PresentationProvider.java b/src/main/java/de/thpeetz/network/osi/presentation/PresentationProvider.java new file mode 100644 index 0000000..be34cd5 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/presentation/PresentationProvider.java @@ -0,0 +1,23 @@ +package de.thpeetz.network.osi.presentation; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public interface PresentationProvider extends PresentationService +{ + void connectRequest(AccessPoint calledNSAP, + AccessPoint calledTSAP, + AccessPoint calledSSAP, + AccessPoint callerPSAP, + AccessPoint calledPSAP, + int qualityOfService, + DataUnit userData); + void releaseRequest(DataUnit userData); + void dataRequest(DataUnit userData); + + void userAbortRequest(DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/presentation/PresentationService.java b/src/main/java/de/thpeetz/network/osi/presentation/PresentationService.java new file mode 100644 index 0000000..109d158 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/presentation/PresentationService.java @@ -0,0 +1,11 @@ +package de.thpeetz.network.osi.presentation; + +/** + * Implementation of ITU-T X.226 + * @author Thomas Peetz + * + */ +public interface PresentationService +{ + +} diff --git a/src/main/java/de/thpeetz/network/osi/presentation/PresentationUser.java b/src/main/java/de/thpeetz/network/osi/presentation/PresentationUser.java new file mode 100644 index 0000000..347781c --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/presentation/PresentationUser.java @@ -0,0 +1,64 @@ +package de.thpeetz.network.osi.presentation; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public interface PresentationUser extends PresentationService +{ + void connectIndication(AccessPoint callingAddress, + AccessPoint calledAddress, + int qualityOfService, + int representationRequirements, + int mode, + int sessionRequirements, + int initialSPSerialNumber, + int assignmentOfTokens, + int sessionConnectionIdentifier, + DataUnit userData); + void connectConfirm(AccessPoint respondingAddress, + int qualityOfService, + int representationRequirements, + int sessionRequirements, + int initialSPSerialNumber, + int assignmentOfTokens, + int sessionConnectionIdentifier, + DataUnit userData); + void userAbortIndication(DataUnit userData); + void providerAbortIndication(int providerReason); + void alterContextIndication(int additionList, int deletionList, + int additionResultList, DataUnit userData); + void alterContextConfirm(int additionResultList, int deletionResultList, + DataUnit userData); + void typedDataIndication(DataUnit userData); + void dataIndication(DataUnit userData); + void resynchronizeIndication(int type, int sPSerialNumber, int tokens, DataUnit userData); + void resynchronizeConfirm(int sPSerialNumber, int tokens, DataUnit userData); + void activityStartIndication(int activityIdentifier, DataUnit userData); + void activityResumeIndication(int activityIdentifier, int oldActivityIdentifier, + int sPSerialNumber, int oldSessionIdentifier, + DataUnit userData); + void activityInterruptIndication(int reason, DataUnit userData); + void activityInterruptConfirm(DataUnit userData); + void activityDiscardIndication(int reason, DataUnit userData); + void activityDiscardConfirm(DataUnit userData); + void activityEndIndication(int sPSerialNumber, DataUnit userData); + void activityEndConfirm(DataUnit userData); + void capabilityDataIndication(DataUnit userData); + void capabilityDataConfirm(DataUnit userData); + void controlGiveIndication(DataUnit userData); + void tokenGiveIndication(DataUnit userData); + void tokenPleaseIndication(int tokens, DataUnit userData); + void userExceptionReportIndication(int reason, DataUnit userData); + void providerExceptionReportIndication(int reason); + void expeditedDataIndication(DataUnit userData); + void syncMinorIndication(int type, int sPSerialNumber, DataUnit userData); + void syncMinorConfirm(int sPSerialNumber, DataUnit userData); + void syncMajorIndication(int sPSerialNumber, DataUnit userData); + void syncMajorConfirm(DataUnit userData); + void releaseIndication(DataUnit userData); + void releaseConfirm(int result, DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/session/SessionLayer.java b/src/main/java/de/thpeetz/network/osi/session/SessionLayer.java new file mode 100644 index 0000000..f61324e --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/session/SessionLayer.java @@ -0,0 +1,523 @@ +package de.thpeetz.network.osi.session; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.presentation.PresentationUser; +import de.thpeetz.network.osi.transport.TransportLayer; +import de.thpeetz.network.osi.transport.TransportProvider; + +/** + * @author Thomas Peetz + * + */ +public class SessionLayer implements SessionProvider, SessionUser +{ + private PresentationUser user; + private TransportProvider provider; + @SuppressWarnings("unused") + private AccessPoint ssap; + private AccessPoint tsap; + + public SessionLayer(boolean manager, PresentationUser user, AccessPoint ssap, AccessPoint tsap) + { + this.user = user; + this.provider = new TransportLayer(manager, this, tsap); + this.ssap = ssap; + this.tsap = tsap; + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#connectRequest(com.peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, int, com.peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void connectRequest(AccessPoint calledNSAP, AccessPoint calledTSAP, + int connectionIdentifier, AccessPoint callingSSAP, + AccessPoint calledSSAP, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + this.provider.connectRequest(calledNSAP, calledTSAP, this.tsap, true, 1, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#connectResponse(int, com.peetz.network.osi.AccessPoint, int, int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void connectResponse(int connectionIdentifier, + AccessPoint respondingAddress, int result, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + this.provider.connectResponse(qualityOfService, respondingAddress, true, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#dataRequest(com.peetz.network.osi.DataUnit) + */ + public void dataRequest(DataUnit userData) + { + this.provider.dataRequest(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#expeditedDataRequest(com.peetz.network.osi.DataUnit) + */ + public void expeditedDataRequest(DataUnit userData) + { + this.provider.expeditedDataRequest(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#typedDataRequest(com.peetz.network.osi.DataUnit) + */ + public void typedDataRequest(DataUnit userData) + { + System.out.println("SessionLayer#typedDataRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#capabilityDataRequest(com.peetz.network.osi.DataUnit) + */ + public void capabilityDataRequest(DataUnit userData) + { + System.out.println("SessionLayer#capabilityDataRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#capabilityDataResponse(com.peetz.network.osi.DataUnit) + */ + public void capabilityDataResponse(DataUnit userData) + { + System.out.println("SessionLayer#capabilityDataResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#tokenGiveRequest(int, com.peetz.network.osi.DataUnit) + */ + public void tokenGiveRequest(int tokens, DataUnit userData) + { + System.out.println("SessionLayer#tokenGiveRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#tokenPleaseRequest(int, com.peetz.network.osi.DataUnit) + */ + public void tokenPleaseRequest(int tokens, DataUnit userData) + { + System.out.println("SessionLayer#tokenPleaseRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#controlGiveRequest(com.peetz.network.osi.DataUnit) + */ + public void controlGiveRequest(DataUnit userData) + { + System.out.println("SessionLayer#controlGiveRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#syncMinorRequest(int, int, int, com.peetz.network.osi.DataUnit) + */ + public void syncMinorRequest(int type, int dataSeparation, + int firstSPSerialNumber, DataUnit userdata) + { + System.out.println("SessionLayer#syncMinorRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#syncMinorResponse(int, com.peetz.network.osi.DataUnit) + */ + public void syncMinorResponse(int firstSPSerialNumber, DataUnit userData) + { + System.out.println("SessionLayer#syncMinorResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#syncMajorRequest(int, com.peetz.network.osi.DataUnit) + */ + public void syncMajorRequest(int firstSPSerialNumber, DataUnit userdata) + { + System.out.println("SessionLayer#syncMajorRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#syncMajorResponse(int, com.peetz.network.osi.DataUnit) + */ + public void syncMajorResponse(int secondSPSerialNumber, DataUnit userData) + { + System.out.println("SessionLayer#syncMajorResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#resynchronizeRequest(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeRequest(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata) + { + System.out.println("SessionLayer#resynchronizeRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#resynchronizeResponse(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeResponse(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata) + { + System.out.println("SessionLayer#resynchronizeResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#userExceptionReportRequest(int, com.peetz.network.osi.DataUnit) + */ + public void userExceptionReportRequest(int reason, DataUnit userData) + { + System.out.println("SessionLayer#userExceptionReportRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityStartRequest(int, com.peetz.network.osi.DataUnit) + */ + public void activityStartRequest(int activityIdentifier, DataUnit userData) + { + System.out.println("SessionLayer#activityStartRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityResumeRequest(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void activityResumeRequest(int activityIdentifier, + int oldActivityIdentifier, int firstSPSerialNumber, + int secondSPSerialNumber, int oldSessionConnectionIdentifier, + DataUnit userData) + { + System.out.println("SessionLayer#activityResumeRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityInterruptRequest(com.peetz.network.osi.DataUnit) + */ + public void activityInterruptRequest(DataUnit userData) + { + System.out.println("SessionLayer#activityInterruptRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityInterruptResponse(int, com.peetz.network.osi.DataUnit) + */ + public void activityInterruptResponse(int reason, DataUnit userData) + { + System.out.println("SessionLayer#activityInterruptResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityDiscardRequest(int, com.peetz.network.osi.DataUnit) + */ + public void activityDiscardRequest(int reason, DataUnit userData) + { + System.out.println("SessionLayer#activityDiscardRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityDiscardResponse(com.peetz.network.osi.DataUnit) + */ + public void activityDiscardResponse(DataUnit userData) + { + System.out.println("SessionLayer#activityDiscardResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityEndRequest(int, com.peetz.network.osi.DataUnit) + */ + public void activityEndRequest(int firstSPSerialNumber, DataUnit userData) + { + System.out.println("SessionLayer#activityEndRequest"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#activityEndResponse(int, com.peetz.network.osi.DataUnit) + */ + public void activityEndResponse(int secondSPSerialNumber, DataUnit userData) + { + System.out.println("SessionLayer#activityEndResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#releaseRequest(com.peetz.network.osi.DataUnit) + */ + public void releaseRequest(DataUnit userData) + { + this.provider.disconnectRequest(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#releaseResponse(int, com.peetz.network.osi.DataUnit) + */ + public void releaseResponse(int result, DataUnit userData) + { + System.out.println("SessionLayer#releaseResponse"); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionProvider#userAbortRequest(com.peetz.network.osi.DataUnit) + */ + public void userAbortRequest(DataUnit userData) + { + this.provider.disconnectRequest(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#connectIndication(int, com.peetz.network.osi.AccessPoint, com.peetz.network.osi.AccessPoint, int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void connectIndication(int connectionIdentifier, + AccessPoint callingAddress, AccessPoint calledAddress, + int qualityOfService, int sessionRequirements, + int firstSPSerialNumber, int secondSPSerialNumber, + int assignmentOfTokens, DataUnit userData) + { + this.user.connectIndication(callingAddress, calledAddress, qualityOfService, 1, 1, sessionRequirements, firstSPSerialNumber, assignmentOfTokens, 1, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#connectConfirm(int, com.peetz.network.osi.AccessPoint, int, int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void connectConfirm(int connectionIdentifier, + AccessPoint respondingAddress, int result, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + this.user.connectConfirm(respondingAddress, qualityOfService, 1, sessionRequirements, firstSPSerialNumber, assignmentOfTokens, 1, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#dataIndication(com.peetz.network.osi.DataUnit) + */ + public void dataIndication(DataUnit userData) + { + this.user.dataIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#expeditedDataIndication(com.peetz.network.osi.DataUnit) + */ + public void expeditedDataIndication(DataUnit userData) + { + this.user.expeditedDataIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#typedDataIndication(com.peetz.network.osi.DataUnit) + */ + public void typedDataIndication(DataUnit userData) + { + this.user.typedDataIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#capabilityDataIndication(com.peetz.network.osi.DataUnit) + */ + public void capabilityDataIndication(DataUnit userData) + { + this.user.capabilityDataIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#capabilityDataConfirm(com.peetz.network.osi.DataUnit) + */ + public void capabilityDataConfirm(DataUnit userData) + { + this.user.capabilityDataConfirm(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#tokenGiveIndication(int, com.peetz.network.osi.DataUnit) + */ + public void tokenGiveIndication(int tokens, DataUnit userData) + { + this.user.tokenGiveIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#tokenPleaseIndication(int, com.peetz.network.osi.DataUnit) + */ + public void tokenPleaseIndication(int tokens, DataUnit userData) + { + this.user.tokenPleaseIndication(tokens, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#controlGiveIndication(com.peetz.network.osi.DataUnit) + */ + public void controlGiveIndication(DataUnit userData) + { + this.user.controlGiveIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#syncMinorIndication(int, int, int, com.peetz.network.osi.DataUnit) + */ + public void syncMinorIndication(int type, int dataSeparation, + int firstSPSerialNumber, DataUnit userData) + { + this.user.syncMinorIndication(type, firstSPSerialNumber, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#syncMinorConfirm(int, com.peetz.network.osi.DataUnit) + */ + public void syncMinorConfirm(int firstSPSerialNumber, DataUnit userData) + { + this.user.syncMinorConfirm(firstSPSerialNumber, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#syncMajorIndication(int, com.peetz.network.osi.DataUnit) + */ + public void syncMajorIndication(int firstSPSerialNumber, DataUnit userData) + { + this.user.syncMajorIndication(firstSPSerialNumber, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#syncMajorConfirm(int, com.peetz.network.osi.DataUnit) + */ + public void syncMajorConfirm(int secondSPSerialNumber, DataUnit userData) + { + this.user.syncMajorConfirm(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#resynchronizeIndication(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeIndication(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + this.user.resynchronizeIndication(firstResynchronizeType, firstResynchronizeType, assignmentOfTokens, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#resynchronizeConfirm(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void resynchronizeConfirm(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + this.user.resynchronizeConfirm(firstSPSerialNumber, assignmentOfTokens, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#providerExceptionReportIndication(int) + */ + public void providerExceptionReportIndication(int reason) + { + this.user.providerExceptionReportIndication(reason); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#userExceptionReportIndication(int, com.peetz.network.osi.DataUnit) + */ + public void userExceptionReportIndication(int reason, DataUnit userData) + { + this.user.userExceptionReportIndication(reason, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityStartIndication(int, com.peetz.network.osi.DataUnit) + */ + public void activityStartIndication(int activityIdentifier, + DataUnit userData) + { + this.user.activityStartIndication(activityIdentifier, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityResumeIndication(int, int, int, int, int, com.peetz.network.osi.DataUnit) + */ + public void activityResumeIndication(int activityIdentifier, + int oldActivityIdentifier, int firstSPSerialNumber, + int secondSPSerialNumber, int oldSessionConnectionIdentifier, + DataUnit userData) + { + this.user.activityResumeIndication(activityIdentifier, oldActivityIdentifier, firstSPSerialNumber, oldSessionConnectionIdentifier, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityInterruptIndication(com.peetz.network.osi.DataUnit) + */ + public void activityInterruptIndication(DataUnit userData) + { + this.user.activityInterruptIndication(1, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityInterruptConfirm(int, com.peetz.network.osi.DataUnit) + */ + public void activityInterruptConfirm(int reason, DataUnit userData) + { + this.user.activityInterruptConfirm(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityDiscardIndication(int, com.peetz.network.osi.DataUnit) + */ + public void activityDiscardIndication(int reason, DataUnit userData) + { + this.user.activityDiscardIndication(reason, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityDiscardConfirm(com.peetz.network.osi.DataUnit) + */ + public void activityDiscardConfirm(DataUnit userData) + { + this.user.activityDiscardConfirm(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityEndIndication(int, com.peetz.network.osi.DataUnit) + */ + public void activityEndIndication(int firstSPSerialNumber, DataUnit userData) + { + this.user.activityEndIndication(firstSPSerialNumber, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#activityEndConfirm(int, com.peetz.network.osi.DataUnit) + */ + public void activityEndConfirm(int secondSPSerialNumber, DataUnit userData) + { + this.user.activityEndConfirm(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#releaseIndication(com.peetz.network.osi.DataUnit) + */ + public void releaseIndication(DataUnit userData) + { + this.user.releaseIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#releaseConfirm(int, com.peetz.network.osi.DataUnit) + */ + public void releaseConfirm(int result, DataUnit userData) + { + this.user.releaseConfirm(result, userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#userAbortIndication(com.peetz.network.osi.DataUnit) + */ + public void userAbortIndication(DataUnit userData) + { + this.user.userAbortIndication(userData); + } + + /* (non-Javadoc) + * @see com.peetz.network.osi.session.SessionUser#providerAbortIndication(int, com.peetz.network.osi.DataUnit) + */ + public void providerAbortIndication(int reason, DataUnit userData) + { + this.user.providerAbortIndication(reason); + } +} diff --git a/src/main/java/de/thpeetz/network/osi/session/SessionProvider.java b/src/main/java/de/thpeetz/network/osi/session/SessionProvider.java new file mode 100644 index 0000000..52acec0 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/session/SessionProvider.java @@ -0,0 +1,82 @@ +package de.thpeetz.network.osi.session; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public interface SessionProvider extends SessionService +{ + void connectRequest(AccessPoint calledNSAP, AccessPoint calledTSAP, + int connectionIdentifier, AccessPoint callingSSAP, + AccessPoint calledSSAP, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData); + + void connectResponse(int connectionIdentifier, + AccessPoint respondingAddress, int result, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData); + + void dataRequest(DataUnit userData); + + void expeditedDataRequest(DataUnit userData); + + void typedDataRequest(DataUnit userData); + + void capabilityDataRequest(DataUnit userData); + + void capabilityDataResponse(DataUnit userData); + + void tokenGiveRequest(int tokens, DataUnit userData); + + void tokenPleaseRequest(int tokens, DataUnit userData); + + void controlGiveRequest(DataUnit userData); + + void syncMinorRequest(int type, int dataSeparation, + int firstSPSerialNumber, DataUnit userdata); + + void syncMinorResponse(int firstSPSerialNumber, DataUnit userData); + + void syncMajorRequest(int firstSPSerialNumber, DataUnit userdata); + + void syncMajorResponse(int secondSPSerialNumber, DataUnit userData); + + void resynchronizeRequest(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata); + + void resynchronizeResponse(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata); + + void userExceptionReportRequest(int reason, DataUnit userData); + + void activityStartRequest(int activityIdentifier, DataUnit userData); + + void activityResumeRequest(int activityIdentifier, + int oldActivityIdentifier, int firstSPSerialNumber, + int secondSPSerialNumber, int oldSessionConnectionIdentifier, + DataUnit userData); + + void activityInterruptRequest(DataUnit userData); + + void activityInterruptResponse(int reason, DataUnit userData); + + void activityDiscardRequest(int reason, DataUnit userData); + + void activityDiscardResponse(DataUnit userData); + + void activityEndRequest(int firstSPSerialNumber, DataUnit userData); + + void activityEndResponse(int secondSPSerialNumber, DataUnit userData); + + void releaseRequest(DataUnit userData); + + void releaseResponse(int result, DataUnit userData); + + void userAbortRequest(DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/session/SessionService.java b/src/main/java/de/thpeetz/network/osi/session/SessionService.java new file mode 100644 index 0000000..915d1bc --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/session/SessionService.java @@ -0,0 +1,160 @@ +package de.thpeetz.network.osi.session; + +/** + * @author Thomas Peetz + * + */ +public interface SessionService +{ + // category 0 + /** + * GIVE TOKEN SPDU + */ + byte GT_SPDU = 0x01; + /** + * PLEASE TOKEN SPDU + */ + byte PT_SPDU = 0x02; + + // category 1 + /** + * CONNECT SPDU + */ + byte CN_SPDU = 0x0D; + /** + * OVERFLOW ACCEPT SPDU + */ + byte OA_SPDU = 0x10; + /** + * CONNECT DATA OVERFLOW SPDU + */ + byte CDO_SPDU = 0x0F; + /** + * ACCEPT SPDU + */ + byte AC_SPDU = 0x0E; + /** + * REFUSE SPDU + */ + byte RF_SPDU = 0x0C; + /** + * FINISH SPDU + */ + byte FN_SPDU = 0x09; + /** + * DISCONNECT SPDU + */ + byte DN_SPDU = 0x0A; + /** + * NOT FINISHED SPDU + */ + byte NF_SPDU = 0x08; + /** + * ABORT SPDU + */ + byte AB_SPDU = 0x19; + /** + * ABORT ACCEPT SPDU + */ + byte AA_SPDU = 0x1A; + /** + * GIVE TOKENS CONFIRM SPDU + */ + byte GTC_SPDU = 0x15; + /** + * GIVE TOKEN ACK SPDU + */ + byte GTA_SPDU = 0x16; + /** + * PREPARE SPDU + */ + byte PR_SPDU = 0x07; + /** + * TYPED DATA SPDU + */ + byte TD_SPDU = 0x21; + + // category 2 + + /** + * DATA TRANSFER SPDU + */ + byte DT_SPDU = 0x01; + /** + * MINOR SYNC POINT SPDU + */ + byte MIP_SPDU = 0x31; + /** + * MINOR SYNC ACK SPDU + */ + byte MIA_SPDU = 0x32; + /** + * MAJOR SYNC POINT SPDU + */ + byte MAP_SPDU = 0x29; + /** + * MAJOR SYNC ACK SPDU + */ + byte MAA_SPDU = 0x2A; + /** + * RESYNCHRONIZE SPDU + */ + byte RS_SPDU = 0x35; + /** + * RESYNCHRONIZE ACK SPDU + */ + byte RA_SPDU = 0x22; + /** + * ACTIVITY START SPDU + */ + byte AS_SPDU = 0x2D; + /** + * ACTIVITY RESUME SPDU + */ + byte AR_SPDU = 0x1D; + /** + * ACTIVITY DISCARD SPDU + */ + byte AD_SPDU = 0x39; + /** + * ACTIVITY DISCARD ACK SPDU + */ + byte ADA_SPDU = 0x3A; + /** + * ACTIVITY INTERRUPT SPDU + */ + byte AI_SPDU = 0x19; + /** + * ACTIVITY INTERRUPT ACK SPDU + */ + byte AIA_SPDU = 0x1A; + /** + * ACTIVITY END SPDU + */ + byte AE_SPDU = 0x29; + /** + * ACTIVITY END ACK + */ + byte AEA_SPDU = 0x2A; + /** + * CAPABILITY DATA SPDU + */ + byte CD_SPDU = 0x3D; + /** + * CAPABILITY DATA ACK SPDU + */ + byte CDA_SPDU = 0x3E; + /** + * EXCEPTION REPORT SPDU + */ + byte ER_SPDU = 0x00; + /** + * EXCEPTION DATA SPDU + */ + byte ED_SPDU = 0x30; + + /** + * EXPEDITED SPDU + */ + byte EX_SPDU = 0x05; +} diff --git a/src/main/java/de/thpeetz/network/osi/session/SessionUser.java b/src/main/java/de/thpeetz/network/osi/session/SessionUser.java new file mode 100644 index 0000000..89c43a9 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/session/SessionUser.java @@ -0,0 +1,87 @@ +package de.thpeetz.network.osi.session; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public interface SessionUser extends SessionService +{ + void connectIndication(int connectionIdentifier, + AccessPoint callingAddress, AccessPoint calledAddress, + int qualityOfService, int sessionRequirements, + int firstSPSerialNumber, int secondSPSerialNumber, + int assignmentOfTokens, DataUnit userData); + + void connectConfirm(int connectionIdentifier, + AccessPoint respondingAddress, int result, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData); + + void dataIndication(DataUnit userData); + + void expeditedDataIndication(DataUnit userData); + + void typedDataIndication(DataUnit userData); + + void capabilityDataIndication(DataUnit userData); + + void capabilityDataConfirm(DataUnit userData); + + void tokenGiveIndication(int tokens, DataUnit userData); + + void tokenPleaseIndication(int tokens, DataUnit userData); + + void controlGiveIndication(DataUnit userData); + + void syncMinorIndication(int type, int dataSeparation, + int firstSPSerialNumber, DataUnit userData); + + void syncMinorConfirm(int firstSPSerialNumber, DataUnit userData); + + void syncMajorIndication(int firstSPSerialNumber, DataUnit userData); + + void syncMajorConfirm(int secondSPSerialNumber, DataUnit userData); + + void resynchronizeIndication(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData); + + void resynchronizeConfirm(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData); + + void providerExceptionReportIndication(int reason); + + void userExceptionReportIndication(int reason, DataUnit userData); + + void activityStartIndication(int activityIdentifier, + DataUnit userData); + + void activityResumeIndication(int activityIdentifier, + int oldActivityIdentifier, int firstSPSerialNumber, + int secondSPSerialNumber, int oldSessionConnectionIdentifier, + DataUnit userData); + + void activityInterruptIndication(DataUnit userData); + + void activityInterruptConfirm(int reason, DataUnit userData); + + void activityDiscardIndication(int reason, DataUnit userData); + + void activityDiscardConfirm(DataUnit userData); + + void activityEndIndication(int firstSPSerialNumber, DataUnit userData); + + void activityEndConfirm(int secondSPSerialNumber, DataUnit userData); + + void releaseIndication(DataUnit userData); + + void releaseConfirm(int result, DataUnit userData); + + void userAbortIndication(DataUnit userData); + + void providerAbortIndication(int reason, DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/DataService.java b/src/main/java/de/thpeetz/network/osi/transport/DataService.java new file mode 100644 index 0000000..7f1c1cf --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/DataService.java @@ -0,0 +1,24 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.DataUnit; + +public interface DataService +{ + /** + * + * @param telegram + */ + void eventReceive(DataUnit telegram); + + /** + * eventSessionDown + * + */ + void eventSessionDown(); + + /** + * + * + */ + void eventClose(); +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/RFC1006Service.java b/src/main/java/de/thpeetz/network/osi/transport/RFC1006Service.java new file mode 100644 index 0000000..00d55d5 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/RFC1006Service.java @@ -0,0 +1,102 @@ +package de.thpeetz.network.osi.transport; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.UnknownHostException; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.logging.Level; +import java.util.logging.Logger; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public class RFC1006Service { + public static final int RFC1006PORT = 102; + + private boolean manager = false; + + @SuppressWarnings("unused") + private boolean serverRun = true; + + private Socket socket; + + private TransportUser user; + + Logger logger; + + /** + * Construct instance of RFC1006Service. This connects OSI-stack to sockets. + * @param manager This value ist true when the stack is in manager mode. + * @param user Reference to upper layer. + */ + public RFC1006Service(boolean manager, TransportUser user) { + this.manager = manager; + this.user = user; + if (this.manager) { + // TODO start socket in server mode + } + logger = Logger.getLogger(RFC1006Service.class.getName()); + } + + public void close() { + this.serverRun = false; + } + + public void listen() { + try (ServerSocket server = new ServerSocket()) { + server.bind(new InetSocketAddress("127.0.0.1", RFC1006PORT)); + server.accept(); + System.out.println("127.0.0.1:102 accepted"); + } catch (IOException e) { + logger.log(Level.FINE, e.getMessage()); + } + } + + public void connect(AccessPoint calledNSAP, DataUnit userData) { + try { + final String host = new String(calledNSAP.getData()); + //System.out.println("opening connection on " + host + " port " + rfc1006Port); + + // Opening a socket connection may require to leave the sandbox. + socket = (Socket)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Object result = null; + + try { + result = new Socket(host, RFC1006PORT); + } catch (UnknownHostException exUnknownHost) { + } catch (IOException exIO) { + } + + return result; + } + }); + + if (socket != null) { +// receiveQueue = new TelegramReceiveThread(socket, this); +// receiveQueue.start(); +// sendQueue = new TelegramSendThread(socket, this); +// sendQueue.start(); + userData.write((byte)userData.getLength()); +// writeRFC1006Header(userData); +// sendQueue.pushTelegram(userData); + } else { + user.disconnectIndication(1, null); +// eventSessionDown(); + } + } +// +// catch (IOException exIO) +// { +// eventSessionDown(); +// } + finally { } + } +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/TransportLayer.java b/src/main/java/de/thpeetz/network/osi/transport/TransportLayer.java new file mode 100644 index 0000000..1cdb07a --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/TransportLayer.java @@ -0,0 +1,213 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.session.SessionUser; + +/** + * @author Thomas Peetz + * + */ +public class TransportLayer extends TransportService implements TransportProvider, TransportUser { + /** + * + */ + private SessionUser user; + + /** + * + */ + private RFC1006Service service; + + /** + * + */ + @SuppressWarnings("unused") + private AccessPoint tsap; + + /** + * Only constructor for TransportLayer. + * @param manager Should the stack be in manager or agent mode? + * @param user Reference to upper layer + * @param tsap address of transport layer + */ + public TransportLayer(final boolean manager, final SessionUser user, final AccessPoint tsap) { + this.user = user; + this.service = new RFC1006Service(manager, this); + this.tsap = tsap; + } + + /** + * Request to open a connection to peer transport layer. + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportProvider#connectRequest + * (de.thpeetz.network.osi.peetz.network.osi.AccessPoint, de.thpeetz.network.osi.peetz.network.osi.AccessPoint, + * de.thpeetz.network.osi.peetz.network.osi.AccessPoint, boolean, int, de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param calledNSAP NSAP address of peer network layer + * @param calledTSAP TSAP address of peer transport layer + * @param callerTSAP TSAP address of this transport layer + * @param expeditedDataOption expedited data mode? + * @param qualityOfService mode of QoS? + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void connectRequest(final AccessPoint calledNSAP, final AccessPoint calledTSAP, + final AccessPoint callerTSAP, final boolean expeditedDataOption, + final int qualityOfService, final DataUnit userData) { + System.out.println("TransportLayer#connectRequest"); + userData.write(calledTSAP.getData()); + userData.write(calledTSAP.getLength()); + userData.write((byte) 0xc2); + userData.write(callerTSAP.getData()); + userData.write(callerTSAP.getLength()); + userData.write((byte) 0xc1); + userData.write((byte) 0x0f); + userData.write((byte) 0x01); + userData.write((byte) 0xc0); + userData.write((byte) 0x00); // class option + userData.write(1); // src-ref + userData.write(0); // dst-ref + userData.write((byte) 0xe0); + service.connect(calledNSAP, userData); + } + + /** + * This message is sent when a requested connection is established. + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportProvider#connectResponse + * (int, de.thpeetz.network.osi.peetz.network.osi.AccessPoint, boolean, de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param respondingAddress + * The parameter usually matches the called address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void connectResponse(final int qualityOfService, + final AccessPoint respondingAddress, final boolean expeditedDataOption, + final DataUnit userData) { + System.out.println("TransportLayer#connectResponse"); + } + + /** + * Request disconnect from peer. + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportProvider#disconnectRequest(de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void disconnectRequest(final DataUnit userData) { + System.out.println("TransportLayer#disconnectRequest"); + byte[] drTpdu = new byte[7]; + drTpdu[0] = (byte) 0x06; + drTpdu[1] = (byte) 0xC0; + drTpdu[2] = (byte) 0x00; + drTpdu[3] = (byte) 0x00; + drTpdu[4] = (byte) 0x00; + drTpdu[5] = (byte) 0x01; + drTpdu[6] = (byte) 0x00; + userData.setToWrite(); + userData.write(drTpdu); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportProvider#dataRequest(de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void dataRequest(final DataUnit userData) { + System.out.println("TransportLayer#dataRequest"); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportProvider#expeditedDataRequest(de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void expeditedDataRequest(final DataUnit userData) { + System.out.println("TransportLayer#expeditedDataRequest"); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportUser#connectConfirm + * (int, de.thpeetz.network.osi.peetz.network.osi.AccessPoint, boolean, de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param respondingAddress + * The parameter usually matches the called address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void connectConfirm(final int qualityOfService, + final AccessPoint respondingAddress, final boolean expeditedDataOption, + final DataUnit userData) { + this.user.connectConfirm(1, respondingAddress, 1, qualityOfService, 1, 1, 1, 1, userData); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportUser#connectIndication + * (de.thpeetz.network.osi.peetz.network.osi.AccessPoint, + * de.thpeetz.network.osi.peetz.network.osi.AccessPoint, boolean, int, de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param calledAddress + * The parameter usually matches the called address. + * @param callingAddress + * The parameter usually matches the callers address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void connectIndication(final AccessPoint calledAddress, + final AccessPoint callingAddress, final boolean expeditedDataOption, + final int qualityOfService, final DataUnit userData) { + this.user.connectIndication(1, callingAddress, calledAddress, qualityOfService, 1, 1, 1, 1, userData); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportUser#disconnectIndication(int, de.thpeetz.network.osi.DataUnit) + * @param disconnectReason + * Gives reason for disconnecting. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void disconnectIndication(final int disconnectReason, final DataUnit userData) { + this.user.releaseIndication(userData); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportUser#dataIndication(de.thpeetz.network.osi.DataUnit) + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void dataIndication(final DataUnit userData) { + this.user.dataIndication(userData); + } + + /** + * @see de.thpeetz.network.osi.transport.peetz.network.osi.transport.TransportUser#expeditedDataIndication(de.thpeetz.network.osi.peetz.network.osi.DataUnit) + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + public final void expeditedDataIndication(final DataUnit userData) { + this.user.expeditedDataIndication(userData); + } +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/TransportProvider.java b/src/main/java/de/thpeetz/network/osi/transport/TransportProvider.java new file mode 100644 index 0000000..b3f299f --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/TransportProvider.java @@ -0,0 +1,74 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * Methods provided by transport layer. Interface to upper layer. + * @author Thomas Peetz + */ +public interface TransportProvider { + /** + * Request a connection to corresponding transport layer peer. + * @param calledNSAP + * NSAP address to be called. + * @param calledTSAP + * TSAP address to be called. + * @param callerTSAP + * TSAP address of connection requester. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void connectRequest(AccessPoint calledNSAP, AccessPoint calledTSAP, + AccessPoint callerTSAP, boolean expeditedDataOption, + int qualityOfService, DataUnit userData); + + /** + * Confirm a requested connection. + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param respondingAddress + * The parameter usually matches the called address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void connectResponse(int qualityOfService, + AccessPoint respondingAddress, boolean expeditedDataOption, + DataUnit userData); + + /** + * Request a disconnect from peer. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void disconnectRequest(DataUnit userData); + + /** + * Send message to peer. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void dataRequest(DataUnit userData); + + /** + * Send message to peer. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void expeditedDataRequest(DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/TransportService.java b/src/main/java/de/thpeetz/network/osi/transport/TransportService.java new file mode 100644 index 0000000..f2c3354 --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/TransportService.java @@ -0,0 +1,48 @@ +package de.thpeetz.network.osi.transport; + +/** + * Definitions for transport layer. + * @author Thomas Peetz + */ +public abstract class TransportService { + /** + * Connection Request TPDU. + */ + public static final int CR_TPDU = 0xE0; + /** + * Connection Confirm TPDU. + */ + public static final int CC_TPDU = 0xD0; + /** + * Disconnect Request TPDU. + */ + public static final int DR_TPDU = 0x80; + /** + * Disconnect Confirm TPDU. + */ + public static final int DC_TPDU = 0xC0; + /** + * Data TPDU. + */ + public static final int DT_TPDU = 0xF0; + /** + * Expedited Data TPDU. + */ + public static final int ED_TPDU = 0x10; + /** + * Data Acknowledge TPDU. + */ + public static final int AK_TPDU = 0x60; + /** + * Expedited Acknowledge TPDU. + */ + public static final int EA_TPDU = 0x20; + /** + * Reject TPDU. + */ + public static final int RJ_TPDU = 0x50; + /** + * Error TPDU. + */ + public static final int ER_TPDU = 0x70; +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/TransportUser.java b/src/main/java/de/thpeetz/network/osi/transport/TransportUser.java new file mode 100644 index 0000000..3ef5fdb --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/TransportUser.java @@ -0,0 +1,78 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +/** + * @author Thomas Peetz + * + */ +public interface TransportUser { + /** + * connectConfirm. + * + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param respondingAddress + * The parameter usually matches the called address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void connectConfirm(int qualityOfService, + AccessPoint respondingAddress, boolean expeditedDataOption, + DataUnit userData); + + /** + * connectIndication. + * + * @param calledAddress + * The calledAddress parameter conveyes the address of the TSAP + * to which the connection is to be established. + * @param callingAddress + * The callingAddress parameter conveyes the address of the TSAP + * from which the connection has been requested. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void connectIndication(AccessPoint calledAddress, + AccessPoint callingAddress, boolean expeditedDataOption, + int qualityOfService, DataUnit userData); + + /** + * disconnectindication. + * @param disconnectReason + * Gives reason for disconnecting. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void disconnectIndication(int disconnectReason, DataUnit userData); + + /** + * Receives data from peer. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void dataIndication(DataUnit userData); + + /** + * expeditedDataIndication. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void expeditedDataIndication(DataUnit userData); +} diff --git a/src/main/java/de/thpeetz/network/osi/transport/User.java b/src/main/java/de/thpeetz/network/osi/transport/User.java new file mode 100644 index 0000000..aec0a8e --- /dev/null +++ b/src/main/java/de/thpeetz/network/osi/transport/User.java @@ -0,0 +1,25 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; + +public interface User { + /** + * connectConfirm. + * + * @param qualityOfService + * The qualityOfService parameter describes the possible + * quality of service value. + * @param respondingAddress + * The parameter usually matches the called address. + * @param expeditedDataOption + * The expeditedDataOption parameter indicates wether the + * expedited data option is to be available on the connection. + * @param userData + * This parameter allows the transfer of user-data between users + * without modification by the transport service provider. + */ + void connectConfirm(int qualityOfService, + AccessPoint respondingAddress, boolean expeditedDataOption, + DataUnit userData); +} \ No newline at end of file diff --git a/src/main/java/de/thpeetz/tools/ObjectPool.java b/src/main/java/de/thpeetz/tools/ObjectPool.java new file mode 100644 index 0000000..1aae913 --- /dev/null +++ b/src/main/java/de/thpeetz/tools/ObjectPool.java @@ -0,0 +1,97 @@ +package de.thpeetz.tools; + +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; + +import de.thpeetz.network.osi.transport.RFC1006Service; + +/** + * @author Thomas Peetz + * + * @param type of objects in ObjectPool + */ +public class ObjectPool { + /** + * Vector of unused object references. + */ + private final Vector freeStack; + + Logger logger; + + /** + * Construct an object pool for a specific class type. + * + * @param clazz + * Class type of object pool + * @throws IllegalAccessException + * @throws InstantiationException + */ + public ObjectPool(final Class clazz) { + this.freeStack = new Vector(); + init(clazz); + logger = Logger.getLogger(ObjectPool.class.getName()); + + } + + /************************************************************************** + * Construct an object pool for a specific class type. Initialize object + * pool with given number of objects. + * + * @param clazz + * Class type of object pool + * @param size + * Initial number of objects in pool + * @throws IllegalAccessException + * @throws InstantiationException + ***************************************************************************/ + public ObjectPool(final Class clazz, final int size) { + this.freeStack = new Vector(size); + init(clazz); + } + + /************************************************************************** + * Construct an object pool for a specific class type. Initialize object + * pool with number of objects equal to stack size. + * + * @param clazz + * Class type of object pool + ***************************************************************************/ + private void init(final Class clazz) { + for (int i = 0; i < freeStack.capacity(); i++) { + try { + freeStack.add(i, clazz.newInstance()); + } catch (InstantiationException e) { + logger.log(Level.FINE, e.getMessage()); + } catch (IllegalAccessException e) { + logger.log(Level.FINE, e.getMessage()); + } + } + } + + /** + * Get instance from object pool. + * + * @return Reference of object + */ + public final synchronized T getInstance() { + // Check if the pool is empty. + if (this.freeStack.isEmpty()) { + return null; + } + // Remove object from end of free pool. + T result = this.freeStack.lastElement(); + this.freeStack.setSize(this.freeStack.size() - 1); + return result; + } + + /************************************************************************** + * Return object to object pool. + * + * @param obj + * Reference of unsed object + ***************************************************************************/ + public final synchronized void freeInstance(final T obj) { + this.freeStack.addElement(obj); + } +} diff --git a/src/test/java/com/ibtp/network/osi/LibraryTest.java b/src/test/java/com/ibtp/network/osi/LibraryTest.java deleted file mode 100644 index d6fc097..0000000 --- a/src/test/java/com/ibtp/network/osi/LibraryTest.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This Java source file was generated by the Gradle 'init' task. - */ -package com.ibtp.network.osi; - -import org.junit.Test; -import static org.junit.Assert.*; - -public class LibraryTest { - @Test public void testSomeLibraryMethod() { - Library classUnderTest = new Library(); - assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod()); - } -} diff --git a/src/test/java/de/thpeetz/network/osi/AccessPointTest.java b/src/test/java/de/thpeetz/network/osi/AccessPointTest.java new file mode 100644 index 0000000..00fabce --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/AccessPointTest.java @@ -0,0 +1,45 @@ +package de.thpeetz.network.osi; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +public class AccessPointTest { + + @Test + void testAccessPoint() { + AccessPoint ap = new AccessPoint(); + assertNotNull(ap); + } + + @Test + void testAccessPointString() { + AccessPoint ap = new AccessPoint("ap12"); + assertEquals("ap12", ap.getString()); + } + + @Test + void testGetString() { + AccessPoint ap = new AccessPoint("ap12"); + assertEquals("ap12", ap.getString()); + } + + @Test + void testGetData() { + AccessPoint ap = new AccessPoint("ap12"); + assertEquals(4, ap.getData().length); + byte[] expected = {97, 112, 49,50}; + int i=0; + for (byte b : expected) { + assertEquals(b, ap.getData()[i]); + i++; + } + } + + @Test + void testGetLength() { + AccessPoint ap = new AccessPoint("ap12"); + assertEquals(4, ap.getData().length); + } +} diff --git a/src/test/java/de/thpeetz/network/osi/DataUnitManagerTest.java b/src/test/java/de/thpeetz/network/osi/DataUnitManagerTest.java new file mode 100644 index 0000000..ee5ecbb --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/DataUnitManagerTest.java @@ -0,0 +1,56 @@ +package de.thpeetz.network.osi; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * @author tpeetz + * + */ +public class DataUnitManagerTest { + + /** + * Test method for + * {@link de.thpeetz.network.osi.DataUnitManager#DataUnitManager()}. + */ + @Test + public void testDataUnitManager() { + DataUnitManager manager = new DataUnitManager(); + assertNotNull(manager); + } + + /** + * Test method for + * {@link de.thpeetz.network.osi.DataUnitManager#getManager()}. + */ + @Test + public void testGetManager() { + DataUnitManager manager = DataUnitManager.getManager(); + assertNotNull(manager); + } + + /** + * Test method for + * {@link de.thpeetz.network.osi.DataUnitManager#getInstance()}. + */ + @Test + public void testGetInstance() { + DataUnit unit = DataUnitManager.getInstance(); + assertNotNull(unit); + } + + /** + * Test method for + * {@link de.thpeetz.network.osi.DataUnitManager#freeInstance(de.thpeetz.network.osi.DataUnit)} + * . + */ + @Test + @Disabled + public void testFreeInstance() { + DataUnit unit = DataUnitManager.getInstance(); + assertNotNull(unit); + DataUnitManager.freeInstance(unit); + } +} diff --git a/src/test/java/de/thpeetz/network/osi/DataUnitTest.java b/src/test/java/de/thpeetz/network/osi/DataUnitTest.java new file mode 100644 index 0000000..96990b0 --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/DataUnitTest.java @@ -0,0 +1,148 @@ +package de.thpeetz.network.osi; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +public class DataUnitTest{ + + /* + * Test method for 'com.peetz.network.osi.DataUnit.DataUnit()' + */ + @Test + public void testDataUnit() { + DataUnit data = new DataUnit(); + assertNotNull(data); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.initialize(byte[])' + */ + @Test + public void testInitializeByteArray() { + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.initialize()' + */ + @Test + public void testInitialize() { + DataUnit data = new DataUnit(); + data.initialize(); + assertEquals(0, data.getLength()); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.addBuffer(byte[])' + */ + @Test + public void testAddBuffer() { + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.setToWrite()' + */ + @Test + public void testSetToWrite() { + DataUnit data = new DataUnit(); + data.setToWrite(); + assertEquals(data.getLength(), 0); + data.write(3); + assertEquals(data.getLength(), 2); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.setToRead()' + */ + @Test + public void testSetToRead() { + DataUnit data = new DataUnit(); + data.setToRead(); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.write(byte[])' + */ + @Test + public void testWriteByteArray() { + DataUnit data = new DataUnit(); + data.setToWrite(); + assertEquals(data.getLength(), 0); + data.write(new byte[]{ (byte) 0x01, (byte) 0x03}); + assertEquals(2, data.getLength()); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.write(byte)' + */ + @Test + public void testWriteByte() { + DataUnit data = new DataUnit(); + data.setToWrite(); + assertEquals(data.getLength(), 0); + data.write( (byte) 0x05); + assertEquals(1, data.getLength()); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.write(int)' + */ + @Test + public void testWriteInt() { + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.read()' + */ + @Test + public void testRead() { + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.read(int)' + */ + @Test + public void testReadInt() { + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.readInt()' + */ + @Test + public void testReadInt1() { + DataUnit data = new DataUnit(); + data.setToWrite(); + data.write(5); + assertEquals(data.readInt(), 5); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.getBuffer()' + */ + @Test + public void testGetBuffer() { + DataUnit data = new DataUnit(); + byte[] buffer = data.getBuffer(); + assertNotNull(buffer); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.getBuffer(int)' + */ + @Test + public void testGetBufferInt() { + DataUnit data = new DataUnit(); + byte[] buffer = data.getBuffer(3); + assertEquals(buffer.length, 3); + } + + /* + * Test method for 'com.peetz.network.osi.DataUnit.getLength()' + */ + @Test + public void testGetLength() { + DataUnit data = new DataUnit(); + assertEquals(data.getLength(), 0); + } +} diff --git a/src/test/java/de/thpeetz/network/osi/OsiTests.java b/src/test/java/de/thpeetz/network/osi/OsiTests.java new file mode 100644 index 0000000..53767a6 --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/OsiTests.java @@ -0,0 +1,9 @@ +package de.thpeetz.network.osi; + +public class OsiTests +{ + public static AccessPoint calledNSAP = new AccessPoint("127.0.0.1"); + public static AccessPoint calledTSAP = new AccessPoint("tl2"); + public static AccessPoint callerTSAP = new AccessPoint("tl1"); + public static AccessPoint callerSSAP = new AccessPoint("sl1"); +} diff --git a/src/test/java/de/thpeetz/network/osi/presentation/PresentationLayerTest.java b/src/test/java/de/thpeetz/network/osi/presentation/PresentationLayerTest.java new file mode 100644 index 0000000..ad6d7cc --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/presentation/PresentationLayerTest.java @@ -0,0 +1,445 @@ +package de.thpeetz.network.osi.presentation; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.DataUnitManager; +import de.thpeetz.network.osi.OsiTests; + +public class PresentationLayerTest { + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.PresentationLayer()' + */ + @Test + public final void testPresentationLayer() { + PresentationLayer layer = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + assertNotNull(layer); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.connectRequest(AccessPoint, + * AccessPoint, AccessPoint, AccessPoint, AccessPoint, int, DataUnit)' + */ + @Test + public final void testConnectRequest() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + assertNotNull(presentation); + DataUnit data = DataUnitManager.getInstance(); + assertNotNull(data); + presentation.connectRequest(OsiTests.calledNSAP, OsiTests.calledTSAP, + null, null, null, 1, data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.releaseRequest(DataUnit)' + */ + @Test + public final void testReleaseRequest() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + presentation.releaseRequest(data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.dataRequest(DataUnit)' + */ + @Test + public final void testDataRequest() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.dataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.userAbortRequest(DataUnit)' + */ + @Test + public final void testUserAbortRequest() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + presentation.userAbortRequest(data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.connectIndication(AccessPoint, + * AccessPoint, int, int, int, int, int, int, int, DataUnit)' + */ + @Test + public final void testConnectIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.connectIndication(null, null, 1, 1, 1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.connectConfirm(AccessPoint, + * int, int, int, int, int, int, DataUnit)' + */ + @Test + public final void testConnectConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.connectConfirm(null, 1, 1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.userAbortIndication(DataUnit)' + */ + @Test + public final void testUserAbortIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.userAbortIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.providerAbortIndication(int)' + */ + @Test + public final void testProviderAbortIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.providerAbortIndication(1); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.alterContextIndication(int, + * int, int, DataUnit)' + */ + @Test + public final void testAlterContextIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.alterContextIndication(1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.alterContextConfirm(int, + * int, DataUnit)' + */ + @Test + public final void testAlterContextConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.alterContextConfirm(1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.typedDataIndication(DataUnit)' + */ + @Test + public final void testTypedDataIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.typedDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.dataIndication(DataUnit)' + */ + @Test + public final void testDataIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.dataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.resynchronizeIndication(int, + * int, int, DataUnit)' + */ + @Test + public final void testResynchronizeIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.resynchronizeIndication(1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.resynchronizeConfirm(int, + * int, DataUnit)' + */ + @Test + public final void testResynchronizeConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.resynchronizeConfirm(1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityStartIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityStartIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityStartIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityResumeIndication(int, + * int, int, int, DataUnit)' + */ + @Test + public final void testActivityResumeIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityResumeIndication(1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityInterruptIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityInterruptIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityInterruptIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityInterruptConfirm(DataUnit)' + */ + @Test + public final void testActivityInterruptConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityInterruptConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityDiscardIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityDiscardIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityDiscardIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityDiscardConfirm(DataUnit)' + */ + @Test + public final void testActivityDiscardConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityDiscardConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityEndIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityEndIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityEndIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.activityEndConfirm(DataUnit)' + */ + @Test + public final void testActivityEndConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.activityEndConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.capabilityDataIndication(DataUnit)' + */ + @Test + public final void testCapabilityDataIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.capabilityDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.capabilityDataConfirm(DataUnit)' + */ + @Test + public final void testCapabilityDataConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.capabilityDataConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.controlGiveIndication(DataUnit)' + */ + @Test + public final void testControlGiveIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.controlGiveIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.tokenGiveIndication(DataUnit)' + */ + @Test + public final void testTokenGiveIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.tokenGiveIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.tokenPleaseIndication(int, + * DataUnit)' + */ + @Test + public final void testTokenPleaseIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.tokenPleaseIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.userExceptionReportIndication(int, + * DataUnit)' + */ + @Test + public final void testUserExceptionReportIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.userExceptionReportIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.providerExceptionReportIndication(int)' + */ + @Test + public final void testProviderExceptionReportIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.providerExceptionReportIndication(1); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.expeditedDataIndication(DataUnit)' + */ + @Test + public final void testExpeditedDataIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.expeditedDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.syncMinorIndication(int, + * int, DataUnit)' + */ + @Test + public final void testSyncMinorIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.syncMinorIndication(1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.syncMinorConfirm(int, + * DataUnit)' + */ + @Test + public final void testSyncMinorConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.syncMinorConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.syncMajorIndication(int, + * DataUnit)' + */ + @Test + public final void testSyncMajorIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.syncMajorIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.syncMajorConfirm(DataUnit)' + */ + @Test + public final void testSyncMajorConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.syncMajorConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.releaseIndication(DataUnit)' + */ + @Test + public final void testReleaseIndication() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.releaseIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.presentation.PresentationLayer.releaseConfirm(int, + * DataUnit)' + */ + @Test + public final void testReleaseConfirm() { + PresentationLayer presentation = new PresentationLayer(false, + OsiTests.callerSSAP, OsiTests.callerTSAP); + presentation.releaseConfirm(1, null); + } +} diff --git a/src/test/java/de/thpeetz/network/osi/session/PresentationMockObject.java b/src/test/java/de/thpeetz/network/osi/session/PresentationMockObject.java new file mode 100644 index 0000000..a613bfc --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/session/PresentationMockObject.java @@ -0,0 +1,153 @@ +package de.thpeetz.network.osi.session; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.presentation.PresentationUser; + +public class PresentationMockObject implements PresentationUser +{ + + public void connectIndication(AccessPoint callingAddress, + AccessPoint calledAddress, int qualityOfService, + int representationRequirements, int mode, int sessionRequirements, + int initialSPSerialNumber, int assignmentOfTokens, + int sessionConnectionIdentifier, DataUnit userData) + { + } + + public void connectConfirm(AccessPoint respondingAddress, + int qualityOfService, int representationRequirements, + int sessionRequirements, int initialSPSerialNumber, + int assignmentOfTokens, int sessionConnectionIdentifier, + DataUnit userData) + { + } + + public void userAbortIndication(DataUnit userData) + { + } + + public void providerAbortIndication(int providerReason) + { + } + + public void alterContextIndication(int additionList, int deletionList, + int additionResultList, DataUnit userData) + { + } + + public void alterContextConfirm(int additionResultList, + int deletionResultList, DataUnit userData) + { + } + + public void typedDataIndication(DataUnit userData) + { + } + + public void dataIndication(DataUnit userData) + { + } + + public void resynchronizeIndication(int type, int sPSerialNumber, + int tokens, DataUnit userData) + { + } + + public void resynchronizeConfirm(int sPSerialNumber, int tokens, + DataUnit userData) + { + } + + public void activityStartIndication(int activityIdentifier, + DataUnit userData) + { + } + + public void activityResumeIndication(int activityIdentifier, + int oldActivityIdentifier, int sPSerialNumber, + int oldSessionIdentifier, DataUnit userData) + { + } + + public void activityInterruptIndication(int reason, DataUnit userData) + { + } + + public void activityInterruptConfirm(DataUnit userData) + { + } + + public void activityDiscardIndication(int reason, DataUnit userData) + { + } + + public void activityDiscardConfirm(DataUnit userData) + { + } + + public void activityEndIndication(int sPSerialNumber, DataUnit userData) + { + } + + public void activityEndConfirm(DataUnit userData) + { + } + + public void capabilityDataIndication(DataUnit userData) + { + } + + public void capabilityDataConfirm(DataUnit userData) + { + } + + public void controlGiveIndication(DataUnit userData) + { + } + + public void tokenGiveIndication(DataUnit userData) + { + } + + public void tokenPleaseIndication(int tokens, DataUnit userData) + { + } + + public void userExceptionReportIndication(int reason, DataUnit userData) + { + } + + public void providerExceptionReportIndication(int reason) + { + } + + public void expeditedDataIndication(DataUnit userData) + { + } + + public void syncMinorIndication(int type, int sPSerialNumber, + DataUnit userData) + { + } + + public void syncMinorConfirm(int sPSerialNumber, DataUnit userData) + { + } + + public void syncMajorIndication(int sPSerialNumber, DataUnit userData) + { + } + + public void syncMajorConfirm(DataUnit userData) + { + } + + public void releaseIndication(DataUnit userData) + { + } + + public void releaseConfirm(int result, DataUnit userData) + { + } +} diff --git a/src/test/java/de/thpeetz/network/osi/session/SessionLayerTest.java b/src/test/java/de/thpeetz/network/osi/session/SessionLayerTest.java new file mode 100644 index 0000000..a23cfc7 --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/session/SessionLayerTest.java @@ -0,0 +1,706 @@ +package de.thpeetz.network.osi.session; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.DataUnitManager; +import de.thpeetz.network.osi.OsiTests; +import de.thpeetz.network.osi.presentation.PresentationUser; + +public class SessionLayerTest { + private PresentationUser presentation = new PresentationMockObject(); + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.SessionLayer(PresentationUser)' + */ + @Test + public final void testSessionLayer() { + assertEquals(SessionLayer.ER_SPDU, 0); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.connectRequest(AccessPoint, + * AccessPoint, int, AccessPoint, AccessPoint, int, int, int, int, int, + * DataUnit)' + */ + @Test + public final void testConnectRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + session.connectRequest(OsiTests.calledNSAP, OsiTests.calledTSAP, 1, + null, null, 1, 1, 1, 1, 1, data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.connectResponse(int, + * AccessPoint, int, int, int, int, int, int, DataUnit)' + */ + @Test + public final void testConnectResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.connectResponse(1, null, 1, 1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.dataRequest(DataUnit)' + */ + @Test + public final void testDataRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.dataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.expeditedDataRequest(DataUnit)' + */ + @Test + public final void testExpeditedDataRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.expeditedDataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.typedDataRequest(DataUnit)' + */ + @Test + public final void testTypedDataRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.typedDataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.capabilityDataRequest(DataUnit)' + */ + @Test + public final void testCapabilityDataRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.capabilityDataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.capabilityDataResponse(DataUnit)' + */ + @Test + public final void testCapabilityDataResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.capabilityDataResponse(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.tokenGiveRequest(int, + * DataUnit)' + */ + @Test + public final void testTokenGiveRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.tokenGiveRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.tokenPleaseRequest(int, + * DataUnit)' + */ + @Test + public final void testTokenPleaseRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.tokenPleaseRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.controlGiveRequest(DataUnit)' + */ + @Test + public final void testControlGiveRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.controlGiveRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMinorRequest(int, int, + * int, DataUnit)' + */ + @Test + public final void testSyncMinorRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMinorRequest(1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMinorResponse(int, + * DataUnit)' + */ + @Test + public final void testSyncMinorResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMinorResponse(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMajorRequest(int, + * DataUnit)' + */ + @Test + public final void testSyncMajorRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMajorRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMajorResponse(int, + * DataUnit)' + */ + @Test + public final void testSyncMajorResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMajorResponse(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.resynchronizeRequest(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testResynchronizeRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.resynchronizeRequest(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.resynchronizeResponse(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testResynchronizeResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.resynchronizeResponse(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.userExceptionReportRequest(int, + * DataUnit)' + */ + @Test + public final void testUserExceptionReportRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.userExceptionReportRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityStartRequest(int, + * DataUnit)' + */ + @Test + public final void testActivityStartRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityStartRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityResumeRequest(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testActivityResumeRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityResumeRequest(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityInterruptRequest(DataUnit)' + */ + @Test + public final void testActivityInterruptRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityInterruptRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityInterruptResponse(int, + * DataUnit)' + */ + @Test + public final void testActivityInterruptResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityInterruptResponse(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityDiscardRequest(int, + * DataUnit)' + */ + @Test + public final void testActivityDiscardRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityDiscardRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityDiscardResponse(DataUnit)' + */ + @Test + public final void testActivityDiscardResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityDiscardResponse(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityEndRequest(int, + * DataUnit)' + */ + @Test + public final void testActivityEndRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityEndRequest(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityEndResponse(int, + * DataUnit)' + */ + @Test + public final void testActivityEndResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityEndResponse(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.releaseRequest(DataUnit)' + */ + @Test + public final void testReleaseRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + session.releaseRequest(data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.releaseResponse(int, + * DataUnit)' + */ + @Test + public final void testReleaseResponse() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.releaseResponse(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.userAbortRequest(DataUnit)' + */ + @Test + public final void testUserAbortRequest() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + session.userAbortRequest(data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.connectIndication(int, + * AccessPoint, AccessPoint, int, int, int, int, int, DataUnit)' + */ + @Test + public final void testConnectIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.connectIndication(1, null, null, 1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.connectConfirm(int, + * AccessPoint, int, int, int, int, int, int, DataUnit)' + */ + @Test + public final void testConnectConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.connectConfirm(1, null, 1, 1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.dataIndication(DataUnit)' + */ + @Test + public final void testDataIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.dataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.expeditedDataIndication(DataUnit)' + */ + @Test + public final void testExpeditedDataIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.expeditedDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.typedDataIndication(DataUnit)' + */ + @Test + public final void testTypedDataIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.typedDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.capabilityDataIndication(DataUnit)' + */ + @Test + public final void testCapabilityDataIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.capabilityDataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.capabilityDataConfirm(DataUnit)' + */ + @Test + public final void testCapabilityDataConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.capabilityDataConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.tokenGiveIndication(int, + * DataUnit)' + */ + @Test + public final void testTokenGiveIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.tokenGiveIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.tokenPleaseIndication(int, + * DataUnit)' + */ + @Test + public final void testTokenPleaseIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.tokenPleaseIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.controlGiveIndication(DataUnit)' + */ + @Test + public final void testControlGiveIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.controlGiveIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMinorIndication(int, int, + * int, DataUnit)' + */ + @Test + public final void testSyncMinorIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMinorIndication(1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMinorConfirm(int, + * DataUnit)' + */ + @Test + public final void testSyncMinorConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMinorConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMajorIndication(int, + * DataUnit)' + */ + @Test + public final void testSyncMajorIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMajorIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.syncMajorConfirm(int, + * DataUnit)' + */ + @Test + public final void testSyncMajorConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.syncMajorConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.resynchronizeIndication(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testResynchronizeIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.resynchronizeIndication(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.resynchronizeConfirm(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testResynchronizeConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.resynchronizeConfirm(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.providerExceptionReportIndication(int)' + */ + @Test + public final void testProviderExceptionReportIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.providerExceptionReportIndication(1); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.userExceptionReportIndication(int, + * DataUnit)' + */ + @Test + public final void testUserExceptionReportIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.userExceptionReportIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityStartIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityStartIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityStartIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityResumeIndication(int, + * int, int, int, int, DataUnit)' + */ + @Test + public final void testActivityResumeIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityResumeIndication(1, 1, 1, 1, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityInterruptIndication(DataUnit)' + */ + @Test + public final void testActivityInterruptIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityInterruptIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityInterruptConfirm(int, + * DataUnit)' + */ + @Test + public final void testActivityInterruptConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityInterruptConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityDiscardIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityDiscardIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityDiscardIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityDiscardConfirm(DataUnit)' + */ + @Test + public final void testActivityDiscardConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityDiscardConfirm(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityEndIndication(int, + * DataUnit)' + */ + @Test + public final void testActivityEndIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityEndIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.activityEndConfirm(int, + * DataUnit)' + */ + @Test + public final void testActivityEndConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.activityEndConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.releaseIndication(DataUnit)' + */ + @Test + public final void testReleaseIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.releaseIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.releaseConfirm(int, + * DataUnit)' + */ + @Test + public final void testReleaseConfirm() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.releaseConfirm(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.userAbortIndication(DataUnit)' + */ + @Test + public final void testUserAbortIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.userAbortIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.session.SessionLayer.providerAbortIndication(int, + * DataUnit)' + */ + @Test + public final void testProviderAbortIndication() { + SessionLayer session = new SessionLayer(false, this.presentation, + OsiTests.callerSSAP, OsiTests.callerTSAP); + session.providerAbortIndication(1, null); + } +} diff --git a/src/test/java/de/thpeetz/network/osi/transport/SessionMockObject.java b/src/test/java/de/thpeetz/network/osi/transport/SessionMockObject.java new file mode 100644 index 0000000..fc7f477 --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/transport/SessionMockObject.java @@ -0,0 +1,145 @@ +package de.thpeetz.network.osi.transport; + +import de.thpeetz.network.osi.AccessPoint; +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.session.SessionUser; + +public class SessionMockObject implements SessionUser +{ + + public void connectIndication(int connectionIdentifier, + AccessPoint callingAddress, AccessPoint calledAddress, + int qualityOfService, int sessionRequirements, + int firstSPSerialNumber, int secondSPSerialNumber, + int assignmentOfTokens, DataUnit userdata) + { + } + + public void connectConfirm(int connectionIdentifier, + AccessPoint respondingAddress, int result, int qualityOfService, + int sessionRequirements, int firstSPSerialNumber, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userData) + { + } + + public void dataIndication(DataUnit userData) + { + } + + public void expeditedDataIndication(DataUnit userData) + { + } + + public void typedDataIndication(DataUnit userData) + { + } + + public void capabilityDataIndication(DataUnit userData) + { + } + + public void capabilityDataConfirm(DataUnit userData) + { + } + + public void tokenGiveIndication(int tokens, DataUnit userData) + { + } + + public void tokenPleaseIndication(int tokens, DataUnit userData) + { + } + + public void controlGiveIndication(DataUnit userData) + { + } + + public void syncMinorIndication(int type, int dataSeparation, + int firstSPSerialNumber, DataUnit userData) + { + } + + public void syncMinorConfirm(int firstSPSerialNumber, DataUnit userData) + { + } + + public void syncMajorIndication(int firstSPSerialNumber, DataUnit userData) + { + } + + public void syncMajorConfirm(int secondSPSerialNumber, DataUnit userData) + { + } + + public void resynchronizeIndication(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata) + { + } + + public void resynchronizeConfirm(int firstResynchronizeType, + int firstSPSerialNumber, int secondResynchronizeType, + int secondSPSerialNumber, int assignmentOfTokens, DataUnit userdata) + { + } + + public void providerExceptionReportIndication(int reason) + { + } + + public void userExceptionReportIndication(int reason, DataUnit userData) + { + } + + public void activityStartIndication(int activityIdentifier, + DataUnit userData) + { + } + + public void activityResumeIndication(int activityIdentifier, + int oldActivityIdentifier, int firstSPSerialNumber, + int secondSPSerialNumber, int oldSessionConnectionIdentifier, + DataUnit userData) + { + } + + public void activityInterruptIndication(DataUnit userData) + { + } + + public void activityInterruptConfirm(int reason, DataUnit userData) + { + } + + public void activityDiscardIndication(int reason, DataUnit userData) + { + } + + public void activityDiscardConfirm(DataUnit userData) + { + } + + public void activityEndIndication(int firstSPSerialNumber, DataUnit userData) + { + } + + public void activityEndConfirm(int secondSPSerialNumber, DataUnit userData) + { + } + + public void releaseIndication(DataUnit userData) + { + } + + public void releaseConfirm(int result, DataUnit userData) + { + } + + public void userAbortIndication(DataUnit userData) + { + } + + public void providerAbortIndication(int reason, DataUnit userData) + { + } +} diff --git a/src/test/java/de/thpeetz/network/osi/transport/TransportLayerTest.java b/src/test/java/de/thpeetz/network/osi/transport/TransportLayerTest.java new file mode 100644 index 0000000..0ca4070 --- /dev/null +++ b/src/test/java/de/thpeetz/network/osi/transport/TransportLayerTest.java @@ -0,0 +1,142 @@ +package de.thpeetz.network.osi.transport; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +import de.thpeetz.network.osi.DataUnit; +import de.thpeetz.network.osi.DataUnitManager; +import de.thpeetz.network.osi.OsiTests; + +public class TransportLayerTest { + private SessionMockObject session = new SessionMockObject(); + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.TransportLayer(SessionUser)' + */ + @Test + public final void testTransportLayer() { + assertEquals(TransportLayer.ER_TPDU, 0x70); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.connectRequest(AccessPoint, + * AccessPoint, AccessPoint, boolean, int, DataUnit)' + */ + @Test + public final void testConnectRequest() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + transport.connectRequest(OsiTests.calledNSAP, OsiTests.calledTSAP, + OsiTests.callerTSAP, false, 0, data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.connectResponse(int, + * AccessPoint, boolean, DataUnit)' + */ + @Test + public final void testConnectResponse() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.connectResponse(1, null, true, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.disconnectRequest(DataUnit)' + */ + @Test + public final void testDisconnectRequest() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + DataUnit data = DataUnitManager.getInstance(); + transport.disconnectRequest(data); + DataUnitManager.freeInstance(data); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.dataRequest(DataUnit)' + */ + @Test + public final void testDataRequest() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.dataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.expeditedDataRequest(DataUnit)' + */ + @Test + public final void testExpeditedDataRequest() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.expeditedDataRequest(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.connectConfirm(int, + * AccessPoint, boolean, DataUnit)' + */ + @Test + public final void testConnectConfirm() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.connectConfirm(1, null, true, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.connectIndication(AccessPoint, + * AccessPoint, boolean, int, DataUnit)' + */ + @Test + public final void testConnectIndication() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.connectIndication(null, null, true, 1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.disconnectIndication(int, + * DataUnit)' + */ + @Test + public final void testDisconnectIndication() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.disconnectIndication(1, null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.dataIndication(DataUnit)' + */ + @Test + public final void testDataIndication() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.dataIndication(null); + } + + /* + * Test method for + * 'com.peetz.network.osi.transport.TransportLayer.expeditedDataIndication(DataUnit)' + */ + @Test + public final void testExpeditedDataIndication() { + TransportLayer transport = new TransportLayer(false, this.session, + OsiTests.callerTSAP); + transport.expeditedDataIndication(null); + } +} diff --git a/src/test/java/de/thpeetz/tools/ObjectPoolTest.java b/src/test/java/de/thpeetz/tools/ObjectPoolTest.java new file mode 100644 index 0000000..17ee8a8 --- /dev/null +++ b/src/test/java/de/thpeetz/tools/ObjectPoolTest.java @@ -0,0 +1,45 @@ +package de.thpeetz.tools; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.junit.jupiter.api.Test; + +import de.thpeetz.network.osi.DataUnit; + +public class ObjectPoolTest { + + /* + * Test method for 'com.peetz.tools.ObjectPool.ObjectPool(Class)' + */ + @Test + public final void testObjectPoolClass() { + ObjectPool objectPool = new ObjectPool(DataUnit.class); + assertNotNull(objectPool); + } + + /* + * Test method for 'com.peetz.tools.ObjectPool.ObjectPool(Class, int)' + */ + public final void testObjectPoolClassInt() { + ObjectPool objectPool = new ObjectPool(DataUnit.class, 5); + assertNotNull(objectPool); + } + + /* + * Test method for 'com.peetz.tools.ObjectPool.getInstance()' + */ + public final void testGetInstance() { + ObjectPool objectPool = new ObjectPool(DataUnit.class, 1); + DataUnit unit = objectPool.getInstance(); + assertNotNull(unit); + } + + /* + * Test method for 'com.peetz.tools.ObjectPool.freeInstance(Object)' + */ + public final void testFreeInstance() { + ObjectPool objectPool = new ObjectPool(DataUnit.class); + DataUnit unit = objectPool.getInstance(); + objectPool.freeInstance(unit); + } +}