- memcpy (collector.data, mp->collector_address, sizeof (collector.data));
- collector_port = ntohs (mp->collector_port);
+ /* Collector address is the key for the exporter lookup */
+ ip4_address_decode (mp_collector_address->un.ip4, &collector);
+
+ if (use_index_0)
+ /*
+ * In this case we update the existing exporter. There is no delete
+ * for exp[0]
+ */
+ exp = &frm->exporters[0];
+ else
+ {
+ if (is_create)
+ {
+ exp = vnet_ipfix_exporter_lookup (&collector);
+ if (!exp)
+ {
+ /* Create a new exporter instead of updating an existing one */
+ if (pool_elts (frm->exporters) >= IPFIX_EXPORTERS_MAX)
+ return VNET_API_ERROR_INVALID_VALUE;
+ pool_get (frm->exporters, exp);
+ if (!exp)
+ return VNET_API_ERROR_INVALID_VALUE;
+ }
+ }
+ else
+ {
+ /* Delete the exporter */
+ exp = vnet_ipfix_exporter_lookup (&collector);
+ if (!exp)
+ return VNET_API_ERROR_NO_SUCH_ENTRY;
+
+ pool_put (frm->exporters, exp);
+ return 0;
+ }
+ }
+
+ if (mp_src_address->af == ADDRESS_IP6 ||
+ mp_collector_address->af == ADDRESS_IP6)
+ {
+ return VNET_API_ERROR_UNIMPLEMENTED;
+ }
+
+ collector_port = ntohs (mp_collector_port);