What is the equivalent in 6.1 of:
include <sys/types.h>
#include <sys/socket.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
int s; // socket descriptor
int length;
int main(int argc, char *argv[]) {
// buffer fpr ethernet frames
void buffer = (void)malloc(2000); // must be > than ethernet packet
size
// pointer to ethernet header
unsigned char* etherhead = buffer;
// userdata in erthernet frame
unsigned char* data = buffer+14;
// create the socket
s = socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if (s == -1) printf(“OOPS - RAW SOCKET DIDNT CREATE\n”);
while (1) {
length = recvfrom(s,buffer,ETH_FRAME_LEN,0,NULL,NULL);
[
.
some data manipulation code here
.
]
}
return -1;
}
\
Using Opera’s revolutionary e-mail client: http://www.opera.com/m2/
There’s no direct equivalent. You could write
an ethernet filter that sits between the stack
and driver and intercept packets there.
-seanb
inn.qnx.com <acellarius@yah0o.lsd.com> wrote:
What is the equivalent in 6.1 of:
include <sys/types.h
#include <sys/socket.h
#include <linux/if_packet.h
#include <linux/if_ether.h
#include <linux/if_arp.h
#include <stdio.h
#include <string.h
#include <sys/time.h
int s; // socket descriptor
int length;
int main(int argc, char *argv[]) {
// buffer fpr ethernet frames
void buffer = (void)malloc(2000); // must be > than ethernet packet
size
// pointer to ethernet header
unsigned char* etherhead = buffer;
// userdata in erthernet frame
unsigned char* data = buffer+14;
// create the socket
s = socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL));
if (s == -1) printf(“OOPS - RAW SOCKET DIDNT CREATE\n”);
while (1) {
length = recvfrom(s,buffer,ETH_FRAME_LEN,0,NULL,NULL);
[
.
some data manipulation code here
.
]
}
return -1;
}
Using Opera’s revolutionary e-mail client: > http://www.opera.com/m2/