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 21int initdevice(device, sport, tout) 22char *device; 23int 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 */ 36int sendip(fd, pkt, len) 37int fd, len; 38char *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 50char *strdup(str) 51char *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 77int initdevice(device, sport, tout) 78char *device; 79int 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 */ 92int sendip(fd, pkt, len) 93int fd, len; 94char *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 106char *strdup(str) 107char *str; 108{ 109 char *s; 110 111 if ((s = (char *)malloc(strlen(str) + 1))) 112 return strcpy(s, str); 113 return NULL; 114} 115