Skip to content

Commit

Permalink
Merge pull request #71 from ostelco/develop
Browse files Browse the repository at this point in the history
New release of OCSgw
  • Loading branch information
mpeterss authored Apr 19, 2018
2 parents c787050 + 2d1d78d commit 4c30ec0
Show file tree
Hide file tree
Showing 33 changed files with 402 additions and 277 deletions.
6 changes: 3 additions & 3 deletions analytics/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
id "application"
id "jacoco"
id "com.github.johnrengelman.shadow" version "2.0.2"
id "com.github.johnrengelman.shadow" version "2.0.3"
id "org.jetbrains.kotlin.jvm" version "1.2.31"
id "idea"
}

dependencies {
implementation project(':ocs-api')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
implementation 'com.google.cloud:google-cloud-pubsub:0.41.0-beta'
implementation 'com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:2.3.0'
implementation 'com.google.cloud:google-cloud-pubsub:0.43.0-beta'
implementation 'com.google.cloud.dataflow:google-cloud-dataflow-java-sdk-all:2.4.0'
runtime 'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.4.0'
implementation 'ch.qos.logback:logback-classic:1.2.3'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
Expand Down
6 changes: 3 additions & 3 deletions auth-server/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "application"
id "jacoco"
id "com.github.johnrengelman.shadow" version "2.0.2"
id "com.github.johnrengelman.shadow" version "2.0.3"
id "org.jetbrains.kotlin.jvm" version "1.2.31"
id "idea"
}
Expand Down Expand Up @@ -35,8 +35,8 @@ task pack(type: Zip, dependsOn: 'shadowJar') {
from('Dockerfile') {
into(project.name)
}
archiveName 'auth-server.zip'
destinationDir(file('build/deploy/'))
archiveName = "auth-server.zip"
destinationDir = file('build/deploy/')
}

sourceSets {
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repository.jboss.org/nexus/content/repositories/releases/" }
maven { url "https://maven.repository.redhat.com/ga/" }
maven { url "http://clojars.org/repo/" }
maven { url = "https://repository.jboss.org/nexus/content/repositories/releases/" }
maven { url = "https://maven.repository.redhat.com/ga/" }
maven { url = "http://clojars.org/repo/" }
}
}

Expand All @@ -27,7 +27,7 @@ subprojects {
}
ext {
kotlinVersion = "1.2.31"
dropwizardVersion = "1.3.0"
dropwizardVersion = "1.3.1"
}
}

Expand All @@ -38,6 +38,6 @@ task pack(type: Zip, dependsOn: [':ocsgw:pack', ':prime:pack', ':auth-server:pac
from 'docker-compose.yaml'
from 'docker-compose.prod.yaml'
rename 'docker-compose.prod.yaml','docker-compose.override.yaml'
archiveName 'ostelco-core.zip'
destinationDir(file('build/deploy/'))
archiveName = 'ostelco-core.zip'
destinationDir = file('build/deploy/')
}
8 changes: 4 additions & 4 deletions diameter-stack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ uploadArchives.repositories.mavenDeployer {
}

pom.project {
name 'ostelco diameter stack'
name = 'ostelco diameter stack'
packaging 'jar'
// optionally artifactId can be defined here
description 'A library to communicate over the Diameter protocol.'
description = 'A library to communicate over the Diameter protocol.'
url 'https://github.com/ostelco/ostelco-core/tree/develop/diameter-stack'

scm {
Expand All @@ -78,15 +78,15 @@ uploadArchives.repositories.mavenDeployer {

licenses {
license {
name 'The Apache License, Version 2.0'
name = 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'la3lma'
name 'Bjørn Remseth'
name = 'Bjørn Remseth'
email '[email protected]'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import org.ostelco.diameter.util.DiameterUtilities

class CreditControlContext(
val sessionId: String,
val originalCreditControlRequest: JCreditControlRequest) {
val originalCreditControlRequest: JCreditControlRequest,
val originHost: String) {

private val LOG by logger()

private var sent: Boolean = false

val originHost:String = originalCreditControlRequest.originHost
val originRealm:String = originalCreditControlRequest.originRealm
val originRealm:String = originalCreditControlRequest.destinationRealm

val creditControlRequest: CreditControlRequest = AvpParser().parse(
CreditControlRequest::class,
Expand Down Expand Up @@ -59,26 +57,20 @@ class CreditControlContext(
// This is a bug in jDiameter due to which this unsigned32 field has to be set as Int and not Long.
answerMSCC.addAvp(Avp.SERVICE_IDENTIFIER_CCA, mscc.serviceIdentifier.toInt(), true, false)
}
if (mscc.granted.total < 1 && originalCreditControlRequest.requestTypeAVPValue != RequestType.TERMINATION_REQUEST) {
resultCode = CreditControlResultCode.DIAMETER_CREDIT_LIMIT_REACHED.value
}

val gsuAvp = answerMSCC.addGroupedAvp(Avp.GRANTED_SERVICE_UNIT, true, false)
gsuAvp.addAvp(Avp.CC_INPUT_OCTETS, 0L, true, false)
gsuAvp.addAvp(Avp.CC_OUTPUT_OCTETS, 0L, true, false)
if (originalCreditControlRequest.requestTypeAVPValue != RequestType.TERMINATION_REQUEST) {

if (originalCreditControlRequest.requestTypeAVPValue == RequestType.TERMINATION_REQUEST || mscc.granted.total < 1) {
LOG.info("Terminate")
// Since this is a terminate reply no service is granted
gsuAvp.addAvp(Avp.CC_TIME, 0, true, false)
gsuAvp.addAvp(Avp.CC_TOTAL_OCTETS, 0L, true, false)
gsuAvp.addAvp(Avp.CC_SERVICE_SPECIFIC_UNITS, 0L, true, false)
if (mscc.finalUnitIndication != null) {
addFinalUnitAction(answerMSCC, mscc)
}

addFinalUnitAction(answerMSCC, mscc)
} else {
gsuAvp.addAvp(Avp.CC_TOTAL_OCTETS, mscc.granted.total, true, false)
if (mscc.granted.total > -1) {
val gsuAvp = answerMSCC.addGroupedAvp(Avp.GRANTED_SERVICE_UNIT, true, false)
gsuAvp.addAvp(Avp.CC_INPUT_OCTETS, 0L, true, false)
gsuAvp.addAvp(Avp.CC_OUTPUT_OCTETS, 0L, true, false)
gsuAvp.addAvp(Avp.CC_TOTAL_OCTETS, mscc.granted.total, true, false)
}
}

answerMSCC.addAvp(Avp.RESULT_CODE, resultCode, true, false)
answerMSCC.addAvp(Avp.VALIDITY_TIME, mscc.validityTime, true, false)
}
Expand Down
22 changes: 22 additions & 0 deletions diameter-stack/src/main/kotlin/org/ostelco/diameter/model/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class ServiceUnit() {
@AvpField(Avp.CC_OUTPUT_OCTETS)
var output: Long = 0

@AvpField(Avp.REPORTING_REASON)
var reportingReason: ReportingReason? = null

constructor(total: Long, input: Long, output: Long) : this() {
this.total = total
this.input = input
Expand Down Expand Up @@ -102,6 +105,9 @@ class MultipleServiceCreditControl() {
@AvpField(Avp.GRANTED_SERVICE_UNIT)
var granted = ServiceUnit()

@AvpField(Avp.REPORTING_REASON)
var reportingReason: ReportingReason? = null

var validityTime = 86400

// https://tools.ietf.org/html/rfc4006#section-8.34
Expand All @@ -125,6 +131,22 @@ enum class RedirectAddressType {
SIP_URL
}

/**
* http://www.3gpp.org/ftp/Specs/html-info/32299.htm
*/
enum class ReportingReason {
THRESHOLD,
QHT,
FINAL,
QUOTA_EXHAUSTED,
VALIDITY_TIME,
OTHER_QUOTA_TYPE,
RATING_CONDITION_CHANGE,
FORCED_REAUTHORISATION ,
POOL_EXHAUSTED,
UNUSED_QUOTA_TIMER
}

/**
* https://tools.ietf.org/html/rfc4006#section-8.37
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ import org.jdiameter.api.AvpDataException
import org.jdiameter.api.AvpSet
import org.jdiameter.common.impl.validation.DictionaryImpl
import org.ostelco.diameter.logger
import org.ostelco.diameter.util.AvpType.ADDRESS
import org.ostelco.diameter.util.AvpType.APP_ID
import org.ostelco.diameter.util.AvpType.FLOAT32
import org.ostelco.diameter.util.AvpType.FLOAT64
import org.ostelco.diameter.util.AvpType.GROUPED
import org.ostelco.diameter.util.AvpType.IDENTITY
import org.ostelco.diameter.util.AvpType.INTEGER32
import org.ostelco.diameter.util.AvpType.INTEGER64
import org.ostelco.diameter.util.AvpType.OCTET_STRING
import org.ostelco.diameter.util.AvpType.RAW
import org.ostelco.diameter.util.AvpType.RAW_DATA
import org.ostelco.diameter.util.AvpType.TIME
import org.ostelco.diameter.util.AvpType.UNSIGNED32
import org.ostelco.diameter.util.AvpType.UNSIGNED64
import org.ostelco.diameter.util.AvpType.URI
import org.ostelco.diameter.util.AvpType.UTF8STRING
import org.ostelco.diameter.util.AvpType.VENDOR_ID

class DiameterUtilities {
Expand Down Expand Up @@ -48,33 +56,25 @@ class DiameterUtilities {
}

private fun getAvpValue(avp: Avp): Any {
var avpValue: Any
try {
val avpType = AvpDictionary.getType(avp)

when (avpType) {
INTEGER32, APP_ID -> avpValue = avp.integer32
UNSIGNED32, VENDOR_ID -> avpValue = avp.unsigned32
FLOAT64 -> avpValue = avp.float64
INTEGER64 -> avpValue = avp.integer64
TIME -> avpValue = avp.time
UNSIGNED64 -> avpValue = avp.unsigned64
GROUPED -> avpValue = "<Grouped>"
else -> avpValue = (avp.utF8String as String)
.replace("\r", "")
.replace("\n", "")
}
} catch (ignore: Exception) {
try {
avpValue = avp.utF8String
.replace("\r", "")
.replace("\n", "")
} catch (e: AvpDataException) {
avpValue = avp.toString()
}

val avpType = AvpDictionary.getType(avp)
return when (avpType) {
ADDRESS -> avp.address
IDENTITY -> avp.diameterIdentity
URI -> avp.diameterURI
FLOAT32 -> avp.float32
FLOAT64 -> avp.float64
GROUPED -> "<Grouped>"
INTEGER32, APP_ID -> avp.integer32
INTEGER64 -> avp.integer64
OCTET_STRING -> String(avp.octetString)
RAW -> avp.raw
RAW_DATA -> avp.rawData
TIME -> avp.time
UNSIGNED32, VENDOR_ID -> avp.unsigned32
UNSIGNED64 -> avp.unsigned64
UTF8STRING -> avp.utF8String
null -> "<null>"
}
return avpValue
}

// TODO for missing Avp, is code and vendorId as 0 okay?
Expand Down
8 changes: 4 additions & 4 deletions diameter-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ uploadArchives.repositories.mavenDeployer {
}

pom.project {
name 'ostelco diameter test'
name = 'ostelco diameter test'
packaging 'jar'
// optionally artifactId can be defined here
description 'A library for testing over the Diameter protocol.'
description = 'A library for testing over the Diameter protocol.'
url 'https://github.com/ostelco/ostelco-core/tree/develop/diameter-test'

scm {
Expand All @@ -66,15 +66,15 @@ uploadArchives.repositories.mavenDeployer {

licenses {
license {
name 'The Apache License, Version 2.0'
name = 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id 'la3lma'
name 'Bjørn Remseth'
name = 'Bjørn Remseth'
email '[email protected]'
}
}
Expand Down
Loading

0 comments on commit 4c30ec0

Please sign in to comment.