Index: openbsc/include/openbsc/mgcp.h
===================================================================
--- openbsc/include/openbsc/mgcp.h (revision 154b9553f758b5a1764097a7cd225d75976c5799)
+++ openbsc/include/openbsc/mgcp.h (revision fe86d3c9f8a229a788a863d1855c9e3d616b04ea)
@@ -66,5 +66,16 @@
 #define MGCP_ENDP_MDCX 3
 
+/*
+ * what to do with the msg?
+ *	- continue as usual?
+ *	- reject and send a failure code?
+ *	- defer? do not send anything
+ */
+#define MGCP_POLICY_CONT	4
+#define MGCP_POLICY_REJECT	5
+#define MGCP_POLICY_DEFER	6
+
 typedef int (*mgcp_change)(struct mgcp_config *cfg, int endpoint, int state, int local_rtp);
+typedef int (*mgcp_policy)(struct mgcp_config *cfg, int endpoint, int state, const char *transactio_id);
 
 struct mgcp_config {
@@ -86,4 +97,6 @@
 
 	mgcp_change change_cb;
+	mgcp_policy policy_cb;
+	void *data;
 
 	struct mgcp_endpoint *endpoints;
Index: openbsc/src/mgcp/mgcp_protocol.c
===================================================================
--- openbsc/src/mgcp/mgcp_protocol.c (revision a820c5f89d0ea3a7aefd1621d9bf1c9c5a25e8eb)
+++ openbsc/src/mgcp/mgcp_protocol.c (revision fe86d3c9f8a229a788a863d1855c9e3d616b04ea)
@@ -456,4 +456,23 @@
 		goto error2;
 
+	/* policy CB */
+	if (cfg->policy_cb) {
+		switch (cfg->policy_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_CRCX, trans_id)) {
+		case MGCP_POLICY_REJECT:
+			LOGP(DMGCP, LOGL_NOTICE, "CRCX rejected by policy on 0x%x\n",
+			     ENDPOINT_NUMBER(endp));
+			mgcp_free_endp(endp);
+			return create_response(500, "CRCX", trans_id);
+			break;
+		case MGCP_POLICY_DEFER:
+			/* stop processing */
+			return NULL;
+			break;
+		case MGCP_POLICY_CONT:
+			/* just continue */
+			break;
+		}
+	}
+
 	LOGP(DMGCP, LOGL_NOTICE, "Creating endpoint on: 0x%x CI: %u port: %u\n",
 		ENDPOINT_NUMBER(endp), endp->ci, endp->rtp_port);
@@ -549,4 +568,22 @@
 	MSG_TOKENIZE_END
 
+	/* policy CB */
+	if (cfg->policy_cb) {
+		switch (cfg->policy_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_MDCX, trans_id)) {
+		case MGCP_POLICY_REJECT:
+			LOGP(DMGCP, LOGL_NOTICE, "MDCX rejected by policy on 0x%x\n",
+			     ENDPOINT_NUMBER(endp));
+			return create_response(500, "MDCX", trans_id);
+			break;
+		case MGCP_POLICY_DEFER:
+			/* stop processing */
+			return NULL;
+			break;
+		case MGCP_POLICY_CONT:
+			/* just continue */
+			break;
+		}
+	}
+
 	/* modify */
 	LOGP(DMGCP, LOGL_NOTICE, "Modified endpoint on: 0x%x Server: %s:%u\n",
@@ -603,4 +640,22 @@
 	MSG_TOKENIZE_END
 
+	/* policy CB */
+	if (cfg->policy_cb) {
+		switch (cfg->policy_cb(cfg, ENDPOINT_NUMBER(endp), MGCP_ENDP_DLCX, trans_id)) {
+		case MGCP_POLICY_REJECT:
+			LOGP(DMGCP, LOGL_NOTICE, "DLCX rejected by policy on 0x%x\n",
+			     ENDPOINT_NUMBER(endp));
+			return create_response(500, "DLCX", trans_id);
+			break;
+		case MGCP_POLICY_DEFER:
+			/* stop processing */
+			return NULL;
+			break;
+		case MGCP_POLICY_CONT:
+			/* just continue */
+			break;
+		}
+	}
+
 	/* free the connection */
 	mgcp_free_endp(endp);
