Operating Systems and Systems Programming
Operating Systems and Systems Programming Semester 1, 2024Eike Ritter, David OswaldThe University of Birmingham30 September, 2024Exercise 1
Deadline: 14 November, 4pm
The Task Write a set of programs which maintains the firewall configuation.
- One program is a server program. Once started, the server should run forever. It waits for requests, process them and produce a specific response.
The server maintains a collection of firewall rules. For each rule in therequests submitted to it. The serverprogram should accept and process requests and return a response asfollows:
❼ Listing all requests in the order they were given. The command forthis request is R
❼ Adding a rule to the stored rules. This request expects a string which
contains a firewall rule as specified below. If the rule is valid, therule is added the set of firewall rules. The response is Rule addeif the rule has been added, and Invalid rule if the string is not avalid rule. The command for this request isA <rule>Checking whether a given IP address and port are allowed according
to the rules. If this is the case, the IP address and port are addedto list of matched queries for this rule. If the given address and portare allowed according to several rules,you should add the IP addressand port to only one rule. If the given IP address and port is checkedgain, they may be added to a different rule. If the input does notprovide a valid IP address and a valid port, the response should beIllegal IP address or port specified. If the IP address andport are valid and should be accepted according to the rules, theresponse should be Connection accepted. If the IP address andport are valid and should be rejected according to the rules, theresponse should be Connection rejected. The command for thisrequest isC <IPAddress> <port>1❼ Delete a valid rule from the stored rules. This should also delete thelist f IP addresses and ports stored for this rule. The rule shouldbe deleted if the server stores exactly the same rule. In allother cases, no action should be taken except returning a suitablemessage. If the specification of the rule is invalid, the response shouldbe Rule invalid. If the rule is successfully deleted, the responseshould be Rule deleted. If the rule is valid but not found on the, the response should be Rule not found. Thecommand forthis request isD <rule>
Return all rules and for each rule list all IP addresses and portswhich are stored with it. More precisely, for each rule, the responsehould beRule: <rule>where <rule> is the specification of the rule as given below, followed
yQuery: <IPaddress> <port>for each query stored with this firewall rule. The command for thisequest is L
❼ For any other request, the response should be Illegal request.There are two ways of interacting with the server program.
❼ The first one is to start the server with<ServerProgram> -iwhere <ServerProgram> is the way to call the server program, typically ./server. In this mode the server reads an command fromstandard input, prints the response andwaits for the next input.
❼ The second way of running the server is
<ServerProgram> <port>where <ServerProgram> is the way to call the server program, typ ./server, and <port> is the port on which the server listens
for incoming connections. A client program, which you will have towrite as well, makes it possible to send commands to the server proand display the results on standard output. The client shoulde called with<ClientProgram> <serverHost> <serverPort> <command>without any quotes, e.g../client ocalhost 2200 A 147.188.193.15 22All other ways of calling the client program should return an errormessage.2The specification of a firewall rule is below.A rule is of the orm<IPAddresses> <portswhere <IPAddresses> is either a single IP address, which has the form xxx.xxx.xxx.xxx,where xxx is a number between 0 and 255, or <IPAddress1>-<IPAddress2>,where <IPAddress1> and <IPaddress2> are IP addresses, and <IPAddress1> issmaller than <IPaddress2>. Assume that IP addresses and portsre separatedby exactly one space character.
Similarly, <ports> is either a single port number, which is a number between0 and 65535, or <port1>-<port2>, where <port1> and <port2> are ports and<port1> is smaller than <port2>.Examples of such rules would be147.188.193.0-147.188.194.255 21-22147.188.192.41 443Your server program should maximise the degree of concurrency and not containany memory leaks.
Submission and Marking ❼ You should submit the file server.c and client.c on the appropriatecanvas-quiz. The marking scripts will execute the command make with
the Makefile provided in the archive on canvas to 代写Operating Systems and Systems Programming produce all requiredbinaries.❼ The zip-archive on canvas contains a Makefile and a basic test script isprovided in thefiletest.sh. The Makefile and the test script will onlyork if server.c and client.c are in the same directory as the Makefiland the test script respectively. Thetesscript tests the cases of adding rule both interactively and via sockets. It is run by changing into theirectory containing the binaries and then running
./test.sWe will use more advanced scripts for marking which test all the specified
functionality, including concurrency and memory leaks. If the basic testscript does not work, all other scripts are likely to fail as well.
❼ Code which does not compile on the virtual machine provided will be
awarded 0 marks.Hints
❼ You should start by implementing the interactive version of the server(the version running with server -i) and the R-command. Sockets andconcurrency will be explained in later lectures.
3❼ You may use the code provided in the lectures in your assignments as yousee fit.4

浙公网安备 33010602011771号