Skip to content

Commit

Permalink
interface: Introduce methods to create and destroy instances.
Browse files Browse the repository at this point in the history
In order to eventually hide the implementation details of the interface,
users will need to be able to create and destroy instances thereof.  This
patch adds the needed methods.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
  • Loading branch information
richardcochran committed Mar 4, 2020
1 parent 21141a4 commit 5316a36
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,27 @@
* @note Copyright (C) 2020 Richard Cochran <richardcochran@gmail.com>
* @note SPDX-License-Identifier: GPL-2.0+
*/
#include <stdlib.h>
#include "interface.h"

struct interface *interface_create(const char *name)
{
struct interface *iface;

iface = calloc(1, sizeof(struct interface));
if (!iface) {
return NULL;
}
interface_set_name(iface, name);

return iface;
}

void interface_destroy(struct interface *iface)
{
free(iface);
}

void interface_ensure_tslabel(struct interface *iface)
{
if (!iface->ts_label[0]) {
Expand Down
13 changes: 13 additions & 0 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ struct interface {
struct sk_ts_info ts_info;
};

/**
* Creates an instance of an interface.
* @param name The device which indentifies this interface.
* @return A pointer to an interface instance on success, NULL otherwise.
*/
struct interface *interface_create(const char *name);

/**
* Destroys an instance of an interface.
* @param iface A pointer obtained via interface_create().
*/
void interface_destroy(struct interface *iface);

/**
* Ensures that an interface has a proper time stamping label.
* @param iface The interface of interest.
Expand Down

0 comments on commit 5316a36

Please sign in to comment.