Table of Contents

Name

linx_create_eth_link() - creates an Ethernet link
linx_destroy_eth_link() - destroys an Ethernet link

Synopsis

#include <linxcfg.h>

int linx_create_eth_link(char *name, char *mac, char *ifc, unsigned long window_size, unsigned long defer_queue_size, unsigned long send_tmo, unsigned long nack_tmo, unsigned long conn_tmo, unsigned long live_tmo);

int linx_destroy_eth_link(char *name);

Description

The calls linx_create_eth_link() and linx_destroy_eth_link() creates and destroys links between two unique Ethernet interfaces that are present in the same subnet. A link is considered up when both sides have done linx_create_eth_link() to each others Ethernet interfaces. A link is identified by its name which is assigned by the parameter name. The name is local to the node so different nodes can have the same name to the same remote interface. The MAC address to the remote interface is given in mac in the form of a character string, i.e. "00:10:4A:0F:AB:00". The ifc parameter is used to specify which interface the link shall use.

The following options are not mandatory. If 0 is given, default values will be used.

The send and receive sliding window size is set by window_size, the window size shall always be of a power of 2. Default window size is 128 and it should be sufficient for most configurations. Both sides must use the same window_size.

A defer queue is used on the sender side when the send window is full, every message sent when the send window is full is stored in a defer queue until the send window has room for more messages. The defer_queue parameter specifies the maximum number of messages that can be stored in the defer queue before the link is disconnected due to lack of resources. The default size is 2048 and it should be sufficient for most systems.

The send_tmo timeout specifies the time to wait until unacked messages are resent (in msec). Default timeout is 10msec and it should be sufficient for most systems.

The nack_tmo timeout specifies the time to wait until nack messages are resent (in msec). The default timeout of 20msec should be sufficient for most systems.

The conn_tmo timeout specifies the time to wait (in msec) until the establishment of a connection is considered failed. The default value of 200msec should be sufficient in most systems.

The live_tmo parameter specifies the time to wait until a connection is considered broken. The default timeout of 100msec (when the system is not idle) should be sufficient for most systems. When the system is idle, the live timeout is ten times larger than the configured live timeout value.


Return Value

Returns zero if successful, otherwise -1 is returned and errno is set.

Errors


EINVAL if name, mac or ifc are NULL.

ENOBUFS or ENOMEM if there is not enough memory.

EPROTONOSUPPORT or EAFNOSUPPORT if linx(7) is not supported by the system.

ENFILE Not enough kernel memory to allocate a new LINX socket.

EMFILE Process file table overflow.

EACCES Permission to create a LINX socket is denied.

Bugs/Limitations

Several links can be created to and from an Ethernet interface but only one link is allowed between two unique interfaces, for instance, interface A can have two links to interface B and C but A cannot have two links to interface B.

Notes

In the future, linx_create_eth_link() and linx_destroy_eth_link() will be replaced by two generic function calls, linx_create_link() and linx_destroy_link().

Example

In this example a link is created to nodeB.


#include <linx.h>
#include <linxcfg.h>
int
main(int argc, char *argv[]) {
  int rv;
  const LINX_SIGSELECT sel_hunt_sig[] = { 1, LINX_OS_HUNT_SIG };
  /* Create a link to the ethernet interface with the MAC
   * address of 00:01:02:03:04:05, use the local interface
   * eth0 for the link and default values for all parameters. */
  rv = linx_create_eth_link("link_to_nodeB", "00:01:02:03:04:05", "eth0",
0, 0, 0, 0, 0, 0);
  if(rv != 0) {
    /* Link was not created */
    return -1;
  }
  /* Link was created, now we can use the link. */
  /* Open a LINX endpoint */
  linx = linx_open("myproc", 0, NULL);
  /* Hunt for process hisproc over the link */
  linx_hunt(linx, "link_to_nodeB/hisproc", NULL);
  /* This hunt will resolve first AFTER the other side has
   * done a linx_create_eth_link to us! */
  linx_receive(linx, &sig, sel_hunt_sig);
  linx_close(linx);
  /* Destroy the link */
  rv = linx_destroy_eth_link("link_to_nodeB");
}

See Also

linx(7) , linx_create_tcp_link(3) , linx_destroy_tcp_link(3)

Author

Enea LINX team

Copyright

Copyright (c) 2006-2008, Enea Software AB All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Enea Software AB nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Table of Contents