Skip to content

Network Abstraction Layer

nikosT edited this page Apr 12, 2011 · 19 revisions

This is the main page for the NAL module.


  • The early form of the api provided by Network Abstraction Layer follows:
int get_interfaces(struct info *p,int size)

Description: get_interfaces function provides info (name, address etc) on the interfaces that are available on the machine. Info for each interface is saved in a struct info record (struct info.... not yet!!!).

Arguments:
p is a pointer to allocated memory space (by the user) where struct info records are saved.
size shows the maximum number of records that can be saved to the allocated space.

Returns: The integer returned shows how many records have been saved to allocated space.

int enable(int interface_id)

Description: Function enable enables a specific interface.

Arguments: interface_id is the id of the interface. It can be obtained with get_interfaces function. Id will be a member of the struct info (hopefully...!!!)

Returns: The integer returned shows if the call was successful. Depending on the integer returned, type of possible errors can be determined. Numbers returned: (not known yet!!!)

int disable(int interface_id)

Description: Function disable disables a specific interface.

Arguments: interface_id is the id of the interface. It can be obtained with get_interfaces function. Id will be a member of the struct info (hopefully...!!!)

Returns: The integer returned shows if the call was successful. Depending on the integer returned, type of possible errors can be determined. Numbers returned: (not known yet!!!)

int send(int interface_id, struct addr* address, char *p, int size)

Description: Sends data to the address specified using a specific adapter.

Arguments:
interface_id is the id of the interface. It can be obtained with get_interfaces function. Id will be a member of the struct info (hopefully...!!!).
Address will be the address of the recipient...
Char pointer points to the data.
How many bytes is the data (how many bytes must be sent).

Returns: The number of bytes actually sent.

int receive(int interface_id, struct addr* address, char *p, int size)

Description: Receives data from the address specified using a specific adapter.

Arguments:
interface_id is the id of the interface. It can be obtained with get_interfaces function. Id will be a member of the struct info (hopefully...!!!).
Address will be the address of the sender...
Char pointer points to a buffer where received data will be saved.
How many bytes must be received.

Returns: The number of bytes actually received.

This function will not be present in the future. A callback register function will be implemented using Wiselib.

Please note that the address structure is still in debate with the other teams.
Using Wiselib, three radio interfaces will be implemented (each for every available interface - bluetooth,ethernet,wifi). This means that the form of the above functions will certainly change (for example, interface_id may not be needed).


Possible address structure for info about connection's establishment

(Network Abstraction Layer and ZeroConf Layer)

The NAL Team could provide as argument a struct addr* pointer to the NAL functions. The basic idea is to give out a more organized form and use only one argument for the connection's establishment (e.g. ip address, port etc). Also in case of a modification of the connection's variables, the argument stays as it is (at the NAL's functions) and the only thing that is being modified is the structure. The ZeroConf Team could fill this struct with the necessary infos and the NAL Team could use it for the sockets' setup.

struct addr {

	char ipv4_addr[16];	/* allocated string containing the ipv4 address */
	char ipv6_addr[40];	/* allocated string containing the ipv6 address */
	char mac_addr[18];	/* allocated string containing the mac (hex) address */

	/* possible other info
	about connection */

	/* it could also be used only
        one char[40] to contain the ip (for any interface)
        and not three */

	};