]> rtime.felk.cvut.cz Git - can-eth-gw.git/blobdiff - utils/cegw/cegw.c
Use perror() to print error messages
[can-eth-gw.git] / utils / cegw / cegw.c
index a0b5259ee6f89dbf7cf716c2efcb09989712cbcf..0efadc22f32678d0694ce4388929fb64c947e57d 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * 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>
@@ -125,7 +141,7 @@ int main(int argc, char* argv[])
        }
 
        if (argc < 4) {
-               perr("not enought arguments");
+               perr("not enough arguments");
                printf(help_msg, argv[0], argv[0]);
                /* ToDo: print usage */
                return -1;
@@ -171,13 +187,13 @@ int main(int argc, char* argv[])
        /* 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;
        }
@@ -185,21 +201,21 @@ int main(int argc, char* argv[])
        /* 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;
        }
@@ -224,4 +240,3 @@ int main(int argc, char* argv[])
 
        return 0;
 }
-