summaryrefslogtreecommitdiffstats
path: root/src/fcp.c
diff options
context:
space:
mode:
authorGravatar aeb 2000-03-16 03:40:52 +0000
committerGravatar aeb 2000-03-16 03:40:52 +0000
commit227464b31ce04e1ceba51067b500ebbe54b2c08f (patch)
tree4414d7778310d0b663a719079dc794f656f22d2d /src/fcp.c
parentRemoved obsolete AC_PROG_RANLIB. (diff)
Added FCP listen functionality.
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@12 53a565d1-3bb7-0310-b661-cf11e63c67ab
Diffstat (limited to 'src/fcp.c')
-rw-r--r--src/fcp.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/fcp.c b/src/fcp.c
new file mode 100644
index 0000000..e3c0800
--- /dev/null
+++ b/src/fcp.c
@@ -0,0 +1,53 @@
+
+#include <errno.h>
+#include <unistd.h>
+
+#include "raw1394.h"
+#include "kernel-raw1394.h"
+#include "raw1394_private.h"
+
+static int do_fcp_listen(struct raw1394_handle *handle)
+{
+ struct sync_cb_data sd = { 0, 0 };
+ struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
+ int err;
+ struct raw1394_request *req = &handle->req;
+
+ CLEAR_REQ(req);
+ req->type = RAW1394_REQ_FCP_LISTEN;
+ req->generation = handle->generation;
+ req->misc = 0;
+ req->tag = (unsigned long)&rh;
+ req->recvb = handle->buffer;
+ req->length = 512;
+
+ err = write(handle->fd, req, sizeof(*req));
+ while (!sd.done) {
+ if (err < 0) return err;
+ err = raw1394_loop_iterate(handle);
+ }
+
+ switch (sd.errcode) {
+ case RAW1394_ERROR_ALREADY:
+ errno = EALREADY;
+ return -1;
+
+ case RAW1394_ERROR_INVALID_ARG:
+ errno = EINVAL;
+ return -1;
+
+ default:
+ errno = 0;
+ return sd.errcode;
+ }
+}
+
+int raw1394_start_fcp_listen(struct raw1394_handle *handle)
+{
+ return do_fcp_listen(handle);
+}
+
+int raw1394_stop_fcp_listen(struct raw1394_handle *handle)
+{
+ return do_fcp_listen(handle);
+}