summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2005-04-29 15:17:25 +0200
committerMichael Brown2005-04-29 15:17:25 +0200
commite4131ebb8469222f9bf864cba516e78b2530ffb3 (patch)
treea0e1d153137da9b70d6e8a68cb77a7787da400aa /src/core
parentFirst version (diff)
downloadipxe-e4131ebb8469222f9bf864cba516e78b2530ffb3.tar.gz
ipxe-e4131ebb8469222f9bf864cba516e78b2530ffb3.tar.xz
ipxe-e4131ebb8469222f9bf864cba516e78b2530ffb3.zip
First version
Diffstat (limited to 'src/core')
-rw-r--r--src/core/proto.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/proto.c b/src/core/proto.c
new file mode 100644
index 000000000..66956971b
--- /dev/null
+++ b/src/core/proto.c
@@ -0,0 +1,25 @@
+#include "stddef.h"
+#include "string.h"
+#include "proto.h"
+
+static struct protocol protocols[0] __protocol_start;
+static struct protocol default_protocols[0] __default_protocol_start;
+static struct protocol protocols_end[0] __protocol_end;
+
+/*
+ * Identify protocol given a name. name may be NULL, in which case
+ * the first default protocol (if any) will be used.
+ *
+ */
+struct protocol * identify_protocol ( const char *name ) {
+ struct protocol *proto = default_protocols;
+
+ if ( name ) {
+ for ( proto = protocols ; proto < protocols_end ; proto++ ) {
+ if ( strcmp ( name, proto->name ) == 0 )
+ break;
+ }
+ }
+
+ return proto < protocols_end ? proto : NULL;
+}