diff options
| author | Michael Brown | 2007-01-18 04:28:55 +0100 |
|---|---|---|
| committer | Michael Brown | 2007-01-18 04:28:55 +0100 |
| commit | 5a807994d84bd494bae38f48d6b71d3cdae22aff (patch) | |
| tree | 57f2e2bc497bd763f5ccedb99bd00b669260c7a4 | |
| parent | Ensure that struct sockaddr is long enough... (diff) | |
| download | ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.gz ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.tar.xz ipxe-5a807994d84bd494bae38f48d6b71d3cdae22aff.zip | |
Add utility function to parse port from URI
| -rw-r--r-- | src/core/uri.c | 11 | ||||
| -rw-r--r-- | src/include/gpxe/uri.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/core/uri.c b/src/core/uri.c index 423671706..cb1ac3bcb 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 ); +} diff --git a/src/include/gpxe/uri.h b/src/include/gpxe/uri.h index 24f92c67d..b8c7e098a 100644 --- a/src/include/gpxe/uri.h +++ b/src/include/gpxe/uri.h @@ -112,5 +112,6 @@ static inline void free_uri ( struct uri *uri ) { } extern struct uri * parse_uri ( const char *uri_string ); +unsigned int uri_port ( struct uri *uri, unsigned int default_port ); #endif /* _GPXE_URI_H */ |
