]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - test/tst-raw-sendto.c
Add kernel version depency for Kernel 3.1.x which extended __rtnl_register().
[socketcan-devel.git] / test / tst-raw-sendto.c
index 7b91fb29d1ba8244c27494881219c653b23a2fb3..257a96267f751316f7a8edde34ad1567a0f5acc6 100644 (file)
@@ -12,8 +12,7 @@
  * modification, are permitted provided that the following conditions
  * are met:
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, the following disclaimer and
- *    the referenced file 'COPYING'.
+ *    notice, this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
@@ -23,8 +22,8 @@
  *
  * Alternatively, provided that this notice is retained in full, this
  * software may be distributed under the terms of the GNU General
- * Public License ("GPL") version 2 as distributed in the 'COPYING'
- * file from the main directory of the linux kernel source.
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
  *
  * The provided data structures and external interfaces from this code
  * are not restricted to be used by modules with a GPL compatible license.
 
 int main(int argc, char **argv)
 {
-    int s;
-    struct sockaddr_can addr;
-    struct can_frame frame;
-    int nbytes;
-    struct ifreq ifr;
-    char *ifname = "vcan2";
-    int ifindex;
-    int opt;
+       int s;
+       struct sockaddr_can addr;
+       struct can_frame frame;
+       struct ifreq ifr;
+       char *ifname = "vcan2";
+       int ifindex;
+       int opt;
 
-    while ((opt = getopt(argc, argv, "i:")) != -1) {
-        switch (opt) {
-        case 'i':
-           ifname = optarg;
-            break;
-        default:
-            fprintf(stderr, "Unknown option %c\n", opt);
-            break;
-        }
-    }
+       while ((opt = getopt(argc, argv, "i:")) != -1) {
+               switch (opt) {
+               case 'i':
+                       ifname = optarg;
+                       break;
+               default:
+                       fprintf(stderr, "Unknown option %c\n", opt);
+                       break;
+               }
+       }
 
 
-    if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
-      perror("socket");
-      return 1;
-    }
+       if ((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
+               perror("socket");
+               return 1;
+       }
 
-    strcpy(ifr.ifr_name, ifname);
-    ioctl(s, SIOCGIFINDEX, &ifr);
-    ifindex = ifr.ifr_ifindex;
+       strcpy(ifr.ifr_name, ifname);
+       ioctl(s, SIOCGIFINDEX, &ifr);
+       ifindex = ifr.ifr_ifindex;
 
-    addr.can_family  = AF_CAN;
-    addr.can_ifindex = 0; /* bind to all interfaces */
+       addr.can_family  = AF_CAN;
+       addr.can_ifindex = 0; /* bind to all interfaces */
  
-    if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-      perror("bind");
-      return 1;
-    }
+       if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+               perror("bind");
+               return 1;
+       }
 
 
-    /* fill CAN frame */
-    frame.can_id  = 0x123;
-    frame.can_dlc = 3;
-    frame.data[0] = 0x11;
-    frame.data[1] = 0x22;
-    frame.data[2] = 0x33;
+       /* fill CAN frame */
+       frame.can_id  = 0x123;
+       frame.can_dlc = 3;
+       frame.data[0] = 0x11;
+       frame.data[1] = 0x22;
+       frame.data[2] = 0x33;
 
-    addr.can_family  = AF_CAN;
-    addr.can_ifindex = ifindex; /* send via this interface */
+       addr.can_family  = AF_CAN;
+       addr.can_ifindex = ifindex; /* send via this interface */
  
-    nbytes = sendto(s, &frame, sizeof(struct can_frame), 0, (struct sockaddr*)&addr, sizeof(addr));
+       sendto(s, &frame, sizeof(struct can_frame), 0, (struct sockaddr*)&addr, sizeof(addr));
 
-    close(s);
+       close(s);
 
-    return 0;
+       return 0;
 }