diff options
| author | Michael Brown | 2007-06-08 17:33:24 +0200 |
|---|---|---|
| committer | Michael Brown | 2007-06-08 17:33:24 +0200 |
| commit | 6f0a6c09db3b714849e3f84dabd3ad9ee9041607 (patch) | |
| tree | 67b0a5d66d2ea9a0508c36ca0a4eaaffa3045725 /src/include | |
| parent | Should call ftp_done() if constructor fails. (diff) | |
| parent | Conflicts with native asn1.c (diff) | |
| download | ipxe-6f0a6c09db3b714849e3f84dabd3ad9ee9041607.tar.gz ipxe-6f0a6c09db3b714849e3f84dabd3ad9ee9041607.tar.xz ipxe-6f0a6c09db3b714849e3f84dabd3ad9ee9041607.zip | |
Merge branch 'master' into mcb-tcp-xfer
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/gpxe/open.h | 21 | ||||
| -rw-r--r-- | src/include/gpxe/process.h | 41 | ||||
| -rw-r--r-- | src/include/gpxe/retry.h | 11 | ||||
| -rw-r--r-- | src/include/gpxe/socket.h | 51 | ||||
| -rw-r--r-- | src/include/gpxe/uri.h | 31 | ||||
| -rw-r--r-- | src/include/gpxe/vsprintf.h | 4 | ||||
| -rw-r--r-- | src/include/gpxe/xfer.h | 20 | ||||
| -rw-r--r-- | src/include/libgen.h | 3 | ||||
| -rw-r--r-- | src/include/stdio.h | 5 |
9 files changed, 135 insertions, 52 deletions
diff --git a/src/include/gpxe/open.h b/src/include/gpxe/open.h index 229d2d78c..5e368486b 100644 --- a/src/include/gpxe/open.h +++ b/src/include/gpxe/open.h @@ -26,7 +26,9 @@ enum { * * Parameter list for open() is: * - * + * int semantics; + * struct sockaddr *peer; + * struct sockaddr *local; */ LOCATION_SOCKET, }; @@ -44,9 +46,6 @@ struct uri_opener { * @v xfer Data transfer interface * @v uri URI * @ret rc Return status code - * - * This method takes ownership of the URI structure, and is - * responsible for eventually calling free_uri(). */ int ( * open ) ( struct xfer_interface *xfer, struct uri *uri ); }; @@ -56,10 +55,10 @@ struct uri_opener { /** A socket opener */ struct socket_opener { - /** Communication domain (e.g. PF_INET) */ - int domain; /** Communication semantics (e.g. SOCK_STREAM) */ - int type; + int semantics; + /** Address family (e.g. AF_INET) */ + int family; /** Open socket * * @v xfer Data transfer interface @@ -76,9 +75,11 @@ struct socket_opener { extern int xfer_open_uri ( struct xfer_interface *xfer, const char *uri_string ); -extern int xfer_open_socket ( struct xfer_interface *xfer, - int domain, int type, struct sockaddr *peer, - struct sockaddr *local ); +extern int xfer_open_named_socket ( struct xfer_interface *xfer, + int semantics, struct sockaddr *peer, + const char *name, struct sockaddr *local ); +extern int xfer_open_socket ( struct xfer_interface *xfer, int semantics, + struct sockaddr *peer, struct sockaddr *local ); extern int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args ); extern int xfer_open ( struct xfer_interface *xfer, int type, ... ); diff --git a/src/include/gpxe/process.h b/src/include/gpxe/process.h index 83ff83934..c0837fa4f 100644 --- a/src/include/gpxe/process.h +++ b/src/include/gpxe/process.h @@ -8,6 +8,7 @@ */ #include <gpxe/list.h> +#include <gpxe/refcnt.h> /** A process */ struct process { @@ -19,14 +20,46 @@ struct process { * This method should execute a single step of the process. * Returning from this method is isomorphic to yielding the * CPU to another process. - * - * If the process wishes to be executed again, it must re-add - * itself to the run queue using schedule(). */ void ( * step ) ( struct process *process ); + /** Reference counter + * + * If this interface is not part of a reference-counted + * object, this field may be NULL. + */ + struct refcnt *refcnt; }; -extern void schedule ( struct process *process ); +extern void process_add ( struct process *process ); +extern void process_del ( struct process *process ); extern void step ( void ); +/** + * Initialise process without adding to process list + * + * @v process Process + * @v step Process' step() method + */ +static inline __attribute__ (( always_inline )) void +process_init_stopped ( struct process *process, + void ( * step ) ( struct process *process ), + struct refcnt *refcnt ) { + process->step = step; + process->refcnt = refcnt; +} + +/** + * Initialise process and add to process list + * + * @v process Process + * @v step Process' step() method + */ +static inline __attribute__ (( always_inline )) void +process_init ( struct process *process, + void ( * step ) ( struct process *process ), + struct refcnt *refcnt ) { + process_init_stopped ( process, step, refcnt ); + process_add ( process ); +} + #endif /* _GPXE_PROCESS_H */ diff --git a/src/include/gpxe/retry.h b/src/include/gpxe/retry.h index 57be432e2..e0c0248b1 100644 --- a/src/include/gpxe/retry.h +++ b/src/include/gpxe/retry.h @@ -37,4 +37,15 @@ struct retry_timer { extern void start_timer ( struct retry_timer *timer ); extern void stop_timer ( struct retry_timer *timer ); +/** + * Test to see if timer is currently running + * + * @v timer Retry timer + * @ret running Non-zero if timer is running + */ +static inline __attribute__ (( always_inline )) unsigned long +timer_running ( struct retry_timer *timer ) { + return ( timer->start ); +} + #endif /* _GPXE_RETRY_H */ diff --git a/src/include/gpxe/socket.h b/src/include/gpxe/socket.h index ea602537e..d47369aac 100644 --- a/src/include/gpxe/socket.h +++ b/src/include/gpxe/socket.h @@ -8,31 +8,7 @@ */ /** - * @defgroup commdomains Communication domains - * - * @{ - */ -#define PF_INET 1 /**< IPv4 Internet protocols */ -#define PF_INET6 2 /**< IPv6 Internet protocols */ -/** @} */ - -/** - * Name communication domain - * - * @v domain Communication domain (e.g. PF_INET) - * @ret name Name of communication domain - */ -static inline __attribute__ (( always_inline )) const char * -socket_domain_name ( int domain ) { - switch ( domain ) { - case PF_INET: return "PF_INET"; - case PF_INET6: return "PF_INET6"; - default: return "PF_UNKNOWN"; - } -} - -/** - * @defgroup commtypes Communication types + * @defgroup commtypes Communication semantics * * @{ */ @@ -41,14 +17,14 @@ socket_domain_name ( int domain ) { /** @} */ /** - * Name communication type + * Name communication semantics * - * @v type Communication type (e.g. SOCK_STREAM) - * @ret name Name of communication type + * @v semantics Communication semantics (e.g. SOCK_STREAM) + * @ret name Name of communication semantics */ static inline __attribute__ (( always_inline )) const char * -socket_type_name ( int type ) { - switch ( type ) { +socket_semantics_name ( int semantics ) { + switch ( semantics ) { case SOCK_STREAM: return "SOCK_STREAM"; case SOCK_DGRAM: return "SOCK_DGRAM"; default: return "SOCK_UNKNOWN"; @@ -64,6 +40,21 @@ socket_type_name ( int type ) { #define AF_INET6 2 /**< IPv6 Internet addresses */ /** @} */ +/** + * Name address family + * + * @v family Address family (e.g. AF_INET) + * @ret name Name of address family + */ +static inline __attribute__ (( always_inline )) const char * +socket_family_name ( int family ) { + switch ( family ) { + case AF_INET: return "AF_INET"; + case AF_INET6: return "AF_INET6"; + default: return "AF_UNKNOWN"; + } +} + /** A socket address family */ typedef uint16_t sa_family_t; diff --git a/src/include/gpxe/uri.h b/src/include/gpxe/uri.h index b8c7e098a..f61623824 100644 --- a/src/include/gpxe/uri.h +++ b/src/include/gpxe/uri.h @@ -8,6 +8,7 @@ */ #include <stdlib.h> +#include <gpxe/refcnt.h> /** A Uniform Resource Identifier * @@ -37,6 +38,8 @@ * query = "what=is", fragment = "this" */ struct uri { + /** Reference count */ + struct refcnt refcnt; /** Scheme */ const char *scheme; /** Opaque part */ @@ -100,18 +103,34 @@ static inline int uri_has_relative_path ( struct uri *uri ) { } /** - * Free URI structure + * Increment URI reference count * * @v uri URI + * @ret uri URI + */ +static inline __attribute__ (( always_inline )) struct uri * +uri_get ( struct uri *uri ) { + ref_get ( &uri->refcnt ); + return uri; +} + +/** + * Decrement URI reference count * - * Frees all the dynamically-allocated storage used by the URI - * structure. + * @v uri URI */ -static inline void free_uri ( struct uri *uri ) { - free ( uri ); +static inline __attribute__ (( always_inline )) void +uri_put ( struct uri *uri ) { + ref_put ( &uri->refcnt ); } extern struct uri * parse_uri ( const char *uri_string ); -unsigned int uri_port ( struct uri *uri, unsigned int default_port ); +extern unsigned int uri_port ( struct uri *uri, unsigned int default_port ); +extern int unparse_uri ( char *buf, size_t size, struct uri *uri ); +extern struct uri * uri_dup ( struct uri *uri ); +extern char * resolve_path ( const char *base_path, + const char *relative_path ); +extern struct uri * resolve_uri ( struct uri *base_uri, + struct uri *relative_uri ); #endif /* _GPXE_URI_H */ diff --git a/src/include/gpxe/vsprintf.h b/src/include/gpxe/vsprintf.h index ac87c5a8b..9360f29b7 100644 --- a/src/include/gpxe/vsprintf.h +++ b/src/include/gpxe/vsprintf.h @@ -64,4 +64,8 @@ struct printf_context { extern size_t vcprintf ( struct printf_context *ctx, const char *fmt, va_list args ); +extern int vssnprintf ( char *buf, ssize_t ssize, const char *fmt, + va_list args ); +extern int ssnprintf ( char *buf, ssize_t ssize, const char *fmt, ... ); + #endif /* _GPXE_VSPRINTF_H */ diff --git a/src/include/gpxe/xfer.h b/src/include/gpxe/xfer.h index 71b69dc51..f946ab1c1 100644 --- a/src/include/gpxe/xfer.h +++ b/src/include/gpxe/xfer.h @@ -112,6 +112,20 @@ enum seek_whence { SEEK_CUR, }; +/** + * Describe seek basis + * + * @v whence Basis for new position + */ +static inline __attribute__ (( always_inline )) const char * +whence_text ( int whence ) { + switch ( whence ) { + case SEEK_SET: return "SET"; + case SEEK_CUR: return "CUR"; + default: return "INVALID"; + } +} + extern struct xfer_interface null_xfer; extern struct xfer_interface_operations null_xfer_ops; @@ -121,14 +135,18 @@ extern int xfer_vredirect ( struct xfer_interface *xfer, int type, extern int xfer_redirect ( struct xfer_interface *xfer, int type, ... ); extern int xfer_request ( struct xfer_interface *xfer, off_t offset, int whence, size_t len ); -extern int xfer_request_all ( struct xfer_interface *xfer ); extern int xfer_seek ( struct xfer_interface *xfer, off_t offset, int whence ); +extern int xfer_ready ( struct xfer_interface *xfer ); extern struct io_buffer * xfer_alloc_iob ( struct xfer_interface *xfer, size_t len ); extern int xfer_deliver_iob ( struct xfer_interface *xfer, struct io_buffer *iobuf ); extern int xfer_deliver_raw ( struct xfer_interface *xfer, const void *data, size_t len ); +extern int xfer_vprintf ( struct xfer_interface *xfer, + const char *format, va_list args ); +extern int xfer_printf ( struct xfer_interface *xfer, + const char *format, ... ); extern void ignore_xfer_close ( struct xfer_interface *xfer, int rc ); extern int ignore_xfer_vredirect ( struct xfer_interface *xfer, diff --git a/src/include/libgen.h b/src/include/libgen.h index 8fa552a92..56a2f760b 100644 --- a/src/include/libgen.h +++ b/src/include/libgen.h @@ -1,6 +1,7 @@ #ifndef _LIBGEN_H #define _LIBGEN_H -char * basename ( char *path ); +extern char * basename ( char *path ); +extern char * dirname ( char *path ); #endif /* _LIBGEN_H */ diff --git a/src/include/stdio.h b/src/include/stdio.h index 169cfd9e3..82077e20f 100644 --- a/src/include/stdio.h +++ b/src/include/stdio.h @@ -10,10 +10,15 @@ printf ( const char *fmt, ... ); extern int __attribute__ (( format ( printf, 3, 4 ) )) snprintf ( char *buf, size_t size, const char *fmt, ... ); +extern int __attribute__ (( format ( printf, 2, 3 ) )) +asprintf ( char **strp, const char *fmt, ... ); + extern int vprintf ( const char *fmt, va_list args ); extern int vsnprintf ( char *buf, size_t size, const char *fmt, va_list args ); +extern int vasprintf ( char **strp, const char *fmt, va_list args ); + /** * Write a formatted string to a buffer * |
