#define included_clib_file_h
#include <vppinfra/socket.h>
+#include <vppinfra/pool.h>
#include <termios.h>
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE (1 << 0)
#define UNIX_FILE_EVENT_EDGE_TRIGGERED (1 << 1)
+ /* polling thread index */
+ u32 polling_thread_index;
+
/* Data available for function's use. */
uword private_data;
/* Functions to be called when read/write data becomes ready. */
clib_file_function_t *read_function, *write_function, *error_function;
+
+ /* Description */
+ u8 *description;
+
+ /* Stats */
+ u64 read_events;
+ u64 write_events;
+ u64 error_events;
} clib_file_t;
typedef enum
clib_file_t *f;
pool_get (um->file_pool, f);
f[0] = template[0];
+ f->read_events = 0;
+ f->write_events = 0;
+ f->error_events = 0;
um->file_update (f, UNIX_FILE_UPDATE_ADD);
return f - um->file_pool;
}
um->file_update (f, UNIX_FILE_UPDATE_DELETE);
close (f->file_descriptor);
f->file_descriptor = ~0;
+ vec_free (f->description);
pool_put (um->file_pool, f);
}
clib_file_del (um, uf);
}
+always_inline void
+clib_file_set_polling_thread (clib_file_main_t * um, uword index,
+ u32 thread_index)
+{
+ clib_file_t *f = pool_elt_at_index (um->file_pool, index);
+ um->file_update (f, UNIX_FILE_UPDATE_DELETE);
+ f->polling_thread_index = thread_index;
+ um->file_update (f, UNIX_FILE_UPDATE_ADD);
+}
+
always_inline uword
clib_file_set_data_available_to_write (clib_file_main_t * um,
u32 clib_file_index,
return pool_elt_at_index (fm->file_pool, file_index);
}
+always_inline clib_error_t *
+clib_file_write (clib_file_t * f)
+{
+ f->write_events++;
+ return f->write_function (f);
+}
+
#endif /* included_clib_file_h */
/*