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