Created abstract super class for all COPS Message Senders as each contained duplicate... 50/19550/2
authorSteven Pisarski <s.pisarski@cablelabs.com>
Mon, 4 May 2015 19:57:34 +0000 (13:57 -0600)
committerThomas Kee <xsited@yahoo.com>
Fri, 8 May 2015 19:52:01 +0000 (12:52 -0700)
Change-Id: I9d2d5e61e4f8816bf1e4f6faff507fe1a6a09763
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-driver/src/main/java/org/pcmm/PCMMPdpMsgSender.java
packetcable-driver/src/main/java/org/umu/cops/COPSMsgSender.java [new file with mode: 0644]
packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSMsgSender.java
packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSMsgSender.java
packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpMsgSender.java
packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepMsgSender.java

index ab71aeeb1cb529dfdd469d44d4d30eb3578fde16..6ed55206509efd316a63d8dae7ed4db66f48da46 100644 (file)
@@ -10,6 +10,7 @@ import org.pcmm.gates.IGateSpec.Direction;
 import org.pcmm.gates.impl.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.umu.cops.COPSMsgSender;
 import org.umu.cops.prpdp.COPSPdpException;
 import org.umu.cops.stack.*;
 import org.umu.cops.stack.COPSClientSI.CSIType;
@@ -29,8 +30,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-//temp
-//pcmm
 /*
  * Example of an UNSOLICITED decision
  *
@@ -46,31 +45,13 @@ import java.util.Set;
 /**
  * COPS message transceiver class for provisioning connections at the PDP side.
  */
-public class PCMMPdpMsgSender {
+public class PCMMPdpMsgSender extends COPSMsgSender {
 
     public final static Logger logger = LoggerFactory.getLogger(PCMMPdpMsgSender.class);
 
-    /**
-     * Socket connected to PEP
-     */
-    protected final Socket _sock;
-
-    /**
-     * COPS client-type that identifies the policy client
-     */
-    protected final short _clientType;
-
-    /**
-     * COPS client handle used to uniquely identify a particular PEP's request
-     * for a client-type
-     */
-    protected final COPSHandle _handle;
-
-    /**
-     *
-     */
     protected short _transactionID;
     protected final short _classifierID;
+
     // XXX - this does not need to be here
     protected IGateID _gateID;
 
@@ -91,23 +72,9 @@ public class PCMMPdpMsgSender {
 
     public PCMMPdpMsgSender(final short clientType, final short tID, final COPSHandle clientHandle,
                             final Socket sock) throws COPSPdpException {
-        if (clientHandle == null) throw new COPSPdpException("Client handle must not be null");
-        if (sock == null) throw new COPSPdpException("Socket must not be null");
-        // COPS Handle
-        _handle = clientHandle;
-        _clientType = clientType;
+        super(clientType, clientHandle, sock);
         _transactionID = tID;
         _classifierID = 0;
-        _sock = sock;
-    }
-
-    /**
-     * Gets the client-type
-     *
-     * @return Client-type value
-     */
-    public short getClientType() {
-        return _clientType;
     }
 
     /**
@@ -159,9 +126,7 @@ public class PCMMPdpMsgSender {
         decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
 
         final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
-
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, new COPSHandle(_handle.getId()),
-                decisionMap, null, clientSD);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
 
         // ** Send the GateSet Decision
         try {
@@ -329,8 +294,7 @@ public class PCMMPdpMsgSender {
 
         // Common Header with the same ClientType as the request
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(),
-                new COPSHandle(_handle.getId()), decisionMap, null, clientSD);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
 
         // ** Send the GateSet Decision
         // **
@@ -489,8 +453,7 @@ public class PCMMPdpMsgSender {
 
         // Common Header with the same ClientType as the request
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, new COPSHandle(_handle.getId()),
-                decisionMap, null, clientSD);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
 
         // ** Send the GateSet Decision
         // **
@@ -559,10 +522,6 @@ public class PCMMPdpMsgSender {
         .setRequestTransmissionPolicy(
             PCMMGlobalConfig.BETransmissionPolicy);
 
-        // byte[] content = "1234".getBytes();
-
-        // handle.setId(new COPSData(content, 0, content.length));
-
         // set transaction ID to gate set
         trID.setGateCommandType(ITransactionID.GateSet);
         _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
@@ -613,8 +572,7 @@ public class PCMMPdpMsgSender {
         final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
 
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(),
-                new COPSHandle(_handle.getId()), decisionMap, null, clientSD);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
 
         // ** Send the GateSet Decision
         // **
@@ -657,8 +615,7 @@ public class PCMMPdpMsgSender {
         decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
         final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
 
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(),
-                new COPSHandle(_handle.getId()), decisionMap, null, clientSD);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
 
         // ** Send the GateDelete Decision
         // **
@@ -687,8 +644,7 @@ public class PCMMPdpMsgSender {
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
         decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
 
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), new COPSHandle(_handle.getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
 
         try {
             decisionMsg.writeData(_sock);
@@ -706,7 +662,7 @@ public class PCMMPdpMsgSender {
         /*
          * <Gate-Info> ::= <Common Header> [<Client Handle>] [<Integrity>]
          */
-        final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), new COPSHandle(_handle.getId()), null);
+        final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
         try {
             msg.writeData(_sock);
         } catch (IOException e) {
@@ -726,7 +682,7 @@ public class PCMMPdpMsgSender {
          */
 
         // Client Handle with the same clientHandle as the request
-        final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), new COPSHandle(_handle.getId()), null);
+        final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
         try {
             msg.writeData(_sock);
         } catch (IOException e) {
diff --git a/packetcable-driver/src/main/java/org/umu/cops/COPSMsgSender.java b/packetcable-driver/src/main/java/org/umu/cops/COPSMsgSender.java
new file mode 100644 (file)
index 0000000..e26db97
--- /dev/null
@@ -0,0 +1,52 @@
+package org.umu.cops;
+
+import org.umu.cops.stack.COPSHandle;
+
+import java.net.Socket;
+
+/**
+ * Abstract COPS Message sender
+ */
+public abstract class COPSMsgSender {
+
+    /**
+     * COPS client-type that identifies the policy client
+     */
+    protected final short _clientType;
+
+    /**
+     * COPS client handle used to uniquely identify a particular
+     * PEP's request for a client-type
+     */
+    protected final COPSHandle _handle;
+
+    /**
+     * Socket connected to PEP
+     */
+    protected final Socket _sock;
+
+    public COPSMsgSender(final short clientType, final COPSHandle handle, final Socket sock) {
+        if (handle == null) throw new IllegalArgumentException("Client handle must not be null");
+        if (sock == null) throw new IllegalArgumentException("Socket must not be null");
+        this._clientType = clientType;
+        this._handle = handle;
+        this._sock = sock;
+    }
+
+    /**
+     * Gets the client handle
+     * @return   Client's <tt>COPSHandle</tt>
+     */
+    public COPSHandle getClientHandle() {
+        return _handle;
+    }
+
+    /**
+     * Gets the client-type
+     * @return   Client-type value
+     */
+    public short getClientType() {
+        return _clientType;
+    }
+
+}
index d4005a05c221e427e423bb0332382e92039d302d..51c458c4267d5b3880fe2458ce12c3f02a7e8c0f 100644 (file)
@@ -1,5 +1,6 @@
 package org.umu.cops.ospdp;
 
+import org.umu.cops.COPSMsgSender;
 import org.umu.cops.stack.*;
 import org.umu.cops.stack.COPSContext.RType;
 import org.umu.cops.stack.COPSDecision.Command;
@@ -15,22 +16,7 @@ import java.util.*;
  *
  * TODO - change all references of Vector to List<>
  */
-public class COPSPdpOSMsgSender {
-    /**
-     * Socket connected to PEP
-     */
-    protected final Socket _sock;
-
-    /**
-     * COPS client-type that identifies the policy client
-     */
-    protected final short _clientType;
-
-    /**
-     * COPS client handle used to uniquely identify a particular
-     * PEP's request for a client-type
-     */
-    protected final COPSHandle _handle;
+public class COPSPdpOSMsgSender extends COPSMsgSender {
 
     /**
      * Creates a COPSPepMsgSender
@@ -39,28 +25,8 @@ public class COPSPdpOSMsgSender {
      * @param clientHandle      Client handle
      * @param sock              Socket to the PEP
      */
-    public COPSPdpOSMsgSender (final short clientType, final COPSHandle clientHandle, final Socket sock) {
-        // COPS Handle
-        _handle = clientHandle;
-        _clientType = clientType;
-
-        _sock = sock;
-    }
-
-    /**
-     * Gets the client handle
-     * @return   Client's <tt>COPSHandle</tt>
-     */
-    public COPSHandle getClientHandle() {
-        return _handle;
-    }
-
-    /**
-     * Gets the client-type
-     * @return   Client-type value
-     */
-    public short getClientType() {
-        return _clientType;
+    public COPSPdpOSMsgSender(final short clientType, final COPSHandle clientHandle, final Socket sock) {
+        super(clientType, clientHandle, sock);
     }
 
     /**
@@ -121,8 +87,8 @@ public class COPSPdpOSMsgSender {
         }
 
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(1, flag, getClientType(),
-                new COPSHandle(getClientHandle().getId()), decisions, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(1, flag, getClientType(), _handle, decisions,
+                null, null);
 
         //** Send decision
         //**
@@ -145,8 +111,7 @@ public class COPSPdpOSMsgSender {
 
         // Common Header with the same ClientType as the request (default UNSOLICITED)
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), new COPSHandle(_handle.getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
 
         try {
             decisionMsg.writeData(_sock);
@@ -161,18 +126,7 @@ public class COPSPdpOSMsgSender {
      * @throws   COPSPdpException
      *
      */
-    //FIXME: Unused?
     public void sendOpenNewRequestState() throws COPSPdpException {
-        /* <Decision Message> ::= <Common Header: Flag UNSOLICITED>
-         *                          <Client Handle>
-         *                          *(<Decision>)
-         *                          [<Integrity>]
-         * <Decision> ::= <Context>
-         *                  <Decision: Flags>
-         * <Decision: Flags> ::= Install Request-State
-         *
-        */
-
         final Set<COPSDecision> decisionSet = new HashSet<>();
         decisionSet.add(new COPSDecision(Command.INSTALL, DecisionFlag.REQSTATE));
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
@@ -180,8 +134,7 @@ public class COPSPdpOSMsgSender {
 
         // Common Header with the same ClientType as the request (default UNSOLICITED)
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), new COPSHandle(_handle.getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
 
         try {
             decisionMsg.writeData(_sock);
@@ -195,14 +148,8 @@ public class COPSPdpOSMsgSender {
      * @throws COPSPdpException
      */
     public void sendSyncRequestState() throws COPSPdpException {
-        /* <Synchronize State Request>  ::= <Common Header>
-         *                                  [<Client Handle>]
-         *                                  [<Integrity>]
-         */
-
-        // Common Header with the same ClientType as the request
         // Client Handle with the same clientHandle as the request
-        final COPSSyncStateMsg msg = new COPSSyncStateMsg(_clientType, new COPSHandle(_handle.getId()), null);
+        final COPSSyncStateMsg msg = new COPSSyncStateMsg(_clientType, _handle, null);
         try {
             msg.writeData(_sock);
         } catch (IOException e) {
index 5ddeed14987f29902db68e061b2354d25dba57e8..82bd5915db5585d609d3fe80677a491033554b39 100644 (file)
@@ -1,5 +1,6 @@
 package org.umu.cops.ospep;
 
+import org.umu.cops.COPSMsgSender;
 import org.umu.cops.stack.*;
 import org.umu.cops.stack.COPSContext.RType;
 import org.umu.cops.stack.COPSReason.ReasonCode;
@@ -13,22 +14,7 @@ import java.util.Set;
 /**
  * COPS message transceiver class for outsourcing connections at the PEP side.
  */
-public class COPSPepOSMsgSender {
-    /**
-     * Socket connection to PDP
-     */
-    protected Socket _sock;
-
-    /**
-     * COPS client-type that identifies the policy client
-     */
-    protected short _clientType;
-
-    /**
-     * COPS client handle used to uniquely identify a particular
-     * PEP's request for a client-type
-     */
-    protected COPSHandle _handle;
+public class COPSPepOSMsgSender extends COPSMsgSender {
 
     /**
      * Creates a COPSPepMsgSender
@@ -37,28 +23,8 @@ public class COPSPepOSMsgSender {
      * @param clientHandle      Client handle
      * @param sock              Socket connected to the PDP
      */
-    public COPSPepOSMsgSender (final short clientType, final COPSHandle clientHandle, final Socket sock) {
-        // COPS Handle
-        _handle = clientHandle;
-        _clientType = clientType;
-
-        _sock = sock;
-    }
-
-    /**
-     * Gets the client handle
-     * @return  Client's <tt>COPSHandle</tt>
-     */
-    public COPSHandle getClientHandle() {
-        return _handle;
-    }
-
-    /**
-     * Gets the client-type
-     * @return  Client-type value
-     */
-    public int getClientType() {
-        return _clientType;
+    public COPSPepOSMsgSender(final short clientType, final COPSHandle clientHandle, final Socket sock) {
+        super(clientType, clientHandle, sock);
     }
 
     /**
index af246724bef142b8890a9f058252f90cb4ee022f..677ff8c0287e41cd970bcd70b4cfaf0427796996 100644 (file)
@@ -6,6 +6,7 @@
 
 package org.umu.cops.prpdp;
 
+import org.umu.cops.COPSMsgSender;
 import org.umu.cops.stack.*;
 import org.umu.cops.stack.COPSContext.RType;
 import org.umu.cops.stack.COPSDecision.Command;
@@ -24,23 +25,7 @@ import java.util.Set;
  *
  * TODO - Need to continue refactoring by removing all instances of Hashtable (change to Map<>)
  */
-public class COPSPdpMsgSender {
-
-    /**
-     * Socket connected to PEP
-     */
-    protected final Socket _sock;
-
-    /**
-     * COPS client-type that identifies the policy client
-     */
-    protected final short _clientType;
-
-    /**
-     * COPS client handle used to uniquely identify a particular
-     * PEP's request for a client-type
-     */
-    protected final COPSHandle _handle;
+public class COPSPdpMsgSender extends COPSMsgSender {
 
     /**
      * Creates a COPSPepMsgSender
@@ -50,27 +35,7 @@ public class COPSPdpMsgSender {
      * @param sock              Socket to the PEP
      */
     public COPSPdpMsgSender (final short clientType, final COPSHandle clientHandle, final Socket sock) {
-        // COPS Handle
-        _handle = clientHandle;
-        _clientType = clientType;
-
-        _sock = sock;
-    }
-
-    /**
-     * Gets the client handle
-     * @return   Client's <tt>COPSHandle</tt>
-     */
-    public COPSHandle getClientHandle() {
-        return _handle;
-    }
-
-    /**
-     * Gets the client-type
-     * @return   Client-type value
-     */
-    public short getClientType() {
-        return _clientType;
+        super(clientType, clientHandle, sock);
     }
 
     /**
@@ -81,24 +46,6 @@ public class COPSPdpMsgSender {
      */
     public void sendDecision(final Map<String, String> removeDecs, Map<String, String> installDecs)
             throws COPSPdpException {
-        /* <Decision Message> ::= <Common Header: Flag SOLICITED>
-         *                          <Client Handle>
-         *                          *(<Decision>) | <Error>
-         *                          [<Integrity>]
-         * <Decision> ::= <Context>
-         *                  <Decision: Flags>
-         *                  [<Named Decision Data: Provisioning>]
-         * <Decision: Flags> ::= <Command-Code> NULLFlag
-         * <Command-Code> ::= NULLDecision | Install | Remove
-         * <Named Decision Data> ::= <<Install Decision> | <Remove Decision>>
-         * <Install Decision> ::= *(<PRID> <EPD>)
-         * <Remove Decision> ::= *(<PRID> | <PPRID>)
-         *
-         * Very important, this is actually being treated like this:
-         * <Install Decision> ::= <PRID> | <EPD>
-         * <Remove Decision> ::= <PRID> | <PPRID>
-         *
-        */
 
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
 
@@ -147,11 +94,9 @@ public class COPSPdpMsgSender {
 
         // Common Header with the same ClientType as the request
         // Client Handle with the same clientHandle as the request
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, new COPSHandle(getClientHandle().getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, null);
 
         //** Send the decision
-        //**
         try {
             decisionMsg.writeData(_sock);
         } catch (IOException e) {
@@ -167,28 +112,6 @@ public class COPSPdpMsgSender {
      */
     public void sendUnsolicitedDecision(final Map<String, String> removeDecs, final Map<String, String> installDecs)
             throws COPSPdpException {
-        //** Example of an UNSOLICITED decision
-        //**
-
-        /* <Decision Message> ::= <Common Header: Flag UNSOLICITED>
-         *                          <Client Handle>
-         *                          *(<Decision>) | <Error>
-         *                          [<Integrity>]
-         * <Decision> ::= <Context>
-         *                  <Decision: Flags>
-         *                  [<Named Decision Data: Provisioning>]
-         * <Decision: Flags> ::= <Command-Code> NULLFlag
-         * <Command-Code> ::= NULLDecision | Install | Remove
-         * <Named Decision Data> ::= <<Install Decision> | <Remove Decision>>
-         * <Install Decision> ::= *(<PRID> <EPD>)
-         * <Remove Decision> ::= *(<PRID> | <PPRID>)
-         *
-         * Very important, this is actually being treated like this:
-         * <Install Decision> ::= <PRID> | <EPD>
-         * <Remove Decision> ::= <PRID> | <PPRID>
-         *
-        */
-
         // Common Header with the same ClientType as the request
         // Client Handle with the same clientHandle as the request
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
@@ -241,11 +164,9 @@ public class COPSPdpMsgSender {
         decisionMsg.add(intr);
         /**/
 
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, new COPSHandle(getClientHandle().getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, null);
 
         //** Send the decision
-        //**
         try {
             decisionMsg.writeData(_sock);
         } catch (IOException e) {
@@ -258,27 +179,13 @@ public class COPSPdpMsgSender {
      * @throws   COPSPdpException
      */
     public void sendDeleteRequestState() throws COPSPdpException {
-        /* <Decision Message> ::= <Common Header: Flag UNSOLICITED>
-         *                          <Client Handle>
-         *                          *(<Decision>)
-         *                          [<Integrity>]
-         * <Decision> ::= <Context>
-         *                  <Decision: Flags>
-         * <Decision: Flags> ::= Remove Request-State
-         *
-        */
-
-        // Decisions
-        //  <Context>
-        //  <Decision: Flags>
         final COPSDecision dec = new COPSDecision(Command.REMOVE, DecisionFlag.REQSTATE);
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
         final Set<COPSDecision> decisionSet = new HashSet<>();
         decisionSet.add(dec);
         decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
 
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), new COPSHandle(_handle.getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
         try {
             decisionMsg.writeData(_sock);
         } catch (IOException e) {
@@ -290,27 +197,14 @@ public class COPSPdpMsgSender {
      * Sends a request asking that a new request state be created
      * @throws   COPSPdpException
      */
-    public void sendOpenNewRequestState()
-    throws COPSPdpException {
-        /* <Decision Message> ::= <Common Header: Flag UNSOLICITED>
-         *                          <Client Handle>
-         *                          *(<Decision>)
-         *                          [<Integrity>]
-         * <Decision> ::= <Context>
-         *                  <Decision: Flags>
-         * <Decision: Flags> ::= Install Request-State
-         *
-        */
-
-        //  <Decision: Flags>
+    public void sendOpenNewRequestState() throws COPSPdpException {
         final COPSDecision dec = new COPSDecision(Command.INSTALL, DecisionFlag.REQSTATE);
         final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
         final Set<COPSDecision> decisionSet = new HashSet<>();
         decisionSet.add(dec);
         decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
 
-        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, new COPSHandle(_handle.getId()),
-                decisionMap, null, null);
+        final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, null);
 
         try {
             decisionMsg.writeData(_sock);
@@ -323,14 +217,8 @@ public class COPSPdpMsgSender {
      * Sends a message asking for a COPS sync operation
      * @throws COPSPdpException
      */
-    public void sendSyncRequestState()
-    throws COPSPdpException {
-        /* <Synchronize State Request>  ::= <Common Header>
-         *                                  [<Client Handle>]
-         *                                  [<Integrity>]
-         */
-
-        final COPSSyncStateMsg msg = new COPSSyncStateMsg(_clientType, new COPSHandle(_handle.getId()), null);
+    public void sendSyncRequestState() throws COPSPdpException {
+        final COPSSyncStateMsg msg = new COPSSyncStateMsg(_clientType, _handle, null);
         try {
             msg.writeData(_sock);
         } catch (IOException e) {
index 17a03b1c1a7e2d0f5593fbdcc5dfbe0c9422e5e4..278e0b43cfe26297ee205f57e7137d3b45dc6e48 100644 (file)
@@ -6,6 +6,7 @@
 
 package org.umu.cops.prpep;
 
+import org.umu.cops.COPSMsgSender;
 import org.umu.cops.stack.*;
 import org.umu.cops.stack.COPSClientSI.CSIType;
 import org.umu.cops.stack.COPSContext.RType;
@@ -24,23 +25,7 @@ import java.util.Set;
  * @version COPSPepMsgSender.java, v 2.00 2004
  *
  */
-public class COPSPepMsgSender {
-
-    /**
-     * Socket connection to PDP
-     */
-    protected Socket _sock;
-
-    /**
-     * The client-type identifies the policy client
-     */
-    protected short _clientType;
-
-    /**
-     * The client handle is used to uniquely identify a particular
-     * PEP's request for a client-type
-     */
-    protected COPSHandle _handle;
+public class COPSPepMsgSender extends COPSMsgSender {
 
     /**
      * Create a COPSPepMsgSender
@@ -49,32 +34,8 @@ public class COPSPepMsgSender {
      * @param clientHandle      client handle
      * @param sock              socket of PDP connection
      */
-    public COPSPepMsgSender (short clientType, COPSHandle clientHandle, Socket sock) {
-        // COPS Handle
-        _handle = clientHandle;
-        _clientType = clientType;
-
-        _sock = sock;
-    }
-
-    /**
-     * Return client handle
-     *
-     * @return   a COPSHandle
-     *
-     */
-    public COPSHandle getClientHandle() {
-        return _handle;
-    }
-
-    /**
-     * Return client-type
-     *
-     * @return   a short
-     *
-     */
-    public int getClientType() {
-        return _clientType;
+    public COPSPepMsgSender(short clientType, COPSHandle clientHandle, Socket sock) {
+        super(clientType, clientHandle, sock);
     }
 
     /**