+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+#include <linux/can.h>
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include "canethgw.h"
+
+int main(int argc, char* argv[])
+{
+ int fd;
+ struct cegw_ioctl* gwctl = NULL;
+
+ gwctl = (struct cegw_ioctl*)malloc(sizeof(*gwctl) + sizeof(struct sockaddr_in));
+
+ /**/
+ fd = open("/dev/cegw", O_RDONLY);
+ if (fd == -1) {
+ fprintf(stderr, "error: could not open device file\n");
+ free(gwctl);
+ return -1;
+ }
+
+ gwctl->can_sock = 0;
+ gwctl->udp_sock = 0;
+ gwctl->udp_dstcnt = 0;
+ gwctl->udp_addrlen = sizeof(struct sockaddr_in);
+
+ if (ioctl(fd, CEGW_IOCTL_START, gwctl) != 0) {
+ fprintf(stderr, "error: ioctl call 1 failed\n");
+ } else
+ {
+ printf("ioctl call 1 OK\n");
+ }
+ close(fd);
+
+ /**/
+ fd = open("/dev/cegw", O_RDWR);
+ if (fd == -1) {
+ fprintf(stderr, "error: could not open device file\n");
+ free(gwctl);
+ return -1;
+ }
+
+ gwctl->can_sock = -1;
+ gwctl->udp_sock = -1;
+ gwctl->udp_dstcnt = 0;
+ gwctl->udp_addrlen = sizeof(struct sockaddr_in);
+
+ if (ioctl(fd, CEGW_IOCTL_START, gwctl) != 0) {
+ fprintf(stderr, "error: ioctl call 2 failed\n");
+ } else {
+ printf("ioctl call 2 OK\n");
+ }
+ close(fd);
+
+ free(gwctl);
+ return 0;
+}
+