/******************************************/ /* transport.h 0.4.1 (1999-Dec-15-Wed) */ /* Adam M. Costello */ /******************************************/ /* Interface to the transport layer, which conforms to */ /* the interface of bytestream.h 0.2.x. All functions */ /* declared here are implemented by the transport layer */ /* (in transport.c), and get called by other entities. */ /* This is ANSI C code. */ #ifndef TRANSPORT_H #define TRANSPORT_H #include #include "bytestream.h" #include "network.h" enum transport_extension_flags { transport_flow_control_efficiency = 4, transport_multiplexing = 1, transport_congestion_control = 2 }; enum transport_extension_flags transport_extensions(void); /* Returns 0 for the basic project, or the bitwise OR of the */ /* flags indicating which extensions have been implemented. */ struct transport_endpoint { struct network_address address; unsigned short port; /* Always in the range 0..0xffff. */ }; struct transport_connection { struct transport_endpoint source; struct transport_endpoint sink; }; /* transport source methods: */ void *transport_source_create(const struct network_address source_address); /* Creates a transport source, which is an entity that provides */ /* one-way outgoing reliable bytestream connections. There is at */ /* most one transport source per host (and in this simulation, */ /* only one network address per host). The pointer returned is */ /* private to the transport layer, and will be blindly passed */ /* back in to the other transport_source_* functions. We will */ /* call this function only once per simulation process, though */ /* you may wish to support multiple transport sources in the same */ /* process for your own testing. */ void transport_source_create_connection( void *transport_source, struct transport_connection connection, void *byte_source, bytestream_go_ahead_method *go_ahead, size_t buffer_max ); /* Creates state for an outgoing connection. After this */ /* function is called, data bytes will arrive from byte_source */ /* via transport_source_receive_bytes() (see below). In the */ /* communication between the byte source and the transport */ /* source, the transport source acts as a byte sink, so it */ /* must call go_ahead(byte_source,transport_source) at the */ /* appropriate times (see bytestream.h). There is a distinct */ /* byte_source for each open connection. If flow control is */ /* supported, the transport source must not buffer more than */ /* buffer_max unacknowledged data bytes for this connection */ /* (it must refuse additional bytes from the byte source */ /* until some more of the buffered data is acknowledged). */ /* Unlike a real transport layer, this one is not expected to */ /* do connection setup; it may assume that the appropriate */ /* connection state will automagically be set up at the other */ /* end. If the multiplexing extension is not supported, this */ /* function will not be called if an outgoing connection */ /* already exists at this transport source. */ void transport_source_delete_connection( void *transport_source, void *byte_source ); /* Deletes state for an outgoing connection. After this function */ /* is called no more data bytes will arrive from the byte source. */ /* Unlike a real transport layer, this one is not expected to do */ /* connection teardown; it may assume that the connection state */ /* will automagically be deleted at the other end, and may even */ /* discard unacknowledged data. */ bytestream_transfer_method transport_source_receive_bytes; /* See bytestream.h. The sink and source */ /* are the tranport_source and byte_source */ /* (respectively) that were passed to */ /* transport_source_create_connection(). */ void transport_source_receive_packet( void *transport_source, struct network_packet packet ); /* Delivers a network-layer packet to the transport source, which */ /* must be able to ignore unexpected packets caused by corruption */ /* or misrouting. The payload memory is valid only until this */ /* function returns, so it must be copied if it is needed after */ /* that. */ /* transport sink methods: */ void *transport_sink_create(const struct network_address sink_address); /* Creates a transport sink, which is an entity that provides */ /* one-way incoming reliable bytestream connections. There is */ /* at most one transport sink per host (and in this simulation, */ /* at most one network address per host). The pointer returned */ /* is private to the transport layer, and will be blindly passed */ /* back in to the other transport_sink_* functions. We will call */ /* this function only once per simulation process, though you may */ /* wish to support multiple transport sources in the same process */ /* for your own testing. */ void transport_sink_create_connection( void *transport_sink, struct transport_connection connection, void *byte_sink, bytestream_transfer_method *transfer, size_t buffer_max ); /* Creates state for an incoming connection. After this */ /* function is called, the transport sink should deliver data */ /* arriving from the transport source to byte_sink, by calling */ /* transfer(byte_sink,transport_sink,...) at appropriate times */ /* (see bytestream.h). In the communication between the */ /* transport sink and the byte sink, the transport sink acts as */ /* a byte source. If flow control is supported, the transport */ /* sink must not buffer more than buffer_max acknowledged */ /* undelivered data bytes (additional incoming bytes may be */ /* dropped or buffered, but must not be acknowledged until the */ /* byte sink has accepted some more of the buffered data). The */ /* value of buffer_max is not necessarily the same for both ends */ /* of a connection. Unlike a real transport layer, this one */ /* is not expected to do connection setup; it may assume that */ /* the appropriate connection state will automagically be set */ /* up at the other end. If the multiplexing extension is not */ /* supported, this function will not be called if an incoming */ /* connection already exists at this transport sink. */ void transport_sink_delete_connection( void *transport_sink, void *byte_sink ); /* Deletes state for an incoming connection. After this function */ /* is called no more data bytes will arrive from the byte source. */ /* Unlike a real transport layer, this one is not expected to do */ /* connection teardown; it may assume that the connection state */ /* will automagically be deleted at the other end, and may even */ /* discard undelivered data. */ bytestream_go_ahead_method transport_sink_okay_to_deliver; /* See bytestream.h. The source and sink are the */ /* transport_sink and byte_sink (respectively) that */ /* were passed to transport_sink_create_connection(). */ void transport_sink_receive_packet( void *transport_sink, struct network_packet packet ); /* Delivers a network-layer packet to the transport sink, which */ /* must be able to ignore unexpected packets caused by corruption */ /* or misrouting. The payload memory is valid only until this */ /* function returns, so it must be copied if it is needed after */ /* that. */ #endif /* TRANSPORT_H */