Diff for /embedaddon/libnet/src/libnet_write.c between versions 1.1 and 1.1.1.2

version 1.1, 2012/02/21 22:14:23 version 1.1.1.2, 2013/07/22 11:54:42
Line 32 Line 32
  *   *
  */   */
   
   #include <netinet/in.h>
   #include <sys/types.h>
   #include <netinet/udp.h>
   
 #if (HAVE_CONFIG_H)  #if (HAVE_CONFIG_H)
 #include "../include/config.h"  #include "../include/config.h"
 #endif  #endif
Line 48  int Line 52  int
 libnet_write(libnet_t *l)  libnet_write(libnet_t *l)
 {  {
     int c;      int c;
    u_int32_t len;    uint32_t len;
    u_int8_t *packet = NULL;    uint8_t *packet = NULL;
   
     if (l == NULL)      if (l == NULL)
     {       { 
Line 125  done: Line 129  done:
   
 #if defined (__WIN32__)  #if defined (__WIN32__)
 libnet_ptag_t  libnet_ptag_t
libnet_win32_build_fake_ethernet(u_int8_t *dst, u_int8_t *src, u_int16_t type,libnet_win32_build_fake_ethernet(uint8_t *dst, uint8_t *src, uint16_t type,
u_int8_t *payload, u_int32_t payload_s, u_int8_t *packet, libnet_t *l,uint8_t *payload, uint32_t payload_s, uint8_t *packet, libnet_t *l,
 libnet_ptag_t ptag)  libnet_ptag_t ptag)
 {  {
     struct libnet_ethernet_hdr eth_hdr;      struct libnet_ethernet_hdr eth_hdr;
Line 154  libnet_ptag_t ptag) Line 158  libnet_ptag_t ptag)
 }  }
   
 libnet_ptag_t  libnet_ptag_t
libnet_win32_build_fake_token(u_int8_t *dst, u_int8_t *src, u_int16_t type,libnet_win32_build_fake_token(uint8_t *dst, uint8_t *src, uint16_t type,
u_int8_t *payload, u_int32_t payload_s, u_int8_t *packet, libnet_t *l,uint8_t *payload, uint32_t payload_s, uint8_t *packet, libnet_t *l,
 libnet_ptag_t ptag)  libnet_ptag_t ptag)
 {  {
     struct libnet_token_ring_hdr token_ring_hdr;      struct libnet_token_ring_hdr token_ring_hdr;
Line 188  libnet_ptag_t ptag) Line 192  libnet_ptag_t ptag)
     return (1);      return (1);
 }  }
   
   
 int  int
libnet_win32_write_raw_ipv4(libnet_t *l, u_int8_t *payload, u_int32_t payload_s)libnet_win32_write_raw_ipv4(libnet_t *l, const uint8_t *payload, uint32_t payload_s)
 {      {    
     static BYTE dst[ETHER_ADDR_LEN];      static BYTE dst[ETHER_ADDR_LEN];
     static BYTE src[ETHER_ADDR_LEN];      static BYTE src[ETHER_ADDR_LEN];
                   
    u_int8_t *packet      = NULL;    uint8_t *packet      = NULL;
    u_int32_t packet_s;    uint32_t packet_s;
   
     LPPACKET lpPacket   = NULL;      LPPACKET lpPacket   = NULL;
     DWORD remoteip      = 0;      DWORD remoteip      = 0;
Line 208  libnet_win32_write_raw_ipv4(libnet_t *l, u_int8_t *pay Line 211  libnet_win32_write_raw_ipv4(libnet_t *l, u_int8_t *pay
     memset(src, 0, sizeof(src));      memset(src, 0, sizeof(src));
   
     packet_s = payload_s + l->link_offset;      packet_s = payload_s + l->link_offset;
    packet = (u_int8_t *)malloc(packet_s);    packet = (uint8_t *)malloc(packet_s);
     if (packet == NULL)      if (packet == NULL)
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
Line 286  libnet_win32_write_raw_ipv4(libnet_t *l, u_int8_t *pay Line 289  libnet_win32_write_raw_ipv4(libnet_t *l, u_int8_t *pay
 }  }
   
 int  int
libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size)libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size)
 {  {
     return (libnet_win32_write_raw_ipv4(l, packet, size));      return (libnet_win32_write_raw_ipv4(l, packet, size));
 }  }
   
 int  int
libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size)libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size)
 {  {
     /* no difference in win32 */      /* no difference in win32 */
     return (libnet_write_raw_ipv4(l, packet, size));      return (libnet_write_raw_ipv4(l, packet, size));
Line 301  libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u Line 304  libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u
 #else /* __WIN32__ */  #else /* __WIN32__ */
   
 int  int
libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u_int32_t size)libnet_write_raw_ipv4(libnet_t *l, const uint8_t *packet, uint32_t size)
 {  {
     int c;      int c;
     struct sockaddr_in sin;      struct sockaddr_in sin;
Line 354  libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u Line 357  libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u
 #endif /* __WIN32__ */  #endif /* __WIN32__ */
   
     c = sendto(l->fd, packet, size, 0, (struct sockaddr *)&sin,      c = sendto(l->fd, packet, size, 0, (struct sockaddr *)&sin,
            sizeof(struct sockaddr));            sizeof(sin));
   
 #if (LIBNET_BSD_BYTE_SWAP)  #if (LIBNET_BSD_BYTE_SWAP)
     ip_hdr->ip_len = UNFIX(ip_hdr->ip_len);      ip_hdr->ip_len = UNFIX(ip_hdr->ip_len);
Line 377  libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u Line 380  libnet_write_raw_ipv4(libnet_t *l, u_int8_t *packet, u
 }  }
   
 int  int
libnet_write_raw_ipv6(libnet_t *l, u_int8_t *packet, u_int32_t size)libnet_write_raw_ipv6(libnet_t *l, const uint8_t *packet, uint32_t size)
 {  {
 #if defined HAVE_SOLARIS && !defined HAVE_SOLARIS_IPV6  #if defined HAVE_SOLARIS && !defined HAVE_SOLARIS_IPV6
     snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): no IPv6 support\n",      snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): no IPv6 support\n",

Removed from v.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>