libteam 1.31

Functions
Libteamdctl

## Functions
void | teamdctl_log (struct teamdctl *tdc, int priority, const char *file, int line, const char *fn, const char *format,...)
TEAMDCTL_EXPORT struct teamdctl * | teamdctl_alloc (void)
TEAMDCTL_EXPORT void | teamdctl_free (struct teamdctl *tdc)
TEAMDCTL_EXPORT void | teamdctl_set_log_fn (struct teamdctl *tdc, void(*log_fn)(struct teamdctl *tdc, int priority, const char *file, int line, const char *fn, const char *format, va_list args))
TEAMDCTL_EXPORT int | teamdctl_get_log_priority (struct teamdctl *tdc)
TEAMDCTL_EXPORT void | teamdctl_set_log_priority (struct teamdctl *tdc, int priority)
TEAMDCTL_EXPORT int | teamdctl_connect (struct teamdctl *tdc, const char *team_name, const char *addr, const char *cli_type)
TEAMDCTL_EXPORT void | teamdctl_disconnect (struct teamdctl *tdc)
TEAMDCTL_EXPORT int | teamdctl_refresh (struct teamdctl *tdc)
TEAMDCTL_EXPORT int | teamdctl_port_add (struct teamdctl *tdc, const char *port_devname)
TEAMDCTL_EXPORT int | teamdctl_port_remove (struct teamdctl *tdc, const char *port_devname)
TEAMDCTL_EXPORT int | teamdctl_port_config_update_raw (struct teamdctl *tdc, const char *port_devname, const char *port_config_raw)
TEAMDCTL_EXPORT int | teamdctl_port_config_get_raw_direct (struct teamdctl *tdc, const char *port_devname, char **p_cfg)
TEAMDCTL_EXPORT char * | teamdctl_config_get_raw (struct teamdctl *tdc)
TEAMDCTL_EXPORT int | teamdctl_config_get_raw_direct (struct teamdctl *tdc, char **p_cfg)
TEAMDCTL_EXPORT char * | teamdctl_config_actual_get_raw (struct teamdctl *tdc)
TEAMDCTL_EXPORT int | teamdctl_config_actual_get_raw_direct (struct teamdctl *tdc, char **p_cfg)
TEAMDCTL_EXPORT char * | teamdctl_state_get_raw (struct teamdctl *tdc)
TEAMDCTL_EXPORT int | teamdctl_state_get_raw_direct (struct teamdctl *tdc, char **p_cfg)
TEAMDCTL_EXPORT int | teamdctl_state_item_value_get (struct teamdctl *tdc, const char *item_path, char **p_value)
TEAMDCTL_EXPORT int | teamdctl_state_item_value_set (struct teamdctl *tdc, const char *item_path, const char *value)

## Detailed Description

Teamd daemon control library

## Header

#include <teamdctl.h>

## Function Documentation

## ◆ teamdctl_alloc()

TEAMDCTL_EXPORT struct teamdctl* teamdctl_alloc | ( | void |  | ) |

Allocates library context and does initial setup.

Returns
  New libteam library context.

## ◆ teamdctl_config_actual_get_raw()

TEAMDCTL_EXPORT char* teamdctl_config_actual_get_raw | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Gets raw actual config string. Using reply cache. Return value is never NULL. To refresh the cache, use teamdctl_refresh function. Note: the obtained string should not be modified or freed by caller.

Returns
  Pointer to cached actual config string.

## ◆ teamdctl_config_actual_get_raw_direct()

TEAMDCTL_EXPORT int teamdctl_config_actual_get_raw_direct | ( | struct teamdctl * | tdc,
|  | char ** | p_cfg
| ) |  |

Parameters

  tdc | libteamdctl library context
  p_cfg | pointer to string which will be set

Gets raw actual config string. Does direct method call avoiding possible stale data in the cache. Note: the obtained string should not be modified or freed by caller.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_config_get_raw()

TEAMDCTL_EXPORT char* teamdctl_config_get_raw | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Gets raw config string. Using reply cache. Return value is never NULL. To refresh the cache, use teamdctl_refresh function. Note: the obtained string should not be modified or freed by caller.

Return Pointer to cached config string.

## ◆ teamdctl_config_get_raw_direct()

TEAMDCTL_EXPORT int teamdctl_config_get_raw_direct | ( | struct teamdctl * | tdc,
|  | char ** | p_cfg
| ) |  |

Parameters

  tdc | libteamdctl library context
  p_cfg | pointer to string which will be set

Gets raw config string. Does direct method call avoiding possible stale data in the cache. Note: the obtained string should not be modified or freed by caller.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_connect()

TEAMDCTL_EXPORT int teamdctl_connect | ( | struct teamdctl * | tdc,
|  | const char * | team_name,
|  | const char * | addr,
|  | const char * | cli_type
| ) |  |

Parameters

  tdc | libteamdctl library context
  team_name | team device name
  addr | address (for zeromq only)
  cli_type | client type

Connect to teamd instance controlling team driver instance with interface name team_name. Use client type cli_type to connect. That can be either "dbus" for connection over D-Bus, "usock" which will use unix domain socket or NULL to select the type automatically.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_disconnect()

TEAMDCTL_EXPORT void teamdctl_disconnect | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Disconnect from teamd instance.

## ◆ teamdctl_free()

TEAMDCTL_EXPORT void teamdctl_free | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteam library context

Do library context cleanup.

## ◆ teamdctl_get_log_priority()

TEAMDCTL_EXPORT int teamdctl_get_log_priority | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Returns
  The current logging priority.

## ◆ teamdctl_log()

void teamdctl_log | ( | struct teamdctl * | tdc,
|  | int | priority,
|  | const char * | file,
|  | int | line,
|  | const char * | fn,
|  | const char * | format,
|  |  | ...
| ) |  |

SECTION: logging

## ◆ teamdctl_port_add()

TEAMDCTL_EXPORT int teamdctl_port_add | ( | struct teamdctl * | tdc,
|  | const char * | port_devname
| ) |  |

Parameters

  tdc | libteamdctl library context
  port_devname | port device name

Adds specified port to team.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_port_config_get_raw_direct()

TEAMDCTL_EXPORT int teamdctl_port_config_get_raw_direct | ( | struct teamdctl * | tdc,
|  | const char * | port_devname,
|  | char ** | p_cfg
| ) |  |

Parameters

  tdc | libteamdctl library context
  port_devname | port device name
  p_cfg | pointer to string which will be set

Gets raw port config string. Does direct method call avoiding possible stale data in the cache. Note: the obtained string should not be modified or freed by caller.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_port_config_update_raw()

TEAMDCTL_EXPORT int teamdctl_port_config_update_raw | ( | struct teamdctl * | tdc,
|  | const char * | port_devname,
|  | const char * | port_config_raw
| ) |  |

Parameters

  tdc | libteamdctl library context
  port_devname | port device name
  port_config_raw | port config

Update config for specified port.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_port_remove()

TEAMDCTL_EXPORT int teamdctl_port_remove | ( | struct teamdctl * | tdc,
|  | const char * | port_devname
| ) |  |

Parameters

  tdc | libteamdctl library context
  port_devname | port device name

Removes specified port from team.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_refresh()

TEAMDCTL_EXPORT int teamdctl_refresh | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Refresh cache.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_set_log_fn()

TEAMDCTL_EXPORT void teamdctl_set_log_fn | ( | struct teamdctl * | tdc,
|  | void(*)(struct teamdctl *tdc, int priority, const char *file, int line, const char *fn, const char *format, va_list args) | log_fn
| ) |  |

Parameters

  tdc | libteamdctl library context
  log_fn | function to be called for logging messages

The built-in logging writes to stderr. It can be overridden by a custom function, to plug log messages into the user's logging functionality.

## ◆ teamdctl_set_log_priority()

TEAMDCTL_EXPORT void teamdctl_set_log_priority | ( | struct teamdctl * | tdc,
|  | int | priority
| ) |  |

Parameters

  tdc | libteamdctl library context
  priority | the new logging priority

Set the current logging priority. The value controls which messages are logged.

## ◆ teamdctl_state_get_raw()

TEAMDCTL_EXPORT char* teamdctl_state_get_raw | ( | struct teamdctl * | tdc | ) |

Parameters

  tdc | libteamdctl library context

Gets raw state string. Using reply cache. Return value is never NULL. To refresh the cache, use teamdctl_refresh function. Note: the obtained string should not be modified or freed by caller.

Returns
  Pointer to cached state string.

## ◆ teamdctl_state_get_raw_direct()

TEAMDCTL_EXPORT int teamdctl_state_get_raw_direct | ( | struct teamdctl * | tdc,
|  | char ** | p_cfg
| ) |  |

Parameters

  tdc | libteamdctl library context
  p_cfg | pointer to string which will be set

Gets raw state string. Does direct method call avoiding possible stale data in the cache. Note: the obtained string should not be modified or freed by caller.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_state_item_value_get()

TEAMDCTL_EXPORT int teamdctl_state_item_value_get | ( | struct teamdctl * | tdc,
|  | const char * | item_path,
|  | char ** | p_value
| ) |  |

Parameters

  tdc | libteamdctl library context
  item_path | path to item
  p_value | pointer where reply string will be stored

Get state item value. Note that caller is responsible to free *p_value.

Returns
  Zero on success or negative number in case of an error.

## ◆ teamdctl_state_item_value_set()

TEAMDCTL_EXPORT int teamdctl_state_item_value_set | ( | struct teamdctl * | tdc,
|  | const char * | item_path,
|  | const char * | value
| ) |  |

Parameters

  tdc | libteamdctl library context
  item_path | path to item
  value | new value to be set

Set state item value.

Returns
  Zero on success or negative number in case of an error.