/*
 * $Id: pylibnet.h,v 1.1.1.1 2001/10/15 06:54:54 davidma Exp $
 *
 * Python libnet
 * Copyright (C) 2001, David Margrave (davidma@eskimo.com)
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 */

#include <libnet.h>

typedef struct {
  struct libnet_link_int *link;
  int fd;
  char *device;
} interface;

/* interface methods */
interface *new_interface();
void delete_interface(interface *self);
void interface_open_link(interface *self, char *device);
void interface_open_raw(interface *self, int protocol);
void interface_write(interface *self, PyObject *pkt);
u_long interface_get_ipaddr(interface *self);
PyObject *interface_get_hwaddr(interface *self);


PyObject *build_arp(u_short hrd, u_short pro, u_char hln, u_char pln,
                    u_short op, u_char *sha, u_char *spa, u_char *tha,
                    u_char *tpa);
PyObject *build_dns(u_short id, u_short flags, u_short num_q,
                    u_short num_anws_rr, u_short num_auth_rr,
                    u_short num_addi_rr);
PyObject *build_ethernet(u_char *dst, u_char *src, u_short type);

PyObject *build_icmp_echo(u_char type, u_char code, u_short id, u_short seq);
PyObject *build_icmp_mask(u_char type, u_char code, u_short id, u_short seq,
            u_long mask);
PyObject *build_icmp_unreach(u_char type, u_char code, u_short orig_len,
        u_char orig_tos, u_short orig_id, u_short orig_frag, u_char orig_ttl,
        u_char orig_prot, u_long orig_src, u_long orig_dst, PyObject *payload);
PyObject *build_icmp_timeexceed(u_char type, u_char code, u_short orig_len,
        u_char orig_tos, u_short orig_id, u_short orig_frag, u_char orig_ttl,
        u_char orig_prot, u_long orig_src, u_long orig_dst, PyObject *payload);
PyObject *build_icmp_timestamp(u_char type,u_char code,u_short id,u_short seq,
        n_time otime, n_time rtime, n_time ttime);
PyObject *build_icmp_redirect(u_char type, u_char code, u_long gateway,
            u_short orig_len, u_char orig_tos, u_short orig_id,
            u_short orig_frag, u_char orig_ttl, u_char orig_prot,
            u_long orig_src, u_long orig_dst, PyObject *payload);


PyObject *build_ip(u_short len, u_char tos, u_short id, u_short frag,
                          u_char ttl, u_char prot, u_long src, u_long dst);
PyObject *build_tcp(u_short sp, u_short dp, u_long seq, u_long ack,
                           u_char control, u_short win, u_short urg);
PyObject *build_udp(u_short sp, u_short dp);



void do_checksum(PyObject *pkt, int protocol, int packet_size);
u_char *interface_select_device(PyObject *device);
u_char *host_lookup(u_long in, u_short use_name);
u_long name_resolve(u_char *hostname, u_short use_name);





syntax highlighted by Code2HTML, v. 0.9.1