496: Advanced Networking and Web Systems ========================================= Capstone-level exploration of network protocols, server configuration, and early web technologies. Topics ------ - TCP/IP networking: BOOTP and DHCP protocol implementation - HTTP server configuration (Apache ``httpd``) - CGI scripting with Perl - Network boot infrastructure Projects -------- BOOTP/DHCP Client (``496/bootp.c``, ``496/bootp.pl``) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Implements a BOOTP/DHCP client in both C and Perl. Constructs and broadcasts UDP discovery packets, parses server responses to obtain IP addresses, subnet masks, and gateway information, and applies the configuration to the local interface. .. code-block:: perl #!/usr/local/bin/perl # Perl BOOTP client — broadcast request, parse reply $BOOTP_PORT = 67; $socket = IO::Socket::INET->new(Proto => 'udp', Broadcast => 1); # Build a minimal BOOTP request packet (RFC 951) $packet = pack("CCCCNnna4a4a4a4a16a64a128", 1, # op: BOOTREQUEST 1, # htype: Ethernet 6, # hlen: MAC address length 0, # hops $xid, # transaction ID 0, 0, # secs, flags $ciaddr, $yiaddr, $siaddr, $giaddr, $chaddr, $sname, $file ); send($socket, $packet, 0, $broadcast); CGI Web Forms (``496/form.pl``, ``496/search.pl``) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Early CGI scripts written in Perl to handle HTML form submissions and implement basic search functionality. Demonstrates the CGI request/response cycle, query-string parsing, and dynamic HTML generation predating modern web frameworks. .. code-block:: perl #!/usr/local/bin/perl print "Content-type: text/html\n\n"; # Read POST body from stdin read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split into name=value pairs and URL-decode each value foreach $pair (split(/&/, $buffer)) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/eg; $form{$name} = $value; } # Validate required fields before processing foreach $var (@required_vars) { if (!$form{$var}) { print "