Sending raw ethernet packets
ronen%math.tau.ac.il at cunyvm.cuny.edu
ronen%math.tau.ac.il at cunyvm.cuny.edu
Thu Jun 29 18:13:24 AEST 1989
The following program was supposed to send a hand-made packet over the
ethernet. It completes with no errors, but does not seem to really send
anything. Am I misunderstanding something ?
I'm using Sun 3/160, SunOS 4.0.1.
Thank you for any help.
Ronen Friedman
ronen at math.tau.ac.il
ronen at taurus.bitnet
----------------------------------------------------
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/stropts.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/nit_pf.h>
#include <net/nit_if.h>
#include <net/nit_buf.h>
#include <stdio.h>
extern int errno;
char mess[] =
/* to: | from: */
"\011\000\053\000\000\017\252\000\004\000\376\005...............";
/* 191 more bytes of data ^^^^ */
main()
{
struct strioctl si;
struct ifreq ifr;
struct strbuf datam;
long if_fd;
if ((if_fd = open("/dev/nit",O_WRONLY)) < 0) {
perror("open: ");
exit(1);
}
/*
* configure the nit device, binding it
*/
strncpy(ifr.ifr_name, "ie0", sizeof ifr.ifr_name);
ifr.ifr_name[sizeof ifr.ifr_name - 1] = ' ';
si.ic_cmd = NIOCBIND;
si.ic_len = sizeof ifr;
si.ic_dp = (char *)𝔦
if (ioctl(if_fd, I_STR, (char *)&si) < 0) {
perror("bind: ");
exit(1);
}
/*
* sending the packet on the wire
*/
datam.maxlen = 203;
datam.len = 203;
datam.buf = mess;
if (putmsg(if_fd, NULL, &datam, 0) != 0) {
perror("putmsg :");
exit(1);
}
}
More information about the Comp.sys.sun
mailing list