• 沒有找到結果。

1. DecisionEngine.java

package pcrf;

import java.io.*;

import java.net.*;

import java.util.*;

import de.fhg.fokus.Constants;

import de.fhg.fokus.diameter.DiameterPeer.data.AVP;

import

de.fhg.fokus.diameter.DiameterPeer.data.DiameterMessa ge;

import

de.fhg.fokus.diameter.DiameterPeer.transaction.Transact ionListener;

import

de.fhg.fokus.diameter.DiameterPeer.DiameterPeer;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

import org.xml.sax.SAXException;

import org.apache.xml.serialize.XMLSerializer;

import org.apache.xml.serialize.OutputFormat;

/**

* DecisionEngine:

*

* This class implements the functions to deal with resource request at the PCRF

* - It loads all listed policies and policy profiles

* - defines policy processor blocks for each policy type

* - passes session information (new and modified) to each policy processor block (depending on priority) * - Enforces returned policy rules in the transport layer

*/

public class DecisionEngine {

DiameterPeer diameterPeer;

xcap policyEngine = null;

String[] policies = new String[10];

String policy_db = "";

String username ="";

String password = "";

int remote_xcap_server;

/** Decision Engine constructor intialises variables*/

public DecisionEngine(DiameterPeer diameterPeer, String policy_db, String[] policies, String username, String password, int remote_xcap_server) throws IOException

{

this.diameterPeer = diameterPeer;

this.diameterPeer.enableTransactions(10,1);

this.policies = policies;

this.policy_db = policy_db;

this.username = username;

this.password = password;

this.remote_xcap_server = remote_xcap_server;

policyEngine = new xcap (policy_db,

"domain_policies", username, password, remote_xcap_server);

}

/**

* this loads the necessary policies and invokes policy processor blocks based on priorities and trigger points

* and installs the created policy rule

* @param service information */

public int authorisation_request(String af_session, Vector ip_flows, Vector codecs) throws IOException

{

int result_code = -1;

/**Get policy profile information*/

/**policy name; priority; trigger point*/

Vector policy_vector = new Vector();

for (int a = 0; a < policies.length; a++) {

if(policies[a] != null) {

String policy_info = policies[a] +

";";

String profile_loc =

"/opt/OpenIMSCore/uctpcrf/policies/" + "profile_" + policies[a] + ".xml";

//read policy profile information Document doc = null;

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

try {

//Using factory get an instance of document builder

DocumentBuilder db = dbf.newDocumentBuilder();

//parse using builder to get DOM representation of the XML file

doc = db.parse(profile_loc);

}catch(ParserConfigurationException pce) { pce.printStackTrace();

}catch(SAXException se) { se.printStackTrace();

}catch(IOException ioe) { ioe.printStackTrace();

}

Element docEle = doc.getDocumentElement();

//get all policy information into vector format

NodeList nl = docEle.getElementsByTagName("priority");

if(nl != null && nl.getLength() >

0) {

Element priority = (Element)nl.item(0);

policy_info = policy_info + priority.getFirstChild().getNodeValue().toString() +

";";

}

nl =

docEle.getElementsByTagName("trigger_point");

if(nl != null && nl.getLength() >

0) {

Element trigger_point = (Element)nl.item(0);

NodeList nl1 = trigger_point.getElementsByTagName("media");

if(nl1 != null &&

nl1.getLength() > 0)

{

Element media = (Element)nl1.item(0);

policy_info = policy_info +

media.getFirstChild().getNodeValue().toString();

//check if session is new request or already existing

//if already existing remove current IP flow rules from the bearer level

//extract session ID StringTokenizer st = new StringTokenizer(af_session,";");

/**The session ID has 2 semi-colons in it, so 3 tokens form the session ID*/

/**TO DO Define a way to decide how long the session id is, perhaps read from the back*/

String session_id = st.nextToken();

session_id = session_id + ";" + st.nextToken();

session_id = session_id + ";" + st.nextToken();

String orig_realm = st.nextToken();

String dest_realm = st.nextToken();

if(policyEngine.sessionExists(session_id) ==

1)

{

System.out.println("INFO: Session ID:

" + session_id + " already exists, removing current IP Flow rules");

//remove IP flows from bearer level Vector current_ip_flows = policyEngine.getIPFlows(session_id);

for (int b = 0; b <

current_ip_flows.size(); b++)

{

int avail_QoS_ul = 0;

int avail_QoS_dl = 0;

st = new

StringTokenizer(current_ip_flows.get(b).toString(),";");

session_id = st.nextToken();

session_id = session_id + ";" + st.nextToken();

session_id = session_id + ";" + st.nextToken();

String flow_id = st.nextToken();

String source_ip = st.nextToken();

String dest_ip = st.nextToken();

int dest_port = Integer.valueOf(st.nextToken()).intValue();

int source_port = Integer.valueOf(st.nextToken()).intValue();

int QoS_class = Integer.valueOf(st.nextToken()).intValue();

int guaranteed_br_ul = bw_ul;

//defaults to same as max

int guaranteed_br_dl = bw_dl;

//defaults to same as max

String PCC_rule_name = session_id + ";" + flow_id;

String pcef_address = "";

/**Only send DIAMETER RAR remove message if flow is already enabled*/

if(status ==

Constants.FlowStatus.ENABLED) {

/**Send DIAMETER RAR remove message via Gx*/

DiameterMessage rar = createRAR(session_id,dest_realm,PCC_rule_name,sourc e_ip,dest_ip,source_port,dest_port,QoS_class,bw_ul,bw_

dl,guaranteed_br_ul,guaranteed_br_dl,1); //command - 1 remove

System.out.println();

System.out.println("---");

System.out.println();

System.out.println("INFO:

Sending DIAMETER RAR message to PCEF");

pcef_address = policyEngine.getPCEF(orig_realm,dest_realm);

DiameterMessage raa = diameterPeer.sendRequestBlocking(pcef_address,rar);

if (raa==null) {

System.out.println("INFO: Time out waiting for PCEF RAA via Gx");

result_code = Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else {

System.out.println();

System.out.println("INFO: Received DIAMETER RAA message from PCEF");

if

(raa.commandCode == Constants.Command.RAA)

{

AVP result_code_avp =

raa.findAVP(Constants.AVPCode.RESULT_CODE,true, Constants.Vendor.DIAM);

if(result_code_avp != null)

{

result_code = result_code_avp.int_data;

if(result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("INFO: Result code SUCCESS received from PCEF");

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_INITIAL _PARAMETERS)

{

System.out.println("INFO: Result code INVALID INITIAL PARAMETERS received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_TRIGGE R_EVENT)

{

System.out.println("INFO: Result code TRIGGER ERROR EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else if(result_code ==

Constants.ResultCode._DIAMETER_PCC_RULE_EVE NT)

{

System.out.println("INFO: Result code PCC RULE EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else {

System.out.println("INFO: Unknown Result Code received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} } } }

System.out.println("INFO:

IP Flow with flow id: " + flow_id + " is being removed from the bearer level");

} }

} else {

result_code =

Constants.ResultCode._DIAMETER_SUCCESS;

}

if(result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

//invoke policies according to priority and trigger points

//find highest priority and invoke - then remove policy and find next highest priority policy - continue until all policies invoked

while(policy_vector.size()>0) {

int highest_priority = 100;

int highest_priority_tag = -1;

for (int a = 0; a <

policy_vector.size(); a++) {

st = new

StringTokenizer(policy_vector.get(a).toString(),";");

st.nextToken();

int priority = Integer.valueOf(st.nextToken()).intValue();

if(priority <

highest_priority)

{

highest_priority = priority;

highest_priority_tag

= a;

}

}

//policy with highest priority is policy_vector(a)

//create policy processor block for this policy

//pass info to this processor block and result code in return

//if result success enforce IP Flows

//then remove policy from policy vector

st = new

StringTokenizer(policy_vector.get(highest_priority_tag).

toString(),";");

String policy = st.nextToken();

st.nextToken();

String trigger_point = st.nextToken();

if(policy.equals("domain_policies")) {

if(trigger_point.equals("ANY")) {

DomainPolicyProcessor dpp = new

DomainPolicyProcessor(diameterPeer, policy_db, policy, username, password, remote_xcap_server);

result_code = dpp.authorisation_request(af_session, ip_flows, codecs);

} }

policy_vector.removeElementAt(highest_priority_t ag);

/**TO DO Add support to create dynamic Policy Processor Blocks*/

//ADD new policy processor blocks here - remember to check the trigger points for each IP Flow which determine whether that policy should be called

}

/**To enforce ENABLED IP Flows in the bearer level*/

if (result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

result_code =

enforce_IP_Flows(ip_flows, orig_realm, dest_realm);

}

if (result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("\nINFO: The Request is Successful. The new session has ID : " + session_id);

} }

return result_code;

}

/**

* This methods check through a session IP Flows and enforces those marked ENABLED in the bearer level

* @param ip_flows all IP Flows assocaited with IMS session

* @param orig_realm the realm or domain of the orginating user

* @param dest_realm the realm or domain of the destination user

*/

public int enforce_IP_Flows(Vector ip_flows, String orig_realm, String dest_realm) throws IOException

{

int result_code = -1;

int b = 0;

for (b = 0; b < ip_flows.size(); b++) {

StringTokenizer st = new StringTokenizer(ip_flows.get(b).toString(),";");

String session_id = st.nextToken();

session_id = session_id + ";" + st.nextToken();

session_id = session_id + ";" + st.nextToken();

String flow_id = st.nextToken();

String source_ip = st.nextToken();

String dest_ip = st.nextToken();

int dest_port =

Integer.valueOf(st.nextToken()).intValue();

int source_port =

Integer.valueOf(st.nextToken()).intValue();

int guaranteed_br_ul = bw_ul;

//defaults to same as max

int guaranteed_br_dl = bw_dl;

//defaults to same as max

String PCC_rule_name = session_id +

";" + flow_id;

int QoS_class =

Integer.valueOf(st.nextToken()).intValue();

System.out.println(session_id + ";" + flow_id + ";" + source_ip + ";" + dest_ip + ";" + source_port + ";" + dest_port + ";" + usage + ";" + status + ";" + bw_ul + ";" + bw_dl + ";" + QoS_class);

String pcef_address = "";

/** enable the IP Flow in the bearer level*/

if(status ==

Constants.FlowStatus.ENABLED) {

/**Send Diameter RAR install message via Gx*/

DiameterMessage rar =

createRAR(session_id,dest_realm,PCC_rule_name,sourc e_ip, dest_ip,

source_port,dest_port,QoS_class,bw_ul,bw_dl,guarantee d_br_ul,guaranteed_br_dl,2); //command - 2 for install

System.out.println();

System.out.println("---");

System.out.println();

System.out.println("INFO:

Sending DIAMETER RAR message to PCEF");

pcef_address =

policyEngine.getPCEF(orig_realm,dest_realm);

DiameterMessage raa = diameterPeer.sendRequestBlocking(pcef_address,rar);

if (raa==null) {

System.out.println("INFO:

Time out waiting for PCEF RAA via Gx");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

ATION;

return result_code;

} else {

if (raa.commandCode ==

Constants.Command.RAA) {

System.out.println();

System.out.println("INFO: Received DIAMETER RAA message from PCEF");

AVP result_code_avp =

raa.findAVP(Constants.AVPCode.RESULT_CODE,true, Constants.Vendor.DIAM);

if(result_code_avp != null) {

result_code = result_code_avp.int_data;

if(result_code

== Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("INFO: AAR Result code SUCCESS received from PCEF");

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_INITIAL _PARAMETERS)

{

System.out.println("INFO: AAR Result code INVALID INITIAL PARAMETERS received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_TRIGGE R_EVENT)

{

System.out.println("INFO: Result code TRIGGER ERROR EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else if(result_code ==

Constants.ResultCode._DIAMETER_PCC_RULE_EVE NT)

{

System.out.println("INFO: Result code PCC RULE EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else {

System.out.println("INFO: Unknown Result Code received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

System.out.println("INFO: IP Flow with flow id: " + flow_id + " is being enforced in the bearer level");

}

/** disable the IP Flow in the bearer level*/

else if (status ==

Constants.FlowStatus.DISABLED) {

/**Send DIAMETER RAR remove message via Gx*/

DiameterMessage rar =

createRAR(session_id,dest_realm,PCC_rule_name,sourc e_ip,dest_ip,

source_port,dest_port,QoS_class,bw_ul,bw_dl,guarantee d_br_ul,guaranteed_br_dl,1); //command - 1 for remove

System.out.println();

System.out.println("---");

System.out.println();

System.out.println("INFO:

Sending DIAMETER RAR message to PCEF");

pcef_address =

policyEngine.getPCEF(orig_realm,dest_realm);

DiameterMessage raa = diameterPeer.sendRequestBlocking(pcef_address,rar);

if (raa==null) {

System.out.println("INFO:

Time out waiting for PCEF RAA via Gx");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else {

if (raa.commandCode ==

Constants.Command.RAA) {

System.out.println();

System.out.println("INFO: Received DIAMETER RAA message from PCEF");

AVP result_code_avp =

raa.findAVP(Constants.AVPCode.RESULT_CODE,true, Constants.Vendor.DIAM);

if(result_code_avp != null) {

result_code = result_code_avp.int_data;

if(result_code

== Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("INFO: AAR Result code SUCCESS received from PCEF");

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_INITIAL _PARAMETERS)

{

System.out.println("INFO: AAR Result code INVALID INITIAL PARAMETERS received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_TRIGGE R_EVENT)

{

System.out.println("INFO: Result code TRIGGER ERROR EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM if(result_code ==

Constants.ResultCode._DIAMETER_PCC_RULE_EVE NT)

{

System.out.println("INFO: Result code PCC RULE EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

System.out.println("INFO: Unknown Result Code received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

System.out.println("INFO: IP Flow with flow id: " + flow_id + " is being removed from the bearer level");

} else {

System.out.println("INFO: Flow status not yet recognised");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} }

if(result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("INFO: IP Flows associated with IMS session have been successfully processed");

}

return result_code;

}

/**

* this loads the necessary policies and invokes policy processor blocks based on priorities and trigger points

* and removes the created policy rule

* @param af_session session information */

public int termination_request(String af_session) throws IOException

{

int result_code = -1;

StringTokenizer st = new StringTokenizer(af_session,";");

String session_id = st.nextToken();

session_id = session_id + ";" + st.nextToken();

session_id = session_id + ";" + st.nextToken();

String orig_realm = st.nextToken();

String dest_realm = st.nextToken();

/**Get policy profile information*/

/**policy name; priority; trigger point*/

Vector policy_vector = new Vector();

for (int a = 0; a < policies.length; a++) {

if(policies[a] != null) {

String policy_info = policies[a] +

";";

String profile_loc =

"/opt/OpenIMSCore/uctpcrf/policies/" + "profile_" + policies[a] + ".xml";

//read policy profile information

Document doc = null;

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

try {

//Using factory get an instance of document builder

DocumentBuilder db = dbf.newDocumentBuilder();

//parse using builder to get DOM representation of the XML file

doc = db.parse(profile_loc);

}catch(ParserConfigurationException pce) { pce.printStackTrace();

}catch(SAXException se) { se.printStackTrace();

}catch(IOException ioe) { ioe.printStackTrace();

}

Element docEle = doc.getDocumentElement();

//get all policy information into vector format

NodeList nl = docEle.getElementsByTagName("priority");

if(nl != null && nl.getLength() >

0) {

Element priority = (Element)nl.item(0);

policy_info = policy_info + priority.getFirstChild().getNodeValue().toString() +

";";

}

nl =

docEle.getElementsByTagName("trigger_point");

if(nl != null && nl.getLength() >

0) {

Element trigger_point = (Element)nl.item(0);

NodeList nl1 = trigger_point.getElementsByTagName("media");

if(nl1 != null &&

nl1.getLength() > 0)

{

Element media = (Element)nl1.item(0);

policy_info = policy_info +

media.getFirstChild().getNodeValue().toString();

//remove IP flows from bearer level Vector current_ip_flows = policyEngine.getIPFlows(session_id);

for (int b = 0; b < current_ip_flows.size();

b++) {

int avail_QoS_ul = 0;

int avail_QoS_dl = 0;

st = new

StringTokenizer(current_ip_flows.get(b).toString(),";");

session_id = st.nextToken();

session_id = session_id + ";" + st.nextToken();

session_id = session_id + ";" + st.nextToken();

String flow_id = st.nextToken();

String source_ip = st.nextToken();

String dest_ip = st.nextToken();

int dest_port =

Integer.valueOf(st.nextToken()).intValue();

int source_port =

Integer.valueOf(st.nextToken()).intValue();

int QoS_class =

Integer.valueOf(st.nextToken()).intValue();

int guaranteed_br_ul = bw_ul;

//defaults to same as max

int guaranteed_br_dl = bw_dl;

//defaults to same as max

String PCC_rule_name = session_id +

";" + flow_id;

String pcef_address = "";

/**Only send DIAMETER RAR remove message if flow is already enabled*/

if(status ==

Constants.FlowStatus.ENABLED) {

/**Send DIAMETER RAR remove message via Gx*/

DiameterMessage rar =

createRAR(session_id,dest_realm,PCC_rule_name,sourc e_ip,dest_ip,source_port,dest_port,QoS_class,bw_ul,bw_

dl,guaranteed_br_ul,guaranteed_br_dl,1); //command - 1 remove

System.out.println();

System.out.println("---");

System.out.println();

System.out.println("INFO:

Sending DIAMETER RAR message to PCEF");

pcef_address =

policyEngine.getPCEF(orig_realm,dest_realm);

DiameterMessage raa = diameterPeer.sendRequestBlocking(pcef_address,rar);

int counter = 0;

if (raa==null) {

if(counter == 3) {

System.out.println("INFO: Time out waiting for PCEF RAA via Gx");

result_code = Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else {

try {

Thread.sleep(100);

}

catch (Exception err) {

err.printStackTrace();

}

counter++;

}

}

else {

System.out.println();

System.out.println("INFO:

Received DIAMETER RAA message from PCEF");

if (raa.commandCode ==

Constants.Command.RAA) {

AVP result_code_avp =

raa.findAVP(Constants.AVPCode.RESULT_CODE,true, Constants.Vendor.DIAM);

if(result_code_avp != null) {

result_code = result_code_avp.int_data;

if(result_code

== Constants.ResultCode._DIAMETER_SUCCESS) {

System.out.println("INFO: AAR Result code SUCCESS received from PCEF");

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_INITIAL _PARAMETERS)

{

System.out.println("INFO: AAR Result code INVALID INITIAL PARAMETERS received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM ATION;

return result_code;

} else if(result_code ==

Constants.ResultCode._DIAMETER_ERROR_TRIGGE R_EVENT)

{

System.out.println("INFO: Result code TRIGGER ERROR EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM if(result_code ==

Constants.ResultCode._DIAMETER_PCC_RULE_EVE NT)

{

System.out.println("INFO: Result code PCC RULE EVENT received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

System.out.println("INFO: Unknown Result Code received from PCEF");

result_code =

Constants.ResultCode._INVALID_SERVICE_INFORM

System.out.println("INFO: IP Flow with flow id: " + flow_id + " is being removed from the bearer level");

} }

if(result_code ==

Constants.ResultCode._DIAMETER_SUCCESS) {

//invoke policies according to priority and trigger points

//find highest priority and invoke - then remove policy and find next highest priority policy - continue until all policies invoked

while(policy_vector.size()>0) {

int highest_priority = 100;

int highest_priority_tag = -1;

for (int a = 0; a <

policy_vector.size(); a++) {

if(priority <

highest_priority)

{

highest_priority = priority;

highest_priority_tag

= a;

}

}

//policy with highest priority is policy_vector(a)

//create policy processor block for this policy

//pass info to this processor block and result code in return

//if result success enforce IP Flows

//then remove policy from policy vector

st = new

StringTokenizer(policy_vector.get(highest_priority_tag).

toString(),";");

String policy = st.nextToken();

st.nextToken();

String trigger_point = st.nextToken();

if(policy.equals("domain_policies")) {

if(trigger_point.equals("ANY")) {

DomainPolicyProcessor dpp = new

DomainPolicyProcessor(diameterPeer, policy_db, policy, username, password, remote_xcap_server);

result_code = dpp.termination_request(af_session);

} }

policy_vector.removeElementAt(highest_priority_t ag);

/**TO DO Add support to create dynamic Policy Processor Blocks*/

//ADD new policy processor blocks here - remember to check the trigger points for each IP Flow which determine whether that policy should be called

}

System.out.println("INFO: IMS with session_id: " + session_id + " has been removed as well as all associated IP Flows");

}

return result_code;

}

/**

* This creates a DIAMETER RAR message

* @param input */

private DiameterMessage createRAR (String session_id,String destination_realm,String

PCC_rule_name,String source_ip,String dest_ip,int source_port,int dest_port,int qos_class_identifier,int max_bw_ul,int max_bw_dl,int guaranteed_br_ul,int guaranteed_br_dl, int command)

{

DiameterMessage rar =

diameterPeer.newRequest(Constants.Command.RAR,Co nstants.Application.GX);

/**add session-id*/

AVP session_id_avp = new AVP(Constants.AVPCode.SESSION_ID,true, Constants.Vendor.DIAM);

session_id_avp.setData(session_id);

rar.addAVP(session_id_avp);

/**add Auth Application id */

AVP auth_application_id_avp = new AVP(Constants.AVPCode.AUTH_APPLICATION_ID, true, Constants.Vendor.DIAM);

auth_application_id_avp.setData(Constants.Application.

GX);

rar.addAVP(auth_application_id_avp);

/**add destination-realm*/

AVP destination_realm_avp = new

AVP(AVP.Destination_Realm,true,Constants.Vendor.DI AM);

destination_realm_avp.setData(destination_realm);

rar.addAVP(destination_realm_avp);

if(command == 1) {

/**add PCC Rule remove*/

AVP charging_rule_remove_avp = new

AVP(Constants.AVPCode.CHARGING_RULE_REMO VE,true,Constants.Vendor.V3GPP);

/*Charging rule definition*/

AVP charging_rule_definition_avp = new

AVP(Constants.AVPCode.CHARGING_RULE_DEFIN ITION,true,Constants.Vendor.V3GPP);

/*Flow description1*/

AVP flow_description_avp = new

AVP(Constants.AVPCode.FLOW_DESCRIPTION,true, Constants.Vendor.V3GPP);

String flow = "permit out ip from

" + source_ip + " to " + dest_ip + " " + dest_port;

flow_description_avp.setData(flow);

charging_rule_definition_avp.addChildAVP(flow_

description_avp);

/*Flow description2*/

flow_description_avp = new AVP(Constants.AVPCode.FLOW_DESCRIPTION,true, Constants.Vendor.V3GPP);

flow = "permit in ip from " + dest_ip + " to " + source_ip + " " + source_port;

flow_description_avp.setData(flow);

flow_description_avp.setData(flow);

相關文件