summaryrefslogtreecommitdiffstats
path: root/src/core/uri.c
diff options
context:
space:
mode:
authorMichael Brown2007-01-18 04:28:55 +0100
committerMichael Brown2007-01-18 04:28:55 +0100
commit5a807994d84bd494bae38f48d6b71d3cdae22aff (patch)
tree57f2e2bc497bd763f5ccedb99bd00b669260c7a4 /src/core/uri.c
parentEnsure that struct sockaddr is long enough... (diff)
downloadipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.gz
ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.xz
ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.zip
Add utility function to parse port from URI
Diffstat (limited to 'src/core/uri.c')
-rw-r--r--src/core/uri.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/uri.c b/src/core/uri.c
index 42367170..cb1ac3bc 100644
--- a/src/core/uri.c
+++ b/src/core/uri.c
@@ -159,3 +159,14 @@ struct uri * parse_uri ( const char *uri_string ) {
return uri;
}
+
+/**
+ * Get port from URI
+ *
+ * @v uri URI
+ * @v default_port Default port to use if none specified in URI
+ * @ret port Port
+ */
+unsigned int uri_port ( struct uri *uri, unsigned int default_port ) {
+ return ( uri->port ? strtoul ( uri->port, NULL, 0 ) : default_port );
+}