Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / ipfilter / ipsend / hpux.c
1 /*
2  * (C)opyright 1997-1998 Darren Reed. (from tcplog)
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  */
6 #include <stdio.h>
7 #include <strings.h>
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include <sys/types.h>
11 #include <sys/param.h>
12 #include <sys/socket.h>
13 #include <sys/file.h>
14 #include <sys/ioctl.h>
15
16
17 int     initdevice(device, sport, tout)
18 char    *device;
19 int     sport, tout;
20 {
21         int     fd;
22
23         if ((fd = socket(AF_DLI, SOCK_RAW, 0)) == -1)
24                 perror("socket");
25         return fd;
26 }
27
28
29 /*
30  * output an IP packet onto a fd opened for /dev/bpf
31  */
32 int     sendip(fd, pkt, len)
33 int     fd, len;
34 char    *pkt;
35 {                       
36         if (send(fd, pkt, len, 0) == -1)
37             {
38                 perror("send");
39                 return -1;
40             }
41
42         return len;
43 }
44
45
46 char *strdup(str)
47 char *str;
48 {
49         char    *s;
50
51         if ((s = (char *)malloc(strlen(str) + 1)))
52                 return strcpy(s, str);
53         return NULL;
54 }
55 /*
56  * (C)opyright 1997 Darren Reed. (from tcplog)
57  *
58  * Redistribution and use in source and binary forms are permitted
59  * provided that this notice is preserved and due credit is given
60  * to the original author and the contributors.
61  */
62 #include <stdio.h>
63 #include <strings.h>
64 #include <unistd.h>
65 #include <stdlib.h>
66 #include <sys/types.h>
67 #include <sys/param.h>
68 #include <sys/socket.h>
69 #include <sys/file.h>
70 #include <sys/ioctl.h>
71
72
73 int     initdevice(device, sport, tout)
74 char    *device;
75 int     sport, tout;
76 {
77         int     fd;
78
79         if ((fd = socket(AF_DLI, SOCK_RAW, 0)) == -1)
80                 perror("socket");
81         return fd;
82 }
83
84
85 /*
86  * output an IP packet onto a fd opened for /dev/bpf
87  */
88 int     sendip(fd, pkt, len)
89 int     fd, len;
90 char    *pkt;
91 {                       
92         if (send(fd, pkt, len, 0) == -1)
93             {
94                 perror("send");
95                 return -1;
96             }
97
98         return len;
99 }
100
101
102 char *strdup(str)
103 char *str;
104 {
105         char    *s;
106
107         if ((s = (char *)malloc(strlen(str) + 1)))
108                 return strcpy(s, str);
109         return NULL;
110 }