[package] busybox: implement ms static routes option in udhcpc (#6435)
[openwrt.git] / package / libtapi / src / tapi-stream.c
1 #include <errno.h>
2 #include <fcntl.h>
3 #include <stdbool.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <unistd.h>
7
8 #include "tapi-device.h"
9 #include "tapi-stream.h"
10 #include "tapi-ioctl.h"
11
12 struct tapi_stream *tapi_stream_alloc(struct tapi_device *dev)
13 {
14 struct tapi_stream *stream;
15
16 stream = malloc(sizeof(*stream));
17 if (!stream)
18 return NULL;
19
20 stream->fd = open(dev->stream_path, O_RDWR);
21
22 if (stream->fd < 0) {
23 free(stream);
24 return NULL;
25 }
26
27 stream->ep = ioctl(stream->fd, TAPI_STREAM_IOCTL_GET_ENDPOINT, 0);
28
29 if (stream->ep < 0) {
30 close(stream->fd);
31 free(stream);
32 return NULL;
33 }
34
35 return stream;
36 }
37
38 void tapi_stream_free(struct tapi_stream *stream)
39 {
40 close(stream->fd);
41 free(stream);
42 }
This page took 0.056091 seconds and 5 git commands to generate.