3 User Configurations

The user can perform the following configurations in the InterWorking and Mediation Function:

Configuring Mediation Rules

User can prepare their own Mediation rules to apply on HTTP Request and Response. Refer to the following sample rules to create new Mediation Rules.

HTTP Request Header Manipulation Rule

Following is a sample HTTP request header manipulation rule.

rule "Http-Req-Header-Manipulation-Rule"
when
    req : Request(headers.has("Header Name"))
then
    req.headers.add("Header Name","Value")
    req.headers.put("Header Name","Value")
    req.headers.set("Header Name","Value")
    req.headers.del("Header Name")
end

HTTP Request Body Manipulation Rule

Following is a sample HTTP request body manipulation rule.

rule "Http-Req-Body-Manipulation_Rule"
    salience 20
when
    req : Request(body.get("JSONPath") == "value")
then
    req.body.add("JSONPATH","Value")
    req.body.put("JSONPATH","Key","Value")
    req.body.set("JSONPATH","Value")
    req.body.del("JSONPath")
end

HTTP Response Header Manipulation Rule

Following is a sample HTTP response header manipulation rule.

rule "Http-Rsp-Header-Manipulation-Rule"
when
    rsp : Response(headers.has("Header Name"))
then
    rsp.headers.add("Header Name","Value")
    rsp.headers.put("Header Name","Value")
    rsp.headers.set("Header Name","Value")
    rsp.headers.del("Header Name")
end

HTTP Response Body Manipulation Rule

Following is a sample HTTP response body manipulation rule.

rule "Http-Rsp-Body-Manipulation_Rule"
    salience 20
when
    rsp : Response(body.get("JSONPath") == "value")
then
    rsp.body.add("JSONPATH","Value")
    rsp.body.put("JSONPATH","Key","Value")
    rsp.body.set("JSONPATH","Value")
    rsp.body.del("JSONPath")
end

Basic Rule API for HTTP Message Manipulation

Following are the APIs for HTTP Message Manipulation:

SL.No API Return Type Description Example
1 getUri() String returns the URI of the Request req.getUri()
2 setUri(String URI) void Sets the URI in the body of request req.setUri("http://oracle.com")
3 getHttpStatusCode() Integer returns the StatusCode from the body of Response rsp.getHttpStatusCode()
4 setHttpStatusCode(Integer httpStatusCode) void sets the StatusCode in the body of Response rsp.setHttpStatusCode(201)
5 getRejectMessage() String returns the Reject Message from the body of Response rsp.getRejectMessage()
6 setRejectMessage(String rejectMessage) void sets the Reject Message in the body of Response rsp.setRejectMessage("Message")

Header Rule APIs and Body Rule APIs

The following are the new header APIs which are being supported in mediation from release 1.5.0:

Header Rule APIs

Table 3-1 Header Rule APIs

SL.No API Return Type Description Example
1 get(String key) String Returns a header value with that key. req.headers.get("header")
2 has(String key) Boolean Returns true/false depending on whether the header is present or not. req.headers.has("header")
3 has(String key, String value) Boolean Returns true/false depending on whether the header is present with that value or not. req.headers.has("header","value")
4 put( String key, String value) Boolean Add the header with given key and value if does not find or updates the header with value if the given key found. req.headers.put("header","value")
5 add( String key, String value); Boolean Add the header with given key and value if does not find req.headers.add("header","value")
6 set( String key, String value); Boolean Updates the header with value if the given key found req.headers.set("header","value")
7 set( String key, String oldValue, String newValue); Boolean Update the header with new value if the existing value matches with oldValue req.headers.set("header"," old value","new value")
8 del(String key) Boolean Delete the header req.headers.del("header")
9 del(String key, String value) Boolean Delete the header if it matches with given key and value req.headers.del("header","value")
10 count(); Integer Returns the count of total numbers of all headers. req.headers.count()
11 count(String key); Integer Returns the count of total numbers of headers with the key. req.headers.count("header")
12 count(String key, String value) Integer Returns the count of total numbers of headers with the key and value req.headers.count("header","value")

Body Rule APIs

Table 3-2 Body Rule APIs

SL.No API Return Type Description Example
1 get(String path) Object Returns the value present at that path. body.get("$.serviceName")
2 getAll(String path) List<Object> Returns the list of objects presnet at the path given. body.getAll("$.serviceName")
3 has(String path); boolean Checks if the key is present at that path or not. body.has("$.serviceName")
4 has(String path, Object value) boolean Checks if the key has the value present at that path or not. body.get("$.serviceName","value")
5 absPath(String arrayPath, String elem, Object value) Object Returns the whole path from head to the elem if the value is present. req.body.absPath("$.payload","iePath", "/a")
6 indexOf(String arrayPath, String elem, Object value) Integer Returns the index of the value in that JSONArray req.body.indexOf("$.dataToIntegrityProtectBlock.payload","value", 100)
7 put(String path, String key, T value) boolean Add the body with given key and value at path if does not find or updates the body with value at the path if the given key found. req.body.put("$","key","value")
8 add(String path, T value) boolean Adds the key embedded in the path with value given if element is not present. req.body.add("$.ipEndPoints","value")
9 set(String path, T value) boolean Updates the key embedded in the path with value given if element is present. rsp.body.add("$.ipEndPoints","value")
10 del(String path, T value) boolean Deletes the element at that path with the value present. req.body.del("$.path","value")
11 del(String path) boolean Deletes the element at that path req.body.del("$.path")

Regex Support and Function Support

The following are the other support for rules:

Regex Support

rule "regex rule"
when
   req : Request(headers.get("x-number")  matches "[0-9]")
then
   req.headers.put( "Header name", "value")
end
 
 
rule "regex rule2"
when
    req : Request(body.get("$.serviceName").toString() matches "suci-.*0-0-0.*")
then
    req.body.put("$","new key","value")
end
 
 
Example:
suci-0-123-45-0-0-0-0-1-17-e9b9916c911f448d8792e6b2f387f85d3ecab9040049427d9edbb5431b0bc711023be6a057f34956ba21b45d936238aebeb7

In operator

rule "New Rule5"
when
   req : Request(headers.get("x-number")  in (1,2,3,4,5 ))
then
   req.headers.put( "Header name", "value")
end

Function Support

function String update(String str){
   int a = Integer.parseInt(str);
   a = a+1;
   str = ""+a;
   return str;
}
 
rule "Function"
when
   req : Request(headers.get("ADD")==1)
then
   req.headers.set("ADD",update(req.headers.get("ADD")))
end

Configuring Mediation Rule for PT

Add the following rules to the mediation rules.

Note:

In the following rules, replace PCF_loadBalancerIP_and_Port and IWF_loadBalancerIP_and_Port with appropriate values.
rule "pt_d2h_to_nf_rule"
salience 1
when
    req : Request(headers.has("pt_dest_uri"))
then
    req.setUri(req.headers.get("pt_dest_uri").replace("pcf.com","10.75.203.74:1000/simulation"))
    req.headers.del("pt_dest_uri")
end
 
rule "pt_rar_to_pcf_rule"
salience 1
when
  req : Request(req.getUri().toString() matches ".*(npcf-policyauthorization)*(v1)*(notification)*(notify).*")
then
 req.getHttpMessageFactImpl().forwardPath = IWFConsts.FORWARD_TO_H2D
 req.headers.add("diameterApplicationId","16777236")
 req.headers.add("diameterCommandCode","258")
 req.headers.add("original-req-uri",req.getUri())
end
 
rule "pt_aar_to_pcf_rule"
salience 1
when
  req : Request(req.body.has("$.ascReqData.notifUri"))
then
  req.body.add("$.ascReqData.notifUri",req.body.get("$.ascReqData.notifUri").toString().replace("iwf.com","10.75.203.74:30079"))
  req.body.add("$.ascReqData.evSubsc.notifUri",req.body.get("$.ascReqData.evSubsc.notifUri").toString().replace("iwf.com","10.75.203.74:30079"))
end
 
rule "pt_asr_to_pcf_rule"
salience 1
when
  req : Request(getUri().toString() matches ".*(npcf-policyauthorization)*(v1)*(notification)*(terminate).*")
then
  req.getHttpMessageFactImpl().forwardPath=IWFConsts.FORWARD_TO_H2D
  req.headers.add("diameterApplicationId","16777236")
  req.headers.add("diameterCommandCode","274")
  req.headers.add("original-req-uri",req.getUri())
end
 
 
rule "pt_ccri_to_h2d_rule"
salience 1
when
req : Request(req.getUri() matches ".*(npcf-smpolicycontrol/v1/sm-policies)(/$|$)")
then
req.getHttpMessageFactImpl().forwardPath=IWFConsts.FORWARD_TO_H2D
req.headers.put("diameterApplicationId","16777238")
req.headers.put("diameterCommandCode","272")
req.headers.put("requestType","CREATE")
end
 
rule "pt_ccru_to_h2d_rule"
salience 1
when
req : Request(req.getUri() == ".*(npcf-smpolicycontrol/v1/sm-policies/)(.*)(/update)(/$|$)")
then
req.getHttpMessageFactImpl().forwardPath=IWFConsts.FORWARD_TO_H2D
req.headers.put("diameterApplicationId","16777238")
req.headers.put("diameterCommandCode","272")
req.headers.put("requestType","UPDATE")
req.headers.put("original-req-uri",req.getUri())
end
 
rule "pt_ccrt_to_h2d_rule"
salience 1
when
req : Request(req.getUri() matches ".*(npcf-smpolicycontrol/v1/sm-policies/)(.*)(/delete)(/$|$)")
then
req.getHttpMessageFactImpl().forwardPath=IWFConsts.FORWARD_TO_H2D
req.headers.put("diameterApplicationId","16777238")
req.headers.put("diameterCommandCode","272")
req.headers.put("requestType","DELETE")
req.headers.put("original-req-uri",req.getUri())
end

Configuring Mediation Rule for NF-Mediation

Extracting the group name and the trigger point from the URLs provided below:

Note:

In rules, the "agenda-group" is used to categories the rule group using the group name and the trigger point that is provided in the URL.
URL Type 1: [http://{apiRoot}/nmediation-http/v1]
  • The above URL does not have any group name or trigger point. So the rules that are without agenda-group are applicable on this.
  • From the below reference rules, the rule default will be applied.
URL Type 2: [http://{apiRoot}/nmediation-http/v1/scp]
  • The above URL has only the group name. So the rules that are under the agenda-group scp is applicable.
  • From the below reference rules, the rule scp-rule-header-1 will be applied.
URL Type 3: [http://{apiRoot}/nmediation-http/v1/scp/triggerpoint2]
  • The above URL has both the group name scp and the trigger point triggerpoint2. So the rules that are under the agenda-group scp-triggerpoint2 are applicable.
  • From the below reference rules, the rule scp-rule-header-2 and scp-rule-body-1 will be applied.
Add the below rules to the mediation rules:
function Map<Object, Object> addObject() {
    return new HashMap<Object, Object>();
}
 
function ArrayList<Object> addArray() {
    return new  ArrayList<Object>();
}
 
function Map<String,Object> ipEndPoints(String ipv4Address, String ipv6Address, String ipv6Prefix){
        Map< String,Object> ipEndPointObj = new HashMap< String,Object>();
        ipEndPointObj.put("ipv4Address", ipv4Address);
        ipEndPointObj.put("ipv6Address", ipv6Address);
        ipEndPointObj.put("ipv6Prefix",ipv6Prefix );
        return ipEndPointObj;
}
 
rule "New Rule1"
    agenda-group "scp"
when
    req : Request(body.get("$.apiPrefix")=="/mediation")
then
    req.headers.put("x-dest-path",req.body.get("$.apiPrefix").toString())
end
 
rule "New Rule2"
when
    req : Request(body.has("$.defaultNotificationSubscriptions[*].callbackUri","pcf.oracle.com/pcs/v1.0/nrf/notifycallback"))
then
    req.body.add("$.ipEndPoints",ipEndPoints("10.75.243.193","2001:0db8:85a3:0000:0000:8a2e:0370:7335","2001:0db8:85a3"))
 
end
 
rule "New Rule3"
when
    req : Request(headers.has("x-forwarded-NF","PCF") && body.has("$.fqdn","pcf.oracle.com"))
then
    req.headers.put("x-forwarded-NF","AMF")
    req.body.put("$","fqdn","amf.oracle.com")
end
 
rule "New Rule4"
when
    req : Request(body.get("$.serviceName")=="svc1")
then
    req.headers.del("x-service-name")
end
 
rule "New Rule5"
when
   req : Request(headers.get("x-number")  in (1,2,3,4,5 ))
then
   req.headers.put( "x-original-authority", "10.172.19.110:8080")
end

Configuring Diameter Peer

The peer nodes are configured in the configmap-pcf-diam-gateway-service-diameter.yaml file present in the location chart pcf/templates.

Note:

The IWF does not listen for incoming connections, as the connection with diameter peer is always initiated by IWF.

Following is a sample yaml file.

apiVersion: v1
kind: ConfigMap
metadata:
  name: pcf-diam-gateway-config-peers
data:
  diameter-config-peers: |
    version: '0.3'
    kind: 'diameter-config'
    metadata:
      label: 'diameter-config-peers'
    setting:
      reconnectDelay: 3
      responseTimeout: 5
      connectionTimeOut: 3
      watchdogInterval: 6
      transport: 'TCP'
    # type: [af, dra]
    nodes:
      - name: 'P-CSCF'
        type: 'pcrf'
        responseOnly: true
        host: '10.75.215.205'
        port: 3880
        realm: 'ociwf.oracle.com'
        identity: 'pcrfsim.ociwf.oracle.com'

Table 3-3 provides information about the yaml file parameters.

Table 3-3 Config Yaml File Parameter

Parameters Definitions
reconnectDelay Time delay in seconds between successive peer connection establishment attempts
responseTimeout Response timer value in seconds
connectionTimeOut Connection timer value in seconds
watchdogInterval Inactivity time in seconds after which DWR will be triggered
transport Transport protocol type "TCP"
Nodes (list) name Name of the peer node
responseOnly Indicates the Diameter GW proxy client or server
host IP address of the peer node
port Port on which peer node listens for connections
realm Realm of the peer node
identity FQDN of the peer node

PCF Discovery Configuration

Update the BSF details in the pcfDiscovery section in ociwf-custom-values-1.5.0.yaml file

  • BSF (Binding Support Function) Configuration
    • bsfSvc: FQDN or IP of BSF service
    • bsfPort: Node Port of BSF service,
  • NRF Configuration
    • requesterNfType: e.g. CUSTOM_IWF
    • targetNfType: e.g. BSF
  • NRF Client configuration
    • Update primaryNrfApiRoot with fqdn of the deployed nrf's ingress gateway
    • Update nrfClientType in profile (It must match with requesterNfType value provided in pcfDiscovery)

Rules in Configmap

Reloading the IWF-Mediation ConfigMap, if in case any updates were made in the Rules.

The tool ociwf-rule-download_tool.sh can be used to download the rule config map in a folder(folder name must be configmap name). It needs namespace as well as required configmap name. These rules then can be changed accordingly.

The tool ociwf-rule-upload_tool.sh can be used to upload the rule config map from the existing config map folder. It needs namespace as well as required configmap name to be uploaded.

•If rules changed on iwf active mediation then use ociwf-iwf-mediation-config-active"as the name of configmap.

•If rules changed on iwf test mediation then use ociwf-iwf-mediation-config-test as the name of the configmap.

Reloading the NF-Mediation ConfigMap, if in case any updates were made in the Rules.

The tool ociwf-rule-download_tool.sh can be used to download the rule config map in a folder(folder name will be configmap name). It needs namespace as well as required configmap name. These rules then can be changed accordingly.

The tool ociwf-rule-upload_tool.sh can be used to upload the rule config map from the existing config map folder. It needs namespace as well as required configmap name to be uploaded.

•If rules changed on nf active mediation then use ociwf-nf-mediation-config-active as the name of the configmap.

•If rules changed on nf test mediation then use ociwf-nf-mediation-config-test as the name of the configmap.