Index: user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_http.h =================================================================== --- user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_http.h (revision 246326) +++ user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_http.h (revision 246327) @@ -1,93 +1,93 @@ /*- * Copyright (c) 2007 Alexey Tarasov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef PXE_HTTP_INCLUDED #define PXE_HTTP_INCLUDED /* * http downloading functions. */ #include #include #ifdef PXE_HTTPFS_CACHING #include "pxe_buffer.h" #endif /* default buffer size for generating/getting http header */ #define PXE_MAX_HTTP_HDRLEN 1024 /* testing function, outputs received data to screen */ int pxe_fetch(char *server, char *filename, off_t from, size_t size); typedef struct pxe_http_handle { char *filename; /* filename including path on server */ char *servername; /* server name */ int socket; /* opened socket, or -1 */ char *buf; /* buffer for creating requests */ uint16_t bufsize; /* size of buffer */ PXE_IPADDR addr; /* web server ip */ off_t offset; /* current offset in bytes from * beginning of file */ #ifdef PXE_HTTPFS_CACHING -/* off_t cache_start; /* cached block, to reduce http requests */ + off_t cache_start; /* cached block, to reduce http requests */ uint16_t cache_size; /* size of cached block */ #endif size_t size; /* file size if known */ } PXE_HTTP_HANDLE; /* gets requested data from server */ int pxe_get(PXE_HTTP_HANDLE *hh, size_t size, void *buffer); /* gets requested data from server, closing connection after */ int pxe_get_close(PXE_HTTP_HANDLE *hh, size_t size, void *buffer); /* checks if file exists and fills filesize if known */ int pxe_exists(PXE_HTTP_HANDLE *hh); #define PXE_HTTP_SIZE_UNKNOWN -1 typedef struct pxe_http_parse_data { uint16_t code; /* response code */ size_t size; /* size of data if known */ } PXE_HTTP_PARSE_DATA; #ifdef PXE_HTTPFS_CACHING /* used in waiting function */ typedef struct pxe_http_wait_data { PXE_BUFFER *buf; /* buffer, waiting to fill */ int socket; /* socket, which buffer is above */ uint16_t wait_size; /* how much must be filled */ uint16_t start_size; /* how much were in buffer before waiting */ } PXE_HTTP_WAIT_DATA; #endif #endif Index: user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_sock.h =================================================================== --- user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_sock.h (revision 246326) +++ user/sbruno/head_177038/sys/boot/i386/pxe_http/pxe_sock.h (revision 246327) @@ -1,142 +1,142 @@ /*- * Copyright (c) 2007 Alexey Tarasov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef PXE_SOCK_H_INCLUDED #define PXE_SOCK_H_INCLUDED /* * Implements simple sockets API */ #include #include #include "pxe_buffer.h" #include "pxe_filter.h" #include "pxe_ip.h" /* default count of sockets used at the same time */ #define PXE_DEFAULT_SOCKETS 4 /* default count of waiting queue */ #define PXE_DEFAULT_WAITCOUNT 3 /* socket timeout when receiving data, in milliseconds */ #define PXE_SOCKET_TIMEOUT 30000 /* timeout, after that force connection checking, in milliseconds */ #define PXE_SOCKET_CHECK_TIMEOUT 100 /* define to add extra socket validating at every function */ #define PXE_SOCKET_ACCURATE /* socket states */ /* socket unused and free for allocating */ #define PXE_SOCKET_FREE 0x0 /* socket structure used */ #define PXE_SOCKET_USED 0x1 /* socket binded (set local ip/local port). TODO: check if need */ #define PXE_SOCKET_BINDED 0x2 /* socket connected (set remote ip/remote port). TODO: check if need */ #define PXE_SOCKET_CONNECTED 0x3 /* connection established. TODO: check if need */ #define PXE_SOCKET_ESTABLISHED 0x4 /* socket */ typedef struct pxe_socket { PXE_BUFFER send_buffer; /* sending buffer */ PXE_BUFFER recv_buffer; /* receiving buffer */ /* transmit and status counters*/ uint32_t sent; /* bytes sent to socket */ uint32_t recv; /* bytes received from socket */ uint8_t state; /* current state */ uint8_t waiting; /* number of connections waiting * to be accepted */ /* for resending usage */ uint32_t last_time_sent; uint32_t last_time_recv; PXE_FILTER_ENTRY *filter; /* filter, that feeds data to socket */ } PXE_SOCKET; /* inits this module */ void pxe_sock_init(); /* allocates pxe_socket structure */ /* int pxe_socket_alloc(); */ /* frees socket structure */ -/* int pxe_socket_free(int socket); (/ +/* int pxe_socket_free(int socket); */ /* shows socket usage statistics */ void pxe_sock_stats(); /* returns current socket state */ int pxe_sock_state(int socket); PXE_BUFFER * pxe_sock_recv_buffer(int socket); /* pxe_listen() - creates "listening" socket * it's not the same as normal listen() system call. * Every pxe_listen() call creates pxe_socket structure * and adds filter to filter table. * WARN: * -1 - means failed * >= 0 - socket for UDP * == 0 - success for TCP */ int pxe_listen(int socket, uint8_t proto, uint16_t port); /* accept awaiting connections */ int pxe_accept(int socket); /* send to provided ip/port, updating filter for socket */ int pxe_sendto(int socket, const PXE_IPADDR *dst, uint16_t port, void *data, uint16_t size); /* moves socket to connected state */ int pxe_connect(int socket, const PXE_IPADDR *ip, uint16_t port, uint8_t proto); /* send data to socket, blocking */ int pxe_send(int socket, void *buf, uint16_t buflen); /* receive data from socket, blocking */ int pxe_recv(int socket, void *buf, uint16_t buflen); /* create new socket */ int pxe_socket(); /* binding */ int pxe_bind(int socket, const PXE_IPADDR *ip, uint16_t port, uint8_t proto); /* flushes send buffers */ int pxe_flush(int socket); /* close socket */ int pxe_close(int socket); /* returns next available local port */ uint16_t pxe_next_port(); #endif // PXE_SOCK_H_INCLUDED