Last active
March 1, 2016 17:49
-
-
Save RicardoLara/0a83455dbe37cc934113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
struct sockaddr_ll { | |
unsigned short sll_family; /* Always AF_PACKET */ | |
//unsigned short sll_protocol; /* Physical layer protocol */ | |
//int sll_ifindex; /* Interface number */ | |
//unsigned short sll_hatype; /* ARP hardware type */ | |
//unsigned char sll_pkttype; /* Packet type */ | |
//unsigned char sll_halen; /* Length of address */ | |
//unsigned char sll_addr[8]; /* Physical layer address */ | |
//}; */ | |
/* | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
int socket(int domain, int type, int protocol); | |
*/ | |
/* | |
LO IMPORTANTE Y QUE LEIMOS | |
SOCK_STREAM(TCP) | |
AF_INET { } | |
SOCK_DGRAM(UDP) | |
SOCK_RAW(Enlace) | |
AF_PACKET{ } | |
SOCK_DGRAM(Red) | |
*/ | |
#include <sys/socket.h> | |
#include <linux/if_packet.h> | |
#include <net/ethernet.h> | |
#include <stdio.h> | |
//Para Htons | |
#include <arpa/inet.h> | |
//Para close | |
#include <unistd.h> | |
int main(){ | |
int packet_socket; | |
packet_socket = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); | |
if(packet_socket == -1) perror("Error en Socket\n"); | |
else perror("Exito al abrirlo, paps\n"); | |
close(packet_socket); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment