httpd: parse Host header line
Mutex: record lock owner

mutex.s:
	record lock owner address if lock succeeds.
	add names.

debugger.s:
	add print mutex state and lock owners.
	change 'm' to print mutexes; add TAB to change mode.

keycodes.s:
	add KEY_TAB
Minor boot image update: calc sectors; add nopad

util/write.cpp:
	add -np (nopad) option: does not pad the image to 1.44Mb

Makefile:
	assign sector size of boot image to SECTORS variable and use
	that to specify boot-load-size to genisoimage.
Improve shell help.

shell.s:
	Add command categories, and reorder commands.
	Update cmdline_execute to skip categories.
	Update cmd_help.
Minor: update cmd_nics usage.

nic.s:
	print the [up|down] argument.
Minor: update cmd_route usage.

net.s:
	cmd_route:
		list all arguments.
		update parsing [mask <ip>]: make optional.

	socket_read:
		dont push/pop eax: not altered.
		update CF flag usage: or (and xor) clear CF.
		remove unused label 2:stc.
Manage paging flag on pmode/realmode transitions.

pmode.s:
	mask out paging flag on entering realmode: fixes protection fault.
	restore CR0 on returning from realmode call.
httpd: implement 'virtual hosts'.

The hardcoded document root serves all files for which a virtual host cannot
be found (i.e. Host: HTTP headers for which no directory exists).
When a directory matching the hostname exists, it is used.

httpd.s:
	use the parsed host header-line in the abovementioned fashion.

fs.s:
	add fs_stat: CF indicates presence of file/dir.
	update handle_pathpart: only print error message if flag says so.
	update fs_openfile/opendir: call fs_open (previously fs_openfile/dir)
	with flag.
	add fs_open: replaces fs_openfile/opendir, takes edx argument.
Implement TCP connection refused (RST).

All incoming TCP connection requests for which no service (port) is defined
are now responded to with a proper RST packet, resulting in 'connection refused'
messages on clients, instead of 'connection timed out' messages.

net.s:
	add net_tcp_tx_rst$: sends an RST packet according to spec.
	Update tcp state documentation according to rfc793.
	update tcp_checksum method: edx points to src/dst ipv4, so it
	can be used when transmission is initiated by packet reception
	aswell as sending data (at which point only the tcp_connection
	information is known).

	started work on accepting tcp connections in conjunction with
	listening sockets.
Move network sources to net/ subdir; 1/2

Note: this commit won't compile.
Split net.s 2/2.

net.s:
	remove protocols, route, and socket code.

arp.s, dhcp.s, eth.s, icmp.s, ipv4.s, tcp.s, udp.s, route.s, socket.s:
	add
Network subsystem improvements.

Main points:

* Fix icmp ping responses to request with payload other than 32 bytes.

* Fix tcp connection closing

* Rework protocol_checksum to take byte length, dealing with odd lengths here
  instead of having each caller do this.

kernel/net/net.s:
	remove debug constants for icmp and dhcp.
	have protocol_checksum take ecx=bytes, not words, and deal with
	odd lengths without modifying protocol frame.
	add net_print_ip_pair, printing src ip:port->dst ip:port, taking
	a pointer to the ipv4 frame and tcp or udp frame or anything starting
	with sport,dport.
	add net_print_ip_port, printing a network socket address, used by
	net_print_ip_pair.

kernel/net/icmp.s:
	move debug constant from net.s
	call protocol_checksum with ecx = bytes
	icmp_ping_response: copy the correct number of payload bytes.
	use macro NET_BUFFER_SEND, calculating proper frame length.

kernel/net/ipv4.s:
	header_put: call protocol_checksum with ecx=bytes;
	add generic method net_ip_pseudo_checksum, callable for udp and tcp
	packets.

kernel/net/tcp.s:
	add NET_TCP_RESPOND_UNK_RST constant, indicating whether to respond
	with RST packets for unknown connections. Due to some virtual network
	implementations, packets that are not really destined for the vm
	get delivered with NAT, resulting in an RST packet sent for active
	connections on the host (which seem to not reset the connection,
	fortunately). The following applies to when this constant is 1:

	do not respond to RST packets with RST;

	respond with RST to unknown connections;

	wrap RST tx debugging in debug constant.

	fix connection closing: count tx FIN and only send an ACK to FIN when
	appropriate.

kernel/net/udp.s:
	add UDP_LOG constant indicating whether to print dropped packets.
	Due to virtual machine network broadcasting (NAT, bridge etc), many
	UDP packets destined for the host will end up on the virtual nic,
	causing log floods.

	net_udp_header_put optimization: one memory reference less.
	net_put_eth_ipv4_udp_headers: calculate and store checksum aswell; at
	current only in used by dns.

	net_udp_checksum: call protocol_checksum with ecx=bytes;

	ph_ipv4_udp: validate ipv4 dst ip: must have a nic with that ip, or
	the address must be 255.255.255.255 broadcast or 224.0.0.0/4 multicast.
	TODO: move check to ipv4.s.

kernel/net/dhcp.s:
	move debug constant from net.s
Implement smtpd using sockets.

dns.s:
	affected due to socket_open arg change;
	fix using the udp port from net_udp_port_get

net.s:
	reorder includes to circumvent page faults due to gas faulty symbol
	resolution.

	include smtp.s

	fix bug in protocol_checksum: sometimes off-by 1 bit.

smtp.s:
	teeny smtpd. can parse all rfc 821 commands, but responds with
	error codes to most requests. mainly included to snoop, and to
	test sockets.

socket.s:
	add peer sockets, created by acceptable tcp syn's.

	socket_open: change arguments: edx=proto|port, ebx=flags, since IP protocol
	identifiers are 16 bits.

	fix socket_get_lport.

	add socket_write; implemented for tcp only. called by service.
	add socket_flush; idem.

	add net_sock_deliver_accept, to notify the task having called socket_accept.
	implement socket_accept: scans the socket array for acceptable peers,
	and if not found, schedules.
	TODO: semaphore optimisation

	add net_socket_find, used by tcp to check for server sockets.
	TODO: check for the LISTEN and !PEER flags. At current there is no
	risk for peer connections triggering accepting connections due to ip
	mismatch.

	add net_socket_write: called by kernel.

	document tcp socket usage.

	TODO: mutex.

	[note: some obsolete code is still present in this commit].

tcp.s:
	before calling net_tcp_service_get, call net_socket_find.

	update tcp_conn: add tcp_conn_sock.

	add tcp_rx_sock; the tcp_conn_handler for rx PSH.

	improve no-handler checking.

udp.s:
	change checksum method, verifying where the occasional checksum errors
	in the dns responses come from.
Fix icmp; Add array assertions.

debugger.s:
	add macro ASSERT_ARRAY_IDX and method, to check array index boundaries
	and element alignment.

net/icmp.s:
	update the call to socket_open.

net/socket.s:
	add array assertions.
	temporarily revert to old method (sti/hlt) of waiting for data in
	 socket_read: the scheduler call results in a hang unless sched.debug > 0.

net/tcp.s:
	add array assertions (and remove old check).
	add a debug trap - at current there is a bug of unknown origin in tcp_sendbuf
	where tcp_conn_sendbuf is invalid.

fs.s:
	add array assertions.

kernel.s:
	call cmd_smtpd

.tcshrc:
	add aliases to restart a second vmware vm.
	update 'w' alias to also grep in the kernel/net/ directory

DOC/:
	Update Assembly.txt:  document or, xor, test, cmp flag behaviour,
	and rep/loop ecx behaviour.
	Add Net.txt: document the (call) structures in use in the networking module.
	Update CloudNet.txt: some notes on deployment behind routers.
Increase ping timing precision.

pit.s:
	add get_time_ms: use the pit clock latch readout to calculate period
	fraction. Accuracy: 16 bit 1/18.4 Hz; rounded down milliseconds returned.

net/icmp.s:
	use get_time_ms instead of [clock_ms].
Create sparse os.iso / boot.img.
Fix DNS class check.

Bug occurred on 'TXT CH VERSION.BIND' query.
DNS: fix <Root> request handling.
Rework sockets & services to use sockets.

Makefile:
	register buffer.s

buffer.s:
	auto-compacting piping buffer.

kernel.s:
	include buffer.s;
	start dns service;
	start http service

mem.s:
	add mdup

mutex.s:
	add MUTEX_SOCK;
	fix mutexes: the argument to btr/bts is bit index, not bit.
	add MUTEX_SPINLOCK_ macro: efficient and clean (no labels/debug/error).
	add MUTEX_UNLOCK_ macros: idem, and preserves flags.
	add MUTEX_SCHEDLOCK: untested, but calls scheduler instead of halt

pit.s:
	add get_time_ms: calculates time precisely reading the clock period
	counter so that higher resolution can be achieved than the clock's
	interrupt interval.
	[note: should've been committed previously]

	set frequency to 250Hz (unrelated to above). This causes extremely fast
	response times for http requests, aswell as provided the cause for an
	intermittent exception in the scheduler.

schedule.s:
	cli on schedule.

net/net.s:
	copy/free packet in net_rx_packet, so that the NIC, which
	marks the packet buffer available as soon as net_rx_packet returns,
	does not cause overwriting of the packet should the buffer be reused
	before the packet is processed.
	The copying has to be done here since the received packet pointer
	will be handled asynchronously (non-deterministic barrier crossing).

net/dns.s:
	rework as scheduled socket service.
	[Triggered changes in socket.s and udp.s]

net/http.s:
	rework as scheduled socket service: use socket api instead of tcp_conn;
	support fragmented requests: use socket_peek (new) to parse the request
	until it is complete.

net/smtp.s:
	move tcp connection closing to socket_close.
	use socket_print instead of getting the tcp connection from the socket.

net/sip.s:
	begin work on 'session initiation protocol' after observing regular
	network traffic for this protocol.

net/socket.s:
	secure socket_array access with the MUTEX_SOCK mutex.

	add sock_in_buffer using buffer.s to both append streaming data
	to support fragmented HTTP requests through the socket_peek mechanism,
	and to append packets simulating a packet queue by using the buffer
	in a packetized manner (block lengths).
	This buffer is NOT used for SOCK_LISTEN sockets since they trigger
	creation of peer sockets which _do_ use this buffer.

	remove sock_in and sock_inlen in favour of the buffer to relieve the
	socket user of having to concatenate fragmented data in a buffer
	and to avoid race conditions.

	add socket_peek: sockets now have an input buffer to which all incoming
	data gets appended, either directly (tcp) or packetized (not tcp);

	add net_socket_deliver_udp: when the UDP socket is created with
	SOCK_LISTEN, create a peer socket and write the data to it; otherwise
	write it to the server socket's input buffer.  A socket_accept on the
	server socket returns a new peer socket for each packet originating from
	a new peer. All communication with that peer is then performed through
	this peer socket.
	[TODO: outgoing communication].

	Data is appended in packetized form, where one socket_read is required
	for each packet. When SOCK_READPEER is specified on socket creation,
	the data returned by sock_read will start with the peer socket address
	for unconnected udp sockets (the ones not created by the SOCK_LISTEN
	process described above).

	When an UDP socket is created without SOCK_LISTEN and without
	SOCK_READPEER, all incoming peer data will be available through this
	socket in packetized form, but without the peer address, when
	socket_read is used.

	socket_read: depending on flags, treat the buffer as a stream or
	packetized.

	socket_buffer_read: common for streaming and packetized; do not call
	directly. [TODO: add $]

	socket_is_stream: utility used in handling the buffer, made
	into a method since it is called without having a mutex lock on the
	array. This might serve with some optimization as lock is entered
	and exited twice for socket_read. This is a method as it is called
	from two places: socket_read and socket_peek, both of which require
	different handling for packetized data, so that this could not be done
	in socket_buffer_read.

	socket_close: handle tcp connection closing.

	remove peer_socket_open - unused; replaced by pre-existing
	net_sock_deliver_accept using socket_open.

	rename sock_data to sock_cust to avoid mistaking it for a buffer.

	net_socket_write uses the buffer, but does not honor packetization;
	it is currently called from the tcp layer.

	minor improvements, error messages etc.

net/tcp.s:
	update state check for reusing tcp connection structures: the order
	of the connection close sequence has changed resulting in a different
	status bitmask.

	remove tcp services called directly from the network queue; they
	are now called through sockets.

	pass the peer port number in LSB to net_sock_deliver_accept;

net/udp.s:
	use net_socket_deliver_udp instead of net_socket_deliver due to
	special handling of SOCK_LISTEN and SOCK_READPEER absence/presence
	for UDP sockets.

	remove check for DNS service.
	[TODO: rework DHCP].
Fix PIT time calculations; add sleep.

pit.s:
	the counter was a factor 16 too low for frequencies other than
	18 Hz; so 250 hz was 4Khz.

	add sleep (milliseconds) method.