diff --git a/compiler2/ttcn3/Statement.cc b/compiler2/ttcn3/Statement.cc
index 37c8ef4f8a127e06af2be71bd6059f6365b5a2ec..c7692a69f19b23c431e0083e2ca7492982a05ef9 100644
--- a/compiler2/ttcn3/Statement.cc
+++ b/compiler2/ttcn3/Statement.cc
@@ -5791,6 +5791,7 @@ error:
             case 1:
             case 2:
             case 3:
+            case 4:
               break;
             default:
               error = true;
@@ -5799,7 +5800,7 @@ error:
           error = true;
         }
         if (error) {
-          setstate_op.val->error("The value of the first parameter must be 0, 1, 2 or 3.");
+          setstate_op.val->error("The value of the first parameter must be 0, 1, 2, 3 or 4.");
         }
       }
     }
diff --git a/compiler2/ttcn3/port.c b/compiler2/ttcn3/port.c
index 1384ce4f8ce5e68fbf3b63ac5e640f0307b3c2ee..624aea20367ad59d31be73a3d5b1b22dd83391fa 100644
--- a/compiler2/ttcn3/port.c
+++ b/compiler2/ttcn3/port.c
@@ -212,7 +212,7 @@ static char *generate_send_mapping(char *src, const port_def *pdef,
     }
     if (!pdef->legacy && pdef->port_type == USER) {
       src = mputprintf(src,
-        "} else if (port_state == FRAGMENTED) {\n"
+        "} else if (port_state == FRAGMENTED || port_state == DISCARDED) {\n"
         "return;\n"
         "} else if (port_state == UNSET) {\n"
         "TTCN_error(\"The state of the port %%s remained unset after the mapping function %s finished.\", port_name);\n"
@@ -418,7 +418,7 @@ static char *generate_incoming_mapping(char *src, const port_def *pdef,
           "}");
         if (pdef->port_type == USER && !pdef->legacy) {
           src = mputprintf(src,
-            " else if (port_state == FRAGMENTED) {\n"
+            " else if (port_state == FRAGMENTED || port_state == DISCARDED) {\n"
             "delete mapped_par;\n"
             "return;\n"
             "}"
diff --git a/core/LoggerPluginManager.cc b/core/LoggerPluginManager.cc
index e3a2a6da1bcbb5af3a26206b8e4952e7b1d60106..f0c499af5cde99efec1a37bed0ecb2855c5fa20c 100644
--- a/core/LoggerPluginManager.cc
+++ b/core/LoggerPluginManager.cc
@@ -1534,6 +1534,9 @@ void LoggerPluginManager::log_setstate(const char *port_name, translation_port_s
     case PARTIALLY_TRANSLATED:
       setstate.state() = "partially translated";
       break;
+    case DISCARDED:
+      setstate.state() = "discarded";
+      break;
     default:
       TTCN_Logger::fatal_error("LoggerPluginManager::log_setstate(): unexpected port state");
   }
diff --git a/core/Runtime.cc b/core/Runtime.cc
index 71a31ee2d756c4508cf67c6d654417a94b32d828..fd750ca2ca280ffe98e6570cf128c16acfae8c7d 100644
--- a/core/Runtime.cc
+++ b/core/Runtime.cc
@@ -126,9 +126,9 @@ void TTCN_Runtime::set_port_state(const INTEGER& state, const CHARSTRING& info,
   if (translation_count > 0) {
     if (p != NULL) {
       int lowed_end = by_system ? -1 : 0;
-      if (state < lowed_end || state > 3) {
+      if (state < lowed_end || state > 4) {
         translation_count--;
-        TTCN_error("The value of the first parameter in the setstate operation must be 0, 1, 2 or 3.");
+        TTCN_error("The value of the first parameter in the setstate operation must be 0, 1, 2, 3 or 4.");
       }
       p->change_port_state((translation_port_state)((int)state));
       TTCN_Logger::log_setstate(p->get_name(), (translation_port_state)((int)state), info);
diff --git a/core/Types.h b/core/Types.h
index 1ffd1dbf98460a6818c4ef8cbc8bdc64d49c969b..e8702fde0a0fa22a3545fdfd8066476dd83f1ba2 100644
--- a/core/Types.h
+++ b/core/Types.h
@@ -135,7 +135,8 @@ enum translation_port_state {
   TRANSLATED = 0,
   NOT_TRANSLATED = 1,
   FRAGMENTED = 2,
-  PARTIALLY_TRANSLATED = 3
+  PARTIALLY_TRANSLATED = 3,
+  DISCARDED = 4
 };
 
 #endif
diff --git a/regression_test/portTranslation/Makefile b/regression_test/portTranslation/Makefile
index 38e825e13334cc30932a3504f4c2ba6c2d81c4f6..a7bd9ace1ea1afa91a0548801dee90bc8df46da5 100644
--- a/regression_test/portTranslation/Makefile
+++ b/regression_test/portTranslation/Makefile
@@ -64,7 +64,7 @@ GENERATED_SOURCES += $(GENERATED_SOURCES2)
 endif
 # C/C++ Source & header files of Test Ports, external functions and
 # other modules:
-USER_SOURCES = PT2.cc P1.cc P2.cc P3.cc VP1.cc NVP1.cc P1Internal.cc P2Internal.cc P3Internal.cc VP1Internal.cc
+USER_SOURCES = PT2.cc PT3.cc P1.cc P2.cc P3.cc P4.cc VP1.cc NVP1.cc P1Internal.cc P2Internal.cc P3Internal.cc VP1Internal.cc
 USER_HEADERS = $(USER_SOURCES:.cc=.hh)
 
 # Object files of this project that are needed for the executable test suite:
diff --git a/regression_test/portTranslation/P4.cc b/regression_test/portTranslation/P4.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0426a50ed7226032b50862d743ca4bb986831c5
--- /dev/null
+++ b/regression_test/portTranslation/P4.cc
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Botond, Baranyi
+ *
+ ******************************************************************************/
+
+#include "P4.hh"
+#include "PortTranslation.hh"
+
+namespace PortTranslation {
+
+P4_PROVIDER::P4_PROVIDER(const char *par_port_name)
+	: PORT(par_port_name)
+{
+
+}
+
+P4_PROVIDER::~P4_PROVIDER()
+{
+
+}
+
+void P4_PROVIDER::set_parameter(const char * /*parameter_name*/,
+	const char * /*parameter_value*/)
+{
+
+}
+
+/*void P4_PROVIDER::Handle_Fd_Event(int fd, boolean is_readable,
+	boolean is_writable, boolean is_error) {}*/
+
+void P4_PROVIDER::Handle_Fd_Event_Error(int /*fd*/)
+{
+
+}
+
+void P4_PROVIDER::Handle_Fd_Event_Writable(int /*fd*/)
+{
+
+}
+
+void P4_PROVIDER::Handle_Fd_Event_Readable(int /*fd*/)
+{
+
+}
+
+/*void P4_PROVIDER::Handle_Timeout(double time_since_last_call) {}*/
+
+void P4_PROVIDER::user_map(const char * /*system_port*/)
+{
+
+}
+
+void P4_PROVIDER::user_unmap(const char * /*system_port*/)
+{
+
+}
+
+void P4_PROVIDER::user_start()
+{
+
+}
+
+void P4_PROVIDER::user_stop()
+{
+
+}
+
+void P4_PROVIDER::outgoing_send(const INTEGER& send_par)
+{
+  // redirect the message back to the port, to test port translation for 'receive' operations
+  // (these messages should be discarded by the translation function)
+  incoming_message(send_par);
+}
+
+void P4_PROVIDER::outgoing_send(const CHARSTRING& send_par)
+{
+  // redirect the message back to the port, to test port translation for 'receive' operations
+  // (these messages should be correctly translated and received)
+  incoming_message(send_par);
+}
+
+void P4_PROVIDER::outgoing_send(const BOOLEAN& send_par)
+{
+  // this should've been discarded by the translation function
+  TTCN_Runtime::setverdict(FAIL, "Sending a boolean value.");
+}
+
+} /* end of namespace */
+
diff --git a/regression_test/portTranslation/P4.hh b/regression_test/portTranslation/P4.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9db63ef9a43bb476d03c6d6110e30c8bc57f6122
--- /dev/null
+++ b/regression_test/portTranslation/P4.hh
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Botond, Baranyi
+ *
+ ******************************************************************************/
+
+#ifndef P4_HH
+#define P4_HH
+
+#include <TTCN3.hh>
+
+// Note: Header file PortTranslation.hh must not be included into this file!
+// (because it includes this file)
+// Please add the declarations of message types manually.
+
+namespace PortTranslation {
+
+class P4_PROVIDER : public PORT {
+public:
+	P4_PROVIDER(const char *par_port_name);
+	~P4_PROVIDER();
+
+	void set_parameter(const char *parameter_name,
+		const char *parameter_value);
+
+private:
+	/* void Handle_Fd_Event(int fd, boolean is_readable,
+		boolean is_writable, boolean is_error); */
+	void Handle_Fd_Event_Error(int fd);
+	void Handle_Fd_Event_Writable(int fd);
+	void Handle_Fd_Event_Readable(int fd);
+	/* void Handle_Timeout(double time_since_last_call); */
+protected:
+	void user_map(const char *system_port);
+	void user_unmap(const char *system_port);
+
+	void user_start();
+	void user_stop();
+
+	void outgoing_send(const INTEGER& send_par);
+	void outgoing_send(const CHARSTRING& send_par);
+	void outgoing_send(const BOOLEAN& send_par);
+	virtual void incoming_message(const INTEGER& incoming_par) = 0;
+	virtual void incoming_message(const CHARSTRING& incoming_par) = 0;
+};
+
+} /* end of namespace */
+
+#endif
diff --git a/regression_test/portTranslation/PT3.cc b/regression_test/portTranslation/PT3.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8e30b3b2d85c3cfcb336bd650bbe48bb9f0c0a5b
--- /dev/null
+++ b/regression_test/portTranslation/PT3.cc
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Botond, Baranyi
+ *
+ ******************************************************************************/
+
+#include "PT3.hh"
+
+namespace PortTranslation {
+
+PT3::PT3(const char *par_port_name)
+	: PT3_BASE(par_port_name)
+{
+
+}
+
+PT3::~PT3()
+{
+
+}
+
+void PT3::set_parameter(const char * /*parameter_name*/,
+	const char * /*parameter_value*/)
+{
+
+}
+
+/*void PT3::Handle_Fd_Event(int fd, boolean is_readable,
+	boolean is_writable, boolean is_error) {}*/
+
+void PT3::Handle_Fd_Event_Error(int /*fd*/)
+{
+
+}
+
+void PT3::Handle_Fd_Event_Writable(int /*fd*/)
+{
+
+}
+
+void PT3::Handle_Fd_Event_Readable(int /*fd*/)
+{
+
+}
+
+/*void PT3::Handle_Timeout(double time_since_last_call) {}*/
+
+void PT3::user_map(const char * /*system_port*/)
+{
+
+}
+
+void PT3::user_unmap(const char * /*system_port*/)
+{
+
+}
+
+void PT3::user_start()
+{
+
+}
+
+void PT3::user_stop()
+{
+
+}
+
+void PT3::outgoing_send(const INTEGER& /*send_par*/)
+{
+
+}
+
+void PT3::outgoing_send(const CHARSTRING& /*send_par*/)
+{
+
+}
+
+void PT3::outgoing_send(const BOOLEAN& /*send_par*/)
+{
+
+}
+
+} /* end of namespace */
+
diff --git a/regression_test/portTranslation/PT3.hh b/regression_test/portTranslation/PT3.hh
new file mode 100644
index 0000000000000000000000000000000000000000..f3ea988a8d4875f9b9c9d4443814c27f0555aec0
--- /dev/null
+++ b/regression_test/portTranslation/PT3.hh
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * Copyright (c) 2000-2017 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Botond, Baranyi
+ *
+ ******************************************************************************/
+
+#ifndef PT3_HH
+#define PT3_HH
+
+#include "PortTranslation.hh"
+
+namespace PortTranslation {
+
+class PT3 : public PT3_BASE {
+public:
+	PT3(const char *par_port_name = NULL);
+	~PT3();
+
+	void set_parameter(const char *parameter_name,
+		const char *parameter_value);
+
+private:
+	/* void Handle_Fd_Event(int fd, boolean is_readable,
+		boolean is_writable, boolean is_error); */
+	void Handle_Fd_Event_Error(int fd);
+	void Handle_Fd_Event_Writable(int fd);
+	void Handle_Fd_Event_Readable(int fd);
+	/* void Handle_Timeout(double time_since_last_call); */
+protected:
+	void user_map(const char *system_port);
+	void user_unmap(const char *system_port);
+
+	void user_start();
+	void user_stop();
+
+	void outgoing_send(const INTEGER& send_par);
+	void outgoing_send(const CHARSTRING& send_par);
+	void outgoing_send(const BOOLEAN& send_par);
+};
+
+} /* end of namespace */
+
+#endif
diff --git a/regression_test/portTranslation/PortTranslation.ttcn b/regression_test/portTranslation/PortTranslation.ttcn
index 314cf21914d56dbb215a9d21683caf4bb96487b4..7cf7c3e3962632186538a348e47675aa0b19b326 100644
--- a/regression_test/portTranslation/PortTranslation.ttcn
+++ b/regression_test/portTranslation/PortTranslation.ttcn
@@ -201,6 +201,25 @@ module PortTranslation {
 	} with {
 		extension "prototype(fast)";
 	}
+	
+	function int_to_float_discard(in integer i, out float j) {
+		port.setstate(4); // discarded
+	} with {
+		extension "prototype(fast)";
+	}
+	
+	function char_to_hex3(in charstring i, out hexstring j) {
+	  j := oct2hex(char2oct(i));
+	  port.setstate(0); // translated
+	} with {
+		extension "prototype(fast)";
+	}
+	
+	function bool_to_bool_discard(in boolean i, out boolean j) {
+		port.setstate(4); // discarded
+	} with {
+		extension "prototype(fast)";
+	}
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -235,6 +254,13 @@ module PortTranslation {
 		out bitstring, hexstring, integer
 		inout octetstring
 	}
+	
+	type port P4 message {
+	  inout integer, charstring
+	  out boolean
+	} with {
+	  extension "provider"
+	}
 
 	type port PT2 message map to P1, P2 {
 		in charstring from charstring with char_to_char()
@@ -250,10 +276,18 @@ module PortTranslation {
 		var hexstring buffer := ''H;
 		var bitstring bit_buffer := ''B;
 	}
+	
+	type port PT3 message map to P4 {
+	  in hexstring from charstring with char_to_hex3()
+	  in float from integer with int_to_float_discard()
+	  out integer, charstring
+	  out boolean to boolean with bool_to_bool_discard()
+	}
 
 
 	type component MyComp {
 		port PT2 p;
+		port PT3 p3;
 
 		// Extra port types to check if multiple map/unmaps does not make things go bad
 		port PT2 p11;
@@ -265,6 +299,7 @@ module PortTranslation {
 		port P1 p1
 		port P2 p2
 		port P3 p3
+		port P4 p4
 
 		// Extra port types to check if multiple map/unmaps does not make things go bad
 		port P1 p11
@@ -693,6 +728,16 @@ module PortTranslation {
 		}
 		t.stop;
 	}
+	
+	// This tests the 'discard' option in the 'setstate' operation when sending
+	testcase tc_send_discarded() runs on MyComp system System {
+	  map(self:p3, system:p4);
+	  
+	  p3.send(true);
+		// a boolean (true) is sent on the main port, but the translation function discards it,
+		// so nothing is sent to the provider port (this is tested in the provider port implementation).
+		setverdict(pass);
+  }
 
 	testcase tc_receive_fragmented() runs on MyComp system System {
 		map(self:p, system:p1);
@@ -741,6 +786,38 @@ module PortTranslation {
 		}
 		t.stop;
 	}
+	
+	// This tests the 'discard' option in the 'setstate' operation when receiving
+	testcase tc_receive_discarded() runs on MyComp system System {
+	  map(self:p3, system:p4);
+	  
+	  p3.send(123);
+		timer t := 0.5;
+		t.start;
+		// an integer (123) is received on the provider port, but the translation function discards it,
+		// so it does not reach the main port
+		alt {
+			[] p3.receive(float: ?) { setverdict(fail, "Test #1 failed. Received float value."); }
+			[] p3.receive(hexstring: ?) { setverdict(fail, "Test #1 failed. Received hexstring value."); }
+			[] t.timeout { setverdict(pass); }
+		}
+		t.stop;
+		
+		p3.send(-10);
+		p3.send("abc");
+		var hexstring bad;
+		t.start;
+		// an integer (-10) and a charstring ("abc") are received on the provider port,
+		// the translation functions discard the integer and convert the charstring into a hexstring,
+		// so only the hexstring is received on the main port
+		alt {
+		  [] p3.receive(hexstring: '616263'H) { setverdict(pass); }
+		  [] p3.receive(hexstring: ?) -> value bad { setverdict(fail, "Test #2 failed. Received invalid hexstring: ", bad); }
+		  [] p3.receive(float: ?) { setverdict(fail, "Test #2 failed. Received float value."); }
+		  [] t.timeout { setverdict(fail, "Test #2 timed out."); }
+		}
+		t.stop;
+	}
 
 	control {
 		execute(tc_send())
@@ -753,9 +830,13 @@ module PortTranslation {
 
 		execute(tc_send_partially_translated());
 		execute(tc_send_fragmented());
+		
+		execute(tc_send_discarded());
 
 		execute(tc_receive_partially_translated());
 		execute(tc_receive_fragmented());
+		
+		execute(tc_receive_discarded());
 	}
 
 }
diff --git a/regression_test/portTranslation/Setstate_neg.ttcn b/regression_test/portTranslation/Setstate_neg.ttcn
index 64130130e809258442871d23ce75603e5c0deae2..402b79ffd99fb71e15955a5835dc42dcb7fb592c 100644
--- a/regression_test/portTranslation/Setstate_neg.ttcn
+++ b/regression_test/portTranslation/Setstate_neg.ttcn
@@ -22,7 +22,7 @@ module Setstate_neg {
 	}
 
 	function int_to_char_bad2(in integer i, out charstring j) {
-		if (i == 4) {
+		if (i == 5) {
 			port.setstate(i);
 		} else {
 			port.setstate(1); // Not translated
@@ -32,7 +32,7 @@ module Setstate_neg {
 	}
 
 	function int_to_char_bad3(in integer i, out charstring j) {
-		if (i != 5) {
+		if (i != 6) {
 			port.setstate(1); // Not translated
 		}
 		// otherwise the state will remain unset which will cause an error.
@@ -75,7 +75,7 @@ module Setstate_neg {
 			p.send(-1);
 			setverdict(fail);
 		} @catch(e) {
-			if (match(e, "Dynamic test case error: The value of the first parameter in the setstate operation must be 0, 1, 2 or 3.")) {
+			if (match(e, "Dynamic test case error: The value of the first parameter in the setstate operation must be 0, 1, 2, 3 or 4.")) {
 				setverdict(pass);
 			} else {
 				setverdict(fail);
@@ -83,10 +83,10 @@ module Setstate_neg {
 		}
 
 		@try {
-			p.send(4);
+			p.send(5);
 			setverdict(fail);
 		} @catch(e) {
-			if (match(e, "Dynamic test case error: The value of the first parameter in the setstate operation must be 0, 1, 2 or 3.")) {
+			if (match(e, "Dynamic test case error: The value of the first parameter in the setstate operation must be 0, 1, 2, 3 or 4.")) {
 				setverdict(pass);
 			} else {
 				setverdict(fail);
@@ -94,7 +94,7 @@ module Setstate_neg {
 		}
 
 		@try {
-			p.send(5);
+			p.send(6);
 			setverdict(fail);
 		} @catch(e) {
 			if (match(e, "Dynamic test case error: The state of the port p remained unset after the mapping function @Setstate_neg.int_to_char_bad3 finished.")) {
@@ -116,10 +116,10 @@ module Setstate_neg {
 		}
 
 		// Will be successful
-		p.send(6);
+		p.send(7);
 	}
 
 	control {
 		execute(tc_setstate_neg_test());
 	}
-}
\ No newline at end of file
+}
diff --git a/usrguide/referenceguide.doc b/usrguide/referenceguide.doc
index 2d8a46bcf13a259b6715ef1590162701bbfae9c9..6453ceeca1db3670bcc26783d85bfa10dbe03f43 100644
Binary files a/usrguide/referenceguide.doc and b/usrguide/referenceguide.doc differ