aboutsummaryrefslogtreecommitdiff
path: root/plugin-api.h
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-09-07 17:28:10 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-09-08 21:40:01 +0200
commitb418bfe22cb7ba9091f065d8697ef8bcfcead203 (patch)
tree20541f58b957cbb7ae25e4baef81cbbce0b92f68 /plugin-api.h
downloadponymap-b418bfe22cb7ba9091f065d8697ef8bcfcead203.tar.gz
ponymap-b418bfe22cb7ba9091f065d8697ef8bcfcead203.tar.xz
ponymap-b418bfe22cb7ba9091f065d8697ef8bcfcead203.zip
Initial commit
Nothing's working yet, only some supporting code has been put in place.
Diffstat (limited to 'plugin-api.h')
-rw-r--r--plugin-api.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/plugin-api.h b/plugin-api.h
new file mode 100644
index 0000000..6324821
--- /dev/null
+++ b/plugin-api.h
@@ -0,0 +1,81 @@
+/*
+ * plugin-api.h: plugin API for ponymap
+ *
+ * Copyright (c) 2014, Přemysl Janouch <p.janouch@gmail.com>
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+// This API is meant to be as simplistic as is realistically possible.
+
+/// The version of the API, and by extension, of all the following structs
+#define API_VERSION 1
+
+///< Opaque object with data relating to a service scan
+struct unit;
+
+enum
+{
+ SERVICE_SUPPORTS_TLS = (1 << 0) ///< Plain TLS can be used
+};
+
+struct service
+{
+ const char *name; ///< Name of the service
+ int flags; ///< Service flags
+
+ /// Initialize a scan, returning a handle to it
+ void *(*scan_init) (struct unit *u);
+
+ /// We have received some data from the peer
+ void (*on_data) (void *handle, struct unit *u, struct str *data);
+
+ /// Server has closed the connection
+ void (*on_eof) (void *handle, struct unit *u);
+
+ /// Network or other error has occured
+ void (*on_error) (void *handle, struct unit *u);
+
+ /// The scan has been cancelled
+ void (*on_cancelled) (void *handle, struct unit *u);
+};
+
+struct plugin_api
+{
+ /// Register the plugin for a service
+ void (*register_service) (void *ctx, struct service *info);
+
+ /// Send some data to the peer
+ ssize_t (*unit_write) (struct unit *u, const void *buf, size_t len);
+
+ /// Mark the scan as un/successful
+ void (*unit_set_success) (struct unit *u, bool success);
+
+ /// Add some information resulting from the scan
+ void (*unit_add_info) (struct unit *u, const char *result);
+
+ /// Abort the scan, close the connection
+ void (*unit_abort) (struct unit *u);
+};
+
+struct plugin_info
+{
+ /// Version of the API used by this plugin
+ int32_t api_version;
+
+ /// Let the plugin initialize itself and register any services.
+ /// The context needs to be passed to the relevant API functions.
+ bool (*initialize) (void *ctx, struct plugin_api *api);
+};