On 05/18/2012 12:38 PM, Sean Bruno wrote:
---
src/drv_fbsd.c | 15 ++++++---------
src/dutil_fbsd.h | 9 +++++++++
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/drv_fbsd.c b/src/drv_fbsd.c
index 0ae2b8e..9770ed0 100644
--- a/src/drv_fbsd.c
+++ b/src/drv_fbsd.c
@@ -72,8 +72,8 @@ static int list_interfaces(struct netcf *ncf, char ***intf) {
/* Look for all interfaces */
hackery = popen("r+","ifconfig|grep flags|awk '{print $1}'|wc
-l"); // HACKERY
The run_program() function (currently in dutil_linux.c, but probably
should be moved to a file with a more generic name) will run a program
and save the combination of stdout + stderr into a char*. Using that
might be a bit less "hackish".
- read(&nint, sizeof(nint), 1, hackery);
- printf ("nint == %d\n");
+ fread(&nint, sizeof(nint), 1, hackery);
+ printf ("nint == %d\n", nint);
(obviously you'll want to remove any debug printf's before you push an
official port)
pclose(hackery);
ERR_BAIL(ncf);
result = nint;
@@ -144,8 +144,8 @@ int drv_num_of_interfaces(struct netcf *ncf, unsigned int flags) {
struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
- int result;
+ printf("%s: attempted to lookup %s\n", __func__, name);
ERR_THROW(1 == 1, ncf, EOTHER, "not implemented on this platform");
error:
return NULL;
@@ -175,11 +175,10 @@ error:
struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str ATTRIBUTE_UNUSED) {
- int result = 0;
ERR_THROW(1 == 1, ncf, EOTHER, "not implemented on this platform");
error:
- return result;
+ return NULL;
}
int drv_undefine(struct netcf_if *nif) {
@@ -192,19 +191,17 @@ error:
char *drv_xml_desc(struct netcf_if *nif) {
- int result = 0;
ERR_THROW(1 == 1, nif->ncf, EOTHER, "not implemented on this
platform");
error:
- return result;
+ return NULL;
}
char *drv_xml_state(struct netcf_if *nif) {
- int result = 0;
ERR_THROW(1 == 1, nif->ncf, EOTHER, "not implemented on this
platform");
error:
- return result;
+ return NULL;
}
int drv_if_status(struct netcf_if *nif, unsigned int *flags ATTRIBUTE_UNUSED) {
diff --git a/src/dutil_fbsd.h b/src/dutil_fbsd.h
index 6409099..73b71ad 100644
--- a/src/dutil_fbsd.h
+++ b/src/dutil_fbsd.h
@@ -20,3 +20,12 @@ struct driver {
unsigned int augeas_xfm_num_tables;
const struct augeas_xfm_table **augeas_xfm_tables;
};
+
+/* Get or create the augeas instance from NCF */
+struct augeas *get_augeas(struct netcf *ncf);
+
+/* Free matches from aug_match (or aug_submatch) */
+void free_matches(int nint, char ***intf);
+
+/* Check if the interface INTF is up using an ioctl call */
+int if_is_active(struct netcf *ncf, const char *intf);
This is another example of a function that could/should be moved (along
with run_program) into a more generically named util file.