PERFORCE change 125297 for review

Alexey Tarasov taleks at FreeBSD.org
Sat Aug 18 06:50:01 PDT 2007


http://perforce.freebsd.org/chv.cgi?CH=125297

Change 125297 by taleks at taleks_th on 2007/08/18 13:49:11

	libi386/pxe.c: moved rootpath parsing to pxe_core_update_bootp()
	loader/main.c: updated for correct usage of PXE_IPADDR
	loader/Makefile: fixed double defining of macros, added PXE_MORE
	pxe_http: fixed usage of servername, DNS resolving for http server moved to pxe_core.
	Makefile: added PXE_TCP_AGRESSIVE macro
	pxe_await.h: made delay smaller
	pxe_core: added pxe_core_update_bootp() function for parsing rootpath and etc after BOOTP/DHCP session.
	pxe_dhcp: changed packet type to  PXE_DHCPDISCOVER instead of PXE_DHCPREQUEST. Seems, more correct.
	pxe_segment: made segment acking more correct.
	pxe_sock: updated pxe_recv() by replacing values by macro.
	pxe_tcp: changed PXE_TCP_MSS to smaller size. Helps in tests with working in Internet .
	pxe_udp: fixed preprocessor misstype
	README: updated documentation.
	-----
	Most probably last submit this summer. Testing is welcomed.

Affected files ...

.. //depot/projects/soc2007/taleks-pxe_http/Makefile#15 edit
.. //depot/projects/soc2007/taleks-pxe_http/README#3 edit
.. //depot/projects/soc2007/taleks-pxe_http/httpfs.c#8 edit
.. //depot/projects/soc2007/taleks-pxe_http/libi386_mod/pxe.c#5 edit
.. //depot/projects/soc2007/taleks-pxe_http/loader_mod/Makefile#3 edit
.. //depot/projects/soc2007/taleks-pxe_http/loader_mod/main.c#3 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_await.h#5 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_core.c#26 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_core.h#22 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_dhcp.c#9 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_dhcp.h#9 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_http.c#12 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_icmp.c#15 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_segment.c#11 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_sock.c#20 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_tcp.c#14 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_tcp.h#9 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_udp.c#11 edit
.. //depot/projects/soc2007/taleks-pxe_http/pxe_udp.h#8 edit

Differences ...

==== //depot/projects/soc2007/taleks-pxe_http/Makefile#15 (text+ko) ====

@@ -35,9 +35,12 @@
 #CFLAGS+=	-DPXE_HTTP_DEBUG_HELL
 
 # define to get more PXE related code and testing functions
-# CFLAGS+=	-DPXE_MORE
+#CFLAGS+=	-DPXE_MORE
 
 # define to get some speed up by bigger requests
 CFLAGS+=	-DPXE_HTTPFS_CACHING
 
+# define to send packets freqently to speed up connection
+#CFLAGS+=	-DPXE_TCP_AGRESSIVE
+
 .include <bsd.lib.mk>

==== //depot/projects/soc2007/taleks-pxe_http/README#3 (text+ko) ====

@@ -1,30 +1,70 @@
+Contents
+----------
 
 1. Introduction
-1.2. Setting up
-1.2.1. DHCP configuration
-1.2.2. TFTP configuration
-1.2.3. Web-server configuration
-1.2.4. loader.rc configuratuion
+
+	1.2. Setting up
+
+		1.2.1. DHCP configuration
+		1.2.2. TFTP configuration
+		1.2.3. Web-server configuration
+		1.2.4. loader.rc configuratuion
+
 2. Project organisation
-2.1. Code modules
-2.2. Naming conventions
-2.3. Understanding logical structure of code
+
+	2.1. Code modules
+	2.2. Naming conventions
+	2.3. Understanding logical structure of code
+
 3. API usage
-3.1. Base information
-3.2. PXE sockets API overview
-3.2.1. PXE API socket details
-3.3. Quick Reference to API, available for user code
-3.3.1. pxe_arp module
-3.3.2. pxe_await module
-3.3.3 pxe_buffer module
-3.3.4. pxe_connection module
-3.3.5. pxe_core module
+
+	3.1. Base information
+	3.2. PXE sockets API overview
+
+		3.2.1. PXE API socket details
+
+	3.3. Quick Reference to API, available for user code
+
+		3.3.1. pxe_arp module
+		3.3.2. pxe_await module
+		3.3.3. pxe_buffer module
+		3.3.4. pxe_connection module
+		3.3.5. pxe_core module
+		3.3.6. pxe_dhcp module
+		3.3.7. pxe_dns module
+		3.3.8. pxe_filter module
+		3.3.9. pxe_http module
+		3.3.10. httpfs module
+		3.3.11. pxe_icmp module
+		3.3.12. pxe_ip module
+		3.3.13. pxe_isr module
+		3.3.14. pxe_mem module
+		3.3.15. pxe_sock module
+		3.3.16. pxe_segment module
+		3.3.17. pxe_tcp module
+		3.3.18. pxe_udp module
+
+4. Debugging, testing and tuning pxe_http library.
+
+	4.1. Using 'pxe' loader's command
+	4.2. Defining debug macroses
+	4.3. Tuning
+	4.4. NFS loading with pxe_http
 
 1. Introduction 
 ----------------
 
 		pxe_http library is user space implementation of simplified
-	TCP/IP4 stack with support of sockets.
+	TCP/IP4 stack with support of sockets. Socket implementation is similar
+	to common sockets, but differs, so I call this variant of sockets -
+	"PXE sockets"
+
+		features (read: simpliest ever implementation of):
+			* supports TCP/UDP PXE sockets
+			* DHCP client
+			* DNS client
+			* http based filesystem
+			* ICMP echo
 
 1.1. Requirements
 ------------------
@@ -175,7 +215,7 @@
 	/* end of example */
 
 		Of course, it's possible to set any other filesystem to work
-	as root, e,g, NFS.
+	as root, e,g, NFS and not use RAM drive.
 		
 2. Project organisation
 ------------------------
@@ -189,18 +229,20 @@
 		pxe_buffer     - implements cyclic buffers		(3.3.3)
 		pxe_connection - TCP connection related functions	(3.3.4)
 		pxe_core       - provides calls to PXE API		(3.3.5)
-		pxe_dhcp       - DHCP client
-		pxe_dns        - DNS client
-		pxe_filter     - incoming packet filters
-		pxe_http       - HTTP related functions
-		pxe_icmp       - ICMP protocol
-		pxe_ip         - IP protocol
-		pxe_isr        - assembler side support for PXE API calling
-		pxe_mem        - memory work routines
-		pxe_sock       - simple sockets
-		pxe_segment    - TCP segments
-		pxe_tcp        - TCP protocol
-		pxe_udp        - UDP protocol
+		pxe_dhcp       - DHCP client				(3.3.6)
+		pxe_dns        - DNS client				(3.3.7)
+		pxe_filter     - incoming packet filters		(3.3.8)
+		pxe_http       - HTTP related functions			(3.3.9)
+		httpfs         - http based file system			(3.3.10)
+		pxe_icmp       - ICMP protocol				(3.3.11)
+		pxe_ip         - IP protocol				(3.3.12)
+		pxe_isr        - assembler side support for PXE API
+				 calling				(3.3.13)
+		pxe_mem        - memory work routines			(3.3.14)
+		pxe_sock       - simple sockets				(3.3.15)
+		pxe_segment    - TCP segments				(3.3.16)
+		pxe_tcp        - TCP protocol				(3.3.17)
+		pxe_udp        - UDP protocol				(3.3.18)
 
 2.2. Naming conventions
 ------------------------
@@ -239,8 +281,7 @@
 	stack protocol, other packets are ignored.
 		Registration of handler (except ARP) is performed during
 	initialisation time of module with usage of pxe_core_register() function,
-	which register handler for IP stack protocol
-	number.
+	which register handler for IP stack protocol number.
 		So, packet is provided to handler, but it may be fragmented,
 	thus before processing it must be recieved completely. But in some cases
 	packet may be not interesting for protocol (unexpected packet, dublicated
@@ -267,6 +308,9 @@
 3. API usage
 -------------
 
+		Here much attention paid to sockets, other pxe_http API
+	may be used less frequently.
+
 3.1. Base information
 -----------------------
 
@@ -289,7 +333,7 @@
 	related functions are declared in pxe_sock.h header
 
 		Socket is created by pxe_socket() call. After usage socket must
-	be closed by pxe_close() call. Result of pxe_call() is integer
+	be closed by pxe_close() call. Result of pxe_socket() is integer
 	descriptor associated with socket. After creating socket is unbinded
 	and not connected.
 		pxe_sendto(), pxe_connect(), pxe_bind() functions performs
@@ -305,6 +349,7 @@
 	that have default sizes 16Kb and 4Kb. If buffers are full, next calls
 	related to writing or reading data will fail.
 
+
 3.2.1. PXE API socket details
 ------------------------------
 
@@ -384,6 +429,10 @@
 3.3 Quick Reference to API, available for user code
 ----------------------------------------------------
 
+		This overview covers functions and macro definitions that
+	may be usefull for user code.
+
+
 3.3.1 pxe_arp module
 ---------------------
 
@@ -392,20 +441,21 @@
 
 macro definitions:
 
-MAX_ARP_ENTRIES	- how much may be ARP table in size. If ARP table full and new
-	MAC must be placed, then one of older entry is replaced by new. Default
-	number is 4.
+MAX_ARP_ENTRIES		- how much may be ARP table in size. If ARP table full
+			and new	MAC must be placed, then one of older entry is
+			replaced by new. Default number is 4.
 
-PXE_MAX_ARP_TRY	- how much trys will be peformed when sending ARP requests,
-	before say MAC search failed. Default: 3
+PXE_MAX_ARP_TRY		- how much trys will be peformed when sending ARP
+			requests, before say MAC search failed. Default: 3
 
-PXE_TIME_TO_DIE	- how much time to wait ARP reply in milliseconds.
-	Default: 5000 ms.
+PXE_TIME_TO_DIE		- how much time to wait ARP reply in milliseconds.
+			Default: 5000 ms.
 
-PXE_ARP_SNIFF	- sometimes it's usefull to get MACs from incoming requests
-	(this may save time, MAC may be found in table without requesting it by
-	ARP module itself). But	if network is big enough - ARP table will be
-	updated too often. By default this option is defined.
+PXE_ARP_SNIFF		- sometimes it's usefull to get senders MACs from
+			incoming requests (this may save time, MAC may be found
+			in table without requesting it by ARP module itself).
+			But if network is big enough - ARP table will be
+			updated too often. By default this option is defined.
 
 
 functions:
@@ -522,16 +572,20 @@
 
 macro definitions:
 
-TIME_DELTA_MS	- delay between iterations during awaitng. At each iteration
-		are checked:
-		* receiving of new packet. If received - awaiting function with
-		  PXE_AWAIT_NEWPACKETS function is called.
-		* try timeout. if timeout exceeds maximum timeout - awaiting
-		  function with PXE_AWAIT_FINISHTRY and PXE_AWAIT_STARTTRY
-		  flags sequentially are called.
-		* try count. if try count exceeds maximum - awaiting function
-		  with PXE_AWAIT_ENDED flag is called. This means that await
-		  failed.
+TIME_DELTA_MS		- delay between iterations during awaitng. At each
+			iteration are checked:
+			* receiving of new packet. If received - awaiting
+			 function with PXE_AWAIT_NEWPACKETS function is called.
+			* try timeout. if timeout exceeds maximum timeout -
+			 awaiting  function with PXE_AWAIT_FINISHTRY and
+			 PXE_AWAIT_STARTTRY flags sequentially are called.
+			* try count. if try count exceeds maximum - awaiting
+			 function with PXE_AWAIT_ENDED flag is called. This
+			 means that await failed.
+			 Default: 1
+
+TIME_DELTA		- default: 1000, same as TIME_DELTA_MS, but in ticks
+			 for delay.
 
 
 3.3.3 pxe_buffer module
@@ -542,19 +596,23 @@
 
 macro definitions:
 
-PXE_POOL_SLOTS - if defined, then statical allocation of buffers is used.
-	Otherwise buffers are allocated at run-time from heap with pxe_alloc()
-	function. Current statical allocation algorithm is simple and square,
-	there are two big buffers data storages divided in slots (by default 2).
-	Each slot has size equal to PXE_DEFAULT_RECV_BUFSIZE or
-	PXE_DEFAULT_SEND_BUFSIZE. Depending on requested size in
-	pxe_buffer_alloc() function data allocated from one of stoarge and
-	related	slot marked busy. When pxe_buffer_free() called, slot marked
-	as free.
-		Default: undefined
+PXE_POOL_SLOTS 		- if defined, then statical allocation of buffers is
+			used. Otherwise buffers are allocated at run-time from
+			heap with pxe_alloc() function. Current statical
+			allocation algorithm is simple and square, there are
+			two big buffers data storages divided in slots (by
+			default 2).
+				Each slot has size equal to
+			PXE_DEFAULT_RECV_BUFSIZE or PXE_DEFAULT_SEND_BUFSIZE.
+			Depending on requested size in pxe_buffer_alloc()
+			function data allocated from one of stoarge and
+			related	slot marked busy. When pxe_buffer_free() called,
+			slot marked as free.
+				Default: undefined
+
+PXE_DEFAULT_RECV_BUFSIZE - size of receiving buffer. Default: 16392
 
-PXE_DEFAULT_RECV_BUFSIZE	- size of receiving buffer. Default: 16392
-PXE_DEFAULT_SEND_BUFSIZE        - size of sending buffer. Default: 4096
+PXE_DEFAULT_SEND_BUFSIZE - size of sending buffer. Default: 4096
 
 
 3.3.4 pxe_connection module
@@ -573,7 +631,8 @@
 functions:
 
 void pxe_connection_stats()
-	- returns connections statistics. Available if defined PXE_MORE macro.
+	- returns connections statistics. Available if PXE_MORE macro is
+	defined.
 
 
 3.3.5 pxe_core module
@@ -587,8 +646,9 @@
 
 PXE_BUFFER_SIZE 	- size of core buffers, used in PXE API calling,
 			  Default: 4096
-PXE_CORE_STATIC_BUFFERS - if defined, core buffers are allocated statically.
-		Otherwise they are allocated in heap. Default: defined
+
+PXE_CORE_STATIC_BUFFERS	- if defined, core buffers are allocated statically.
+			Otherwise they are allocated in heap. Default: defined
 
 functions:
 
@@ -622,11 +682,572 @@
 void pxe_set_ip(uint8_t id, const PXE_IPADDR *ip)
 	- sets value by it's id.
 
-structures and types:
+time_t	pxe_get_secs()
+	- returns time in seconds. Used in timeout and resend checking.
+
+types:
 
 typedef int (*pxe_protocol_call)(PXE_PACKET *pack, uint8_t function)
 	- protocol callback function type
 
-time_t	pxe_get_secs()
-	- returns time in seconds. Used in timeout and resend checking.
+
+3.3.6. pxe_dhcp module
+-----------------------
+
+		This module implements simple DHCP client, used to obtain
+	gateway, nameserver and other information.
+
+
+macro definitions:
+
+PXE_BOOTP_USE_LIBSTAND	- use bootp() function provided by libstand instead
+	of own DHCP client. NOTE: bootp() doesn't set nameip (nameserver ip
+	structure), thus DNS resolving will be impossible. Default: undefined
+	
+	NOTE: to use bootp(), also UDP_DEFAULT_SOCKET macro must be defined.
+
+
+functions:
+
+void pxe_dhcp_query(uint32_t xid)
+	- sends DHCPDISCOVER packet and sets core_ips, if gets reply.
+
+
+3.3.6. pxe_dns module
+----------------------
+
+		This module provides domain name resolving. Actually
+	A and CNAME resource records are supported.
+
+macro definitions:
+
+PXE_MAX_DNS_TIMEOUT	- max time to wait DNS reply in milliseconds.
+			Default: 10 seconds
+
+PXE_MAX_DNS_TRYS	- how many times to try to resend request,
+			if there is no reply. Default: 3
+
+PXE_DNS_MAX_PACKET_SIZE	- maximum UDP packet size in bytes. Default: 512.
+			This DNS client doesn't support TCP for resolving.
+
+functions:
+
+const PXE_IPADDR *pxe_gethostbyname(char *name)
+	- returns IP, if resolved, for provided domain name. 
+
+uint32_t pxe_convert_ipstr(char *str)
+	- converts string value of ipv4 to uint32_t value.
+
+
+3.3.8. pxe_filter module
+-------------------------
+
+		This module is not supposed to be used by user code directly.
+	It implements filtering of incoming IP packets. It's used by UDP and
+	TCP modules for sorting packets in appropriate socket.
+		Module provides functions for adding and removing filters.
+	Each filter contains source/destination ip:port definition and masks
+	for all of them. Usage of masks gives opportunity to recieve data
+	from subnet, or subset of ports.
+
+functions:
+
+void pxe_filter_init()
+	- inits filter module structures such as list of free filter entries.
+
+void pxe_filter_stats()
+	- show active filters information. Used for debugging. Available if
+	PXE_MORE macro defined.
+
+
+3.3.9. pxe_http module
+-----------------------
+
+		pxe_http implements functions for getting files via HTTP.
+	Most of it's functions are used only by httpfs module.
+		At opening file pxe_exists() function is called, which
+	gets filesize (if possible) by HEAD method of request and opens
+	connection to file. Result of pxe_exists() call is keep-alive
+	connection to file.
+		pxe_get() function gets needed data and reestablishes
+	connection if needed.
+		if PXE_MORE defined - pxe_get_close() function becomes
+	available. It opens connection, gets portion of data and closes
+	connection. It's rather not optimal usage of http connections,
+	but some times it may be needed (e.g. for servers, where keep
+	alive connections are prohibited).
+
+macro definitions:
+
+PXE_MAX_HTTP_HDRLEN	- buffer size for generating/getting http header.
+			Default: 1024 bytes.
+
+functions:
+
+int pxe_fetch(char *server, char *filename, off_t from, size_t size)
+	- testing function, gets file from server ()may be partially) and
+	outputs received data to screen. Available if PXE_MORE defined.
+
+
+3.3.10. httpfs module
+----------------------
+
+		httpfs is filesystem, available via HTTP. It is read-only
+	filesystem, mainly with sequential access to files. It exports
+	file operations structure and is not used directly by user code.
+		httpfs module may support some kind of caching: it requests
+	more data per request then it's needed at http_read() call and
+	reads this data later. Such approach speed ups connections speed
+	and reduces server load.
+		This opportunity is available if PXE_HTTPFS_CACHING macro
+	is defined.
+
+
+3.3.11. pxe_icmp module
+------------------------
+
+		pxe_icmp module provides some basic functionality of ICMP
+	protocol: echo requesting/replying.
+		Module is unavailable, if PXE_MORE undefined.
+
+
+macro definitions:
+
+PXE_ICMP_TIMEOUT	- timeout in milliseconds when waiting echo reply.
+		Default: 5000 ms.
+
+
+functions:
+
+int pxe_ping(const PXE_IPADDR *ip, int count, int flags)
+	- works similar to usual ping, sends echo request and shows timeout
+	before echo reply.
+
+int pxe_icmp_init()
+	- inits module
+
+
+3.3.12. pxe_ip module
+----------------------
+
+		This module implemets IP protocol functions, also it works
+	with routing table. It also declares PXE_IPADDR, that is used widely.
+
+macro definitions:
+
+PXE_MAX_ROUTES	- route table size. Default: 4, usually used 2 entries.
+
+
+functions:
+
+uint16_t pxe_ip_checksum(const void *data, size_t size)
+	- calculates checksum for provided block of data.
+
+
+void pxe_ip_route_init(const PXE_IPADDR *def_gw)
+	- inits routing table, sets default gateway
+
+
+int pxe_ip_route_add(const PXE_IPADDR *net, uint32_t mask,
+	const PXE_IPADDR *gw)
+	- adds route to routing table 
+
+int pxe_ip_route_del(const PXE_IPADDR *net, uint32_t mask,
+	const PXE_IPADDR *gw)
+	- dels route from routing table 
+
+uint32_t pxe_ip_get_netmask(const PXE_IPADDR *ip)
+	- returns class based netmask for ip.
+
+int pxe_ip_route_default(const PXE_IPADDR *gw)
+	- adds default gateway 
+
+int pxe_ip_send(void *data, const PXE_IPADDR *dst, uint8_t protocol,
+	uint16_t size)
+	-  sends ip packet with provided data. There must be space for
+	IP header in buffer, pointed by data.
+
+void pxe_ip_route_stat()
+	- show route table. Available if PXE_MORE defined
+
+
+3.3.13. pxe_isr module
+-----------------------
+
+		Contains assembler side functions, used in pxe_core.
+	User code has no direct access to them.
+		There supported: installation/removing of interrupt handler,
+	interrupt handler and wrapper for PXE API calls.
+
+
+3.3.14. pxe_mem module
+-----------------------
+
+		Actually this module just a wrapper to bcopy(), alloc() and free()
+	functions. That's done to make pxe_http library more portable.
+		But in fact, pxe_http depends much on other libstand functions,
+	such as printf(), strcpy() and etc. So this module is not very usefull and
+	will be probably removed in future.
+
+
+3.3.15. pxe_sock module
+------------------------
+
+		Most used by user code module. Contains implementation of
+	pxe_http sockets API.
+
+
+macro definitions:
+
+PXE_DEFAULT_SOCKETS	- count of sockets used at the same time. If all
+			socket structures are used, next socket creating calls
+			and API that depends on it, will fail. Default: 4
+
+
+PXE_SOCKET_TIMEOUT	- how long pxe_recv() will be wiating incoming data per
+			call before return error. Default: 30000 ms
+
+PXE_SOCKET_CHECK_TIMEOUT - If pxe_recv() waits incoming data and have big free
+			space in buffer, and in case of TCP protocol it may notice
+			remote server about this by sending empty packet (with
+			no data) acking current state, so remote host updates
+			knowledge about	receiving window of client and sends new
+			data.
+				That option specifies how long pxe_recv() will
+			be waiting before checking TCP connection. In fast
+			environments like LAN it speed ups connection when huge
+			amount of data is transmitted, in WAN it's not very
+			useful.
+				Default: 100 ms. This option works only if
+			PXE_TCP_AGRESSIVE macro is defined.
+
+PXE_SOCKET_ACCURATE	- adds extra socket validating at head of every
+			socket related function, available to user.
+			By default: defined.
+
+functions:
+
+void	pxe_sock_init()
+	- inits socket API module.
+
+void	pxe_sock_stats()
+	- prints out to screen socket usage statistics. Available if PXE_MORE
+	macro defined.
+
+int	pxe_sock_state(int socket)
+	- return current socket state. May be one of this states:
+	PXE_SOCKET_BINDED, PXE_SOCKET_CONNECTED, PXE_SOCKET_ESTABLISHED.
+	It may be used for checking, if connection was breaked.
+
+
+int	pxe_sendto(int socket, const PXE_IPADDR *dst, uint16_t port,
+	    void *data, uint16_t size)
+	-  sends to provided ip/port, updating filter for socket. If
+	socket is not connected, connects it. Blocking operation.
+
+int	pxe_connect(int socket, const PXE_IPADDR *ip, uint16_t port,
+	    uint8_t proto)
+	- establishes connection to remote host and updates needed filter
+	structures.
+
+int	pxe_send(int socket, void *buf, uint16_t buflen)
+	- sends data to socket, blocking operation till successfull sending
+	or error.
+
+int	pxe_recv(int socket, void *buf, uint16_t buflen)
+	- receives data from socket. Blocks till timeout, error or
+	successfull result.
+
+int	pxe_socket()
+	- creates new socket. Every socket must be closed after usage by
+	pxe_close() call.
+
+int	pxe_bind(int socket, const PXE_IPADDR *ip, uint16_t port,
+	    uint8_t proto)
+	- binds local ip, port for socket. Used e,g, by DHCP.
+
+int	pxe_flush(int socket)
+	- flushes sending buffer. After this call user code may be sure that
+	data was transmitted to network, but may be not received by remote
+	host yet.
+
+int	pxe_close(int socket)
+	- closes socket.
+
+uint16_t pxe_next_port()
+	- returns next available local port. It just increments at each call.
+
+
+3.3.16. pxe_segment module
+---------------------------
+
+		Part of TCP related modules. Contains functions used internally
+	for creating and sending TCP segments.
+		pxe_segment module uses memory space of sending buffer manually
+	without buffer writing functions. 
+		Buffer is divided to PXE_TCP_BLOCK_COUNT blocks, each block
+	is divided to PXE_TCP_CHUNK_COUNT chunks, by default 64 chunks at all
+	with size 64 bytes for each (for default buffer size 4096).
+		Packets may be "small" (e.g. system packets ACK, RST and etc)
+	and contain no user data. In such case usualy will be enough one chunk
+	for packet. Also packets may be "big", but not bigger than one block
+	size minus segment descriptor structure. If packet exclusevely uses
+	all chunks in block it gives about 460 user data per segment.
+		For client-side usage this must be enough.
+
+macro definitions:
+
+PXE_RESEND_TIME		- if during this time segment was not acked, it will be
+			resent. At every resend try this value will be increased.
+			Default: 1 second
+
+PXE_RESEND_TRYS		- how much resend trys to do. Default: 3
+
+PXE_TCP_BLOCK_COUNT     - how much blocks in memory buffer for segments.
+
+PXE_TCP_CHUNK_COUNT     - how much chhunks in buffer for segments.
+
+
+3.3.17. pxe_tcp module
+-----------------------
+
+		TCP related module. Implements handling of incoming packets,
+	it's functions are used internally.
+
+macro definitions:
+
+PXE_TCP_MSL		- maximum segment life time in milliseconds.
+			Used only in TINE_WAIT state. Default: 60000 ms.
+
+PXE_TCP_SYSBUF_SIZE	-  buffer size used for system messages for packets
+			without real connection. It may be for closed or
+			unxexisting connections. In such case there is no
+			bufer for outcoming segments, but module needs to send
+			at least RST. Default: 64 bytes.
+
+PXE_TCP_MSS		- maximum segment size. For Ethernet LAN it's 1460,
+			but for internet connections it may be useful to
+			use smaller segment size, e.g. 1260. Default: 1260
+
+functions:
+
+void pxe_tcp_init()
+	- inits TCP module. Usually started automatically from pxe_core_init()
+
+
+3.3.18. pxe_udp module
+-----------------------
+
+        	Implements UDP protocol. May be used without sockets API.
+
+macro definitions:
+
+UDP_DEFAULT_SOCKET	- if defined, "default UDP socket" is created. All
+			filtered out data goes to this socket. It was added
+			to support udpread() and udpsend() functions, used
+			by libstand itself. Also it may be used for working
+			with UDP module, skipping direct work with sockets API.
+			Default: undefined.
+
+functions:
+
+void pxe_udp_init()
+	- UDP module init
+
+void pxe_udp_shutdown()
+	- UDP module shutdown routine
+
+int pxe_udp_send(void *data, const PXE_IPADDR *dst, uint16_t dst_port,
+	uint16_t src_port, uint16_t size)
+	- sends udp packet.
+
+
+int pxe_udp_read(PXE_SOCKET *sock, void *tobuf, uint16_t buflen,
+	PXE_UDP_DGRAM *dgram_out)
+	-  reads data from udp socket. if sock == NULL, "default"
+	socket is assumed.
+
+
+4. Debugging, testing and tuning pxe_http library.
+--------------------------------------------------
+
+		pxe_http library has built-in testing functions, that may be
+	started from loader's console. For this PXE_MORE macro must be defined
+	while compiling loader and pxe_http itself.
+		After this 'pxe' command appears in list of available commands.
+	
+	
+4.1. Using 'pxe' loader's command
+----------------------------------
+
+		This commands helps to test working od pxe_http library and
+	contains one really usefull function ping.
+		While loading pxe_http gets gateway, nameserver & etc
+	information from DHCP server. In case if there is any error (e.g.
+	DHCP packet contains no information about nameserver) this must be
+	set manually for correct working of code.
+
+	command 'arp':
+		- this command test ARP protocol related functions.
+
+		 Example: pxe arp stats 
+				-  shows current arp table. It contains same
+				values as usual.
+			  pxe arp ip4.addres 
+				- trys to get MAC address of provided ip using
+				ARP protocol.
+
+	command 'await':
+		- used to test how implemented ICMP echo request and ARP
+		 request replying.
+
+		 Example: pxe await 
+				- starts infinte loop, in which will be
+				processed received packets. It's usefull for
+				testing ARP and ICMP request/replies. "Infinte"
+				means there is no exit from it without resetting
+				of PC.
+
+	command 'filters':
+		- shows current filters usage information.
+
+ 		 Example: pxe filters
+				- shows current filters usage. If all is ok,
+				sockets closed correctly, filters are free -
+				you will see something like "0/8 filters".
+				If there is connected socket, or there was
+				error somewhere in implementation - you will
+				see filters related info (source/destination
+				ip/ports, binded socket).
+
+	command 'ns':
+		- used to see and modify default nameserver.
+
+		 Example: pxe ns
+				- shows nameserver
+
+		 	  pxe ns ip4.addr
+				- sets nameserver to specified ip address.
+
+
+	command 'ping':
+		- performs similar actions to well known ping command. It sends
+		 echo requests and gets replies, calculating timeouts.
+
+		 Example: pxe ping ip4.addr
+				- performs sending five icmp echo requests to
+				specified ip address.
+
+	command 'resolve':
+		- performs sending DNS requests and extracts A or CNAME answers
+		 from nameserver replies. 
+
+		 Example: pxe resolve domain.name
+				- performs domain name resolution, using default
+				nameserver.
+
+	command 'route':
+		- works with routing table and used for ip based protocols.
+		 IP packet routed to first found route, routes are searched
+		 sequentially from start of table to end..
+
+		 Example: pxe route print 
+				- shows current routing table.
+
+			  pxe route add default ip4.addr
+				- sets default gateway
+
+			  pxe route add net4.addr gw4.addr
+				- sets gateway for network. Mask for network is
+				generated automatically from net address, CIDR
+				is not supported.
+
+			  pxe route del net4.addf gw4.addr 
+				- removes route from table.
+
+	command 'socket':
+		- currently just shows statistics related to active sockets.
+
+		 Example: pxe socket stats
+				- show active sockets information.
+
+
+4.2. Defining debug macroses
+-----------------------------
+
+		All debug macroses divided in groups to provide more flexible
+	debugging of exact module. There are two levels of debugging:
+	first just adds _DEBUG suffix to macro, next _DEBUG_HELL. Second one
+	as expected from it's naming - provides more information.
+		All this macro definitions are situated in project Makefile.
+
+
+macro definitions:
+
+PXE_DEBUG
+PXE_DEBUG_HELL		- common modules debuging. This macroses adds debug
+			information output toi all modules, that are not
+			covered by macroses below.
+
+			NOTE: defining PXE_DEBUG macro doesn't defines
+			 e.g. PXE_CORE_DEBUG. It must be set manually.
+
+PXE_CORE_DEBUG
+PXE_CORE_DEBUG_HELL	- pxe_core module debuging
+
+PXE_TCP_DEBUG
+PXE_TCP_DEBUG_HELL	- related to TCP modules debuging
+
+PXE_IP_DEBUG
+PXE_IP_DEBUG_HELL	- IP module debug. Includes routing.
+
+PXE_ARP_DEBUG
+PXE_ARP_DEBUG_HELL	- ARP module debug
+
+PXE_HTTP_DEBUG
+PXE_HTTP_DEBUG_HELL	- httpfs and pxe_http module debugging
+
+PXE_MORE		- adds functions, used to out to screen information
+			about filters, sockets and etc usage.
+
+4.3. Tuning
+------------
+
+		Well, pxe_http library developed as library that implements
+	client sockets API. But, it may be used in different environments and
+	thus may have different behaviour e,g, in LAN and in WAN.
+		In most cases it works well in both cases, but if not - here is
+	some hints that may be usefull.
+
+		In LAN usually packet loss is small and speed is fast, so
+	it may be good idea to define PXE_TCP_AGRRESIVE macro (see 3.3.15).
+		PXE_TCP_MSS may me set to 1460 without any doubts.
+		Buffer sizes may be set higher (3.3.3). 16K for incoming
+	traffic is good enough for WAN connections, but for LAN it may be set
+	higher. If big UDP datagrams are sended, send buffer must be set to
+	such space, in which it may fit.
+		Also all timeouts may be smaller. For example, first candidate
+	for it is TIME_DELTA (3.3.2)
+
+		Next point - what buffers use: statically allocated or
+	dinamically. Default variant is best (at least, I think so) but
+	it may be not bad idea to play with PXE_CORE_STATIC_BUFFERS and 
+	PXE_POOL_COUNT.
+
+		It may be usefull to turn off httpfs caching. Using of
+	caching speed ups getting of file, but anyway undefining of
+	PXE_HTTPFS_CACHING still gives working code.
+
+
+4.4. NFS loading with pxe_http
+-------------------------------
+
+		Original pxeboot has ability to load kernel, loader.rc and etc.
+	pke_http may provide udpread()/udpsend() functions needed for that.
+
+		undefine:	loader/Makefile: LOADER_HTTP_SUPPORT
+		define:		pxe_http/pxe_udp.h: UDP_DEFAULT_SOCKET
+				pxe_http/pxe_dhcp.h: PXE_BOOTP_USE_LIBSTAND
+				libi386/Makefile: PXEHTTP_UDP_FOR_LIBSTAND
 
+	After that - NFS loader must work, as well as TFTP.		
==== //depot/projects/soc2007/taleks-pxe_http/httpfs.c#8 (text+ko) ====

@@ -91,7 +91,7 @@
 
 	pxe_memset(httpfile, 0, sizeof(PXE_HTTP_HANDLE));
 								
-	pxe_memcpy(pxe_get_ip(PXE_IP_WWW), &httpfile->addr, sizeof(PXE_IPADDR));
+
 	httpfile->offset = 0;
 	httpfile->socket = -1;
 	
@@ -101,18 +101,22 @@
 		handle_cleanup(httpfile);
                 return (ENOMEM);
         }
-	
 
 	if (servername[0]) {
 		httpfile->servername = servername;
 	} else {
-		httpfile->servername = strdup(inet_ntoa(httpfile->addr.ip));	
+		httpfile->servername = strdup(inet_ntoa(httpfile->addr.ip));
 	}
-	
+
+	pxe_memcpy(pxe_get_ip(PXE_IP_WWW), &httpfile->addr, sizeof(PXE_IPADDR));
+
+#ifdef PXE_DEBUG_HELL	
+	printf("servername: %s\n", httpfile->servername);
+#endif
 	if (httpfile->servername == NULL) {
 		handle_cleanup(httpfile);
 	}
-	
+
 	httpfile->buf = malloc(PXE_MAX_HTTP_HDRLEN);
 	
 	if (httpfile->buf == NULL) {
@@ -132,6 +136,7 @@
 #ifdef PXE_HTTP_DEBUG
 	printf("http_open(): %s opened\n", httpfile->filename);
 #endif
+
 	return (0);
 }
 

==== //depot/projects/soc2007/taleks-pxe_http/libi386_mod/pxe.c#5 (text+ko) ====

@@ -185,8 +185,6 @@
 {
 	va_list	args;
 	char	*devname = NULL;
-	char	temp[20];
-/*	char	temp[FNAME_SIZE]; */
 	int	i = 0;
 	
         va_start(args, f);
@@ -205,73 +203,13 @@
 	    
 		}
 

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list