+/*
+ * Copyright: (c) 2012 Czech Technical University in Prague
+ *
+ * Authors:
+ * Radek Matějka <radek.matejka@gmail.com>
+ * Michal Sojka <sojkam1@fel.cvut.cz>
+ *
+ * Funded by: Volkswagen Group Research
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}
if (argc < 4) {
- perr("not enought arguments");
+ perr("not enough arguments");
printf(help_msg, argv[0], argv[0]);
/* ToDo: print usage */
return -1;
/* prepare udp socket */
udp_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (udp_sock == -1) {
- fprintf(stderr, "error: udp socket(..) failed\n");
+ perror("udp socket()");
free(gwctl);
return -1;
}
if (bind(udp_sock, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr_in)) != 0) {
- fprintf(stderr, "error: udp bind(..) failed\n");
+ perror("bind(udp)");
free(gwctl);
return -1;
}
/* prepare can socket */
can_sock = socket(PF_CAN, SOCK_RAW, CAN_RAW);
if (can_sock == -1) {
- fprintf(stderr, "error: can socket(..) failed\n");
+ perror("can socket()");
free(gwctl);
return -1;
}
if (bind(can_sock, (struct sockaddr *)&can_addr, sizeof(struct sockaddr_can)) != 0) {
- fprintf(stderr, "error: can bind(..) failed\n");
+ perror("bind(can)");
free(gwctl);
return -1;
}
/* send it to kernel gateway */
- fd = open("/dev/cegw", O_RDONLY);
+ fd = open("/dev/canethgw", O_RDONLY);
if (fd == -1) {
- fprintf(stderr, "error: could not open device file\n");
+ perror("/dev/canethgw");
free(gwctl);
return -1;
}
return 0;
}
-