library/DIAMETER_Templates: add templates for DWR/DWA

Change-Id: I2abe33a3ac08c8855342f4277288cacb3545771b
Related: SYS#5602
diff --git a/library/DIAMETER_Templates.ttcn b/library/DIAMETER_Templates.ttcn
index b27d144..fd4683e 100644
--- a/library/DIAMETER_Templates.ttcn
+++ b/library/DIAMETER_Templates.ttcn
@@ -244,6 +244,14 @@
 		}
 	}
 }
+template (present) GenericAVP tr_AVP_OriginStateId(template (present) OCTET4 state_id := ?) := {
+	avp := {
+		avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Origin_State_Id),
+		avp_data := {
+			avp_BASE_NONE_Origin_State_Id := state_id
+		}
+	}
+}
 
 template (value) GenericAVP ts_AVP_HostIpAddr(template (value) OCTET4 ipv4_addr) := {
 	avp := {
@@ -391,6 +399,14 @@
 		}
 	}
 }
+template (present) GenericAVP tr_AVP_ResultCode(DIAMETER_Resultcode res_code) := {
+	avp := {
+		avp_header := tr_DIA_Hdr(c_AVP_Code_BASE_NONE_Result_Code),
+		avp_data := {
+			avp_BASE_NONE_Result_Code := int2oct(enum2int(res_code), 4)
+		}
+	}
+}
 
 template (value) GenericAVP ts_AVP_AuthSessionState(template (value) BASE_NONE_Auth_Session_State ass := NO_STATE_MAINTAINED) := {
 	avp := {
@@ -963,4 +979,74 @@
 		// origin
 	});
 
+/* RFC 6733, section 5.5.1 "Device-Watchdog-Request" */
+template (value) PDU_DIAMETER
+ts_DIA_DWR(template (value) OCTET4 state_id := '00000000'O,
+	   template (value) charstring orig_host := "ttcn3.localdomain",
+	   template (value) charstring orig_realm := "localdomain",
+	   template (value) UINT32 hbh_id := '00000000'O,
+	   template (value) UINT32 ete_id := '00000000'O) :=
+	ts_DIAMETER(flags := '10000000'B,
+		    cmd_code := Device_Watchdog,
+		    app_id := '00000000'O,
+		    hbh_id := hbh_id,
+		    ete_id := ete_id,
+		    avps := {
+			ts_AVP_OriginHost(orig_host),
+			ts_AVP_OriginRealm(orig_realm),
+			ts_AVP_OriginStateId(state_id)
+	});
+template (present) PDU_DIAMETER
+tr_DIA_DWR(template (present) OCTET4 state_id := ?,
+	   template (present) charstring orig_host := ?,
+	   template (present) charstring orig_realm := ?,
+	   template (present) UINT32 hbh_id := ?,
+	   template (present) UINT32 ete_id := ?) :=
+	tr_DIAMETER(flags := '1???????'B,
+		    cmd_code := Device_Watchdog,
+		    app_id := '00000000'O,
+		    hbh_id := hbh_id,
+		    ete_id := ete_id,
+		    avps := superset(
+			tr_AVP_OriginHost(orig_host),
+			tr_AVP_OriginRealm(orig_realm),
+			tr_AVP_OriginStateId(state_id)
+	));
+
+/* RFC 6733, section 5.5.2 "Device-Watchdog-Answer" */
+template (value) PDU_DIAMETER
+ts_DIA_DWA(template (value) OCTET4 state_id := '00000000'O,
+	   template (value) charstring orig_host := "ttcn3.localdomain",
+	   template (value) charstring orig_realm := "localdomain",
+	   template (value) UINT32 hbh_id := '00000000'O,
+	   template (value) UINT32 ete_id := '00000000'O) :=
+	ts_DIAMETER(flags := '00000000'B,
+		    cmd_code := Device_Watchdog,
+		    app_id := '00000000'O,
+		    hbh_id := hbh_id,
+		    ete_id := ete_id,
+		    avps := {
+			ts_AVP_ResultCode(DIAMETER_SUCCESS),
+			ts_AVP_OriginHost(orig_host),
+			ts_AVP_OriginRealm(orig_realm),
+			ts_AVP_OriginStateId(state_id)
+	});
+template (present) PDU_DIAMETER
+tr_DIA_DWA(template (present) OCTET4 state_id := ?,
+	   template (present) charstring orig_host := ?,
+	   template (present) charstring orig_realm := ?,
+	   template (present) UINT32 hbh_id := ?,
+	   template (present) UINT32 ete_id := ?) :=
+	tr_DIAMETER(flags := '0???????'B,
+		    cmd_code := Device_Watchdog,
+		    app_id := '00000000'O,
+		    hbh_id := hbh_id,
+		    ete_id := ete_id,
+		    avps := superset(
+			tr_AVP_ResultCode(DIAMETER_SUCCESS),
+			tr_AVP_OriginHost(orig_host),
+			tr_AVP_OriginRealm(orig_realm),
+			tr_AVP_OriginStateId(state_id)
+	));
+
 }