| gclib 421 Communications API for Galil controllers and PLCs |

## ◆ GAssign()

GReturn GCALL GAssign | ( | GCStringIn | ip,
|  | GCStringIn | mac
| ) |  |

Uses GUtility(), G_UTIL_GCAPS_ASSIGN or G_UTIL_ASSIGN to assign an IP address over the Ethernet to a controller at a given MAC address.

Parameters

  ip | The null-terminated ip address to assign. The hardware should not yet have an IP address.
  mac | The null-terminated MAC address of the hardware.

Returns
  The success status or error code of the function. See gclib_errors.h for possible values.

On Linux and Mac, the desired IP address will be pinged prior to the assignment. If the ping is returned, GAssign() will return G_GCLIB_UTILITY_IP_TAKEN.

If gcaps is available, the assign will be performed from the server via G_UTIL_GCAPS_ASSIGN. In the absence of the server, gclib will use G_UTIL_ASSIGN to assign.

Attention
  When not using gcaps, Linux/OS X users must be root to use GAssign() and have UDP access to send on port 68.

Note
  GAssign() will take up to 1 second to look for gcaps.

See x_examples.cpp for an example.

Definition at line 66 of file gclibo.c.

References G_GCLIB_UTILITY_IP_TAKEN, G_NO_ERROR, G_UTIL_ASSIGN, G_UTIL_GCAPS_ASSIGN, G_UTIL_GCAPS_PING, G_UTIL_PING, and GUtility().