libmac.h
Go to the documentation of this file.00001
00004
#ifndef LIBMAC_H
00005
#define LIBMAC_H
00006
#include <sys/types.h>
00007
#include <sys/socket.h>
00008
#include <stdio.h>
00009
#include <math.h>
00010
#include <errno.h>
00011
#include <fcntl.h>
00012
#include <ctype.h>
00013
#include <stdlib.h>
00014
#include <string.h>
00015
#include <unistd.h>
00016
#include <sys/ioctl.h>
00017
#include <netinet/in.h>
00018
#include <netinet/ether.h>
00019
#include <arpa/inet.h>
00021
#include <net/if_arp.h>
00022
#include <libnet.h>
00023
#include <pcap.h>
00024
#include <assert.h>
00025
#include <time.h>
00026
#include <syslog.h>
00028
#include <stdarg.h>
00030
#include "libmac_cmn.h"
00032
#include <limits.h>
00034
#include <math.h>
00035
00037 #define DEBUG_ERR
00038
00039 #define DEBUG_BASIC
00040
00041
00043 #define USE_PROC_INTERFACE_OK 0
00044
00045 #define IFNAME 8
00046
00047 #define IPSIZE 16
00048
00049 #define MACSIZE 6
00050
00051 #define VERSION 1.2
00052
00053 #define FRM_TYPE 0x0900
00054
00055 #define MAX_FRAME_SIZE 1500
00056
00057 #define IOCTL_BUF_SIZE 1024
00058
00059 #define PROC_BUF_SIZE 128
00060
00061 #define SET 0
00062
00063 #define RESET 1
00064
00065 #define GET_FLAG 0
00066
00067 #define SET_FLAG 1
00068
00069 #define APPEND_FLAG 2
00070
00071 #define INCLUDE_FLAG 3
00072
00073 #define CHANGE_FLAG 4
00074
00075 #define OUTGOING 0
00076
00077 #define INCOMING 1
00078
00079 #define APPEND_OFF 2
00080
00081 #define INIT_VAL -1
00082
00083 #define UNSUPPORTED INT_MIN
00084
00085 #define READONLY INT_MAX
00086
00087 #define SIZEOF_PARAMS_LIST_LEN sizeof(char)
00088
00089 #define SIZEOF_PARAMS_LIST_KEY sizeof(char)
00090
00091 #define SIZEOF_PARAMS_LIST_VALUE sizeof(unsigned short)
00092
00093 #define BYTE_SIZE_MAX_16b_VALUE 5
00094
00095
00097
00099 struct mac_promisc_recv_frame_info
00100 {
00102 unsigned char *
frame_ptr;
00104 unsigned short frame_len;
00105 };
00106
00108
00111 struct mac_recv_frame_info
00112 {
00114 struct ether_header *
hptr;
00116 unsigned char *
data;
00118 short data_len;
00119 };
00120
00122
00131 struct mac_ifinfo_list
00132 {
00134 char if_name[
IFNAME + 1];
00136 char ip_addr[
IPSIZE + 1];
00138 u_char
hw_addr[
MACSIZE + 1];
00140 char mac_flag;
00142 libnet_t *
link_struct;
00144 pcap_t *
pcap_descr;
00146 unsigned char num_supported_params;
00148 unsigned char supported_params[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00150 unsigned char mode_params[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00152 unsigned char append_params_incmg[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00154 unsigned char append_params_outgng[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00156 struct mac_recv_frame_info frame_info;
00158 struct mac_promisc_recv_frame_info promisc_frame_info;
00160 struct mac_ifinfo_list *
next;
00161 };
00162
00164
00174 struct mac_ifinfo
00175 {
00177 struct mac_ifinfo_list *
mac_list;
00179 float lib_version;
00180 };
00181
00183
00194
int mac_get_ifinfo(
struct mac_ifinfo **mac_ptr);
00195
00197
00204
void mac_free_ifinfo(
struct mac_ifinfo **mac_ptr);
00205
00207
00216
int iw_sockets_open(
void);
00217
00219
00227
char *
pr_ether(
unsigned char *ptr);
00228
00230
00246
int mac_send_broadcast(u_char *payload,
short len,
struct mac_ifinfo_list *q);
00247
00249
00263
int mac_send_unicast(u_char *payload,
short len,
struct mac_ifinfo_list *q,
unsigned char *ucast_mac);
00264
00266
00292
int mac_recv(
struct ether_header **header,
char **payload,
unsigned short *len,
unsigned char **send_params,
unsigned char **recv_params,
struct mac_ifinfo_list *q,
char *filter);
00293
00295
00315
int mac_promisc_recv(
unsigned char **frame,
unsigned short *frame_len,
unsigned char **send_params,
unsigned char **recv_params,
struct mac_ifinfo_list *q);
00316
00318
00329 struct mac_params {
00331 short key[
MAX_NO_PARAMS];
00333 int value[
MAX_NO_PARAMS];
00335 unsigned char number_of_params;
00337 float lib_version;
00338 };
00339
00341
00358 struct mac_params_flags {
00360 unsigned char set_flag[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00362 unsigned char get_flag[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00364 unsigned char append_flag[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00366 unsigned char change_flag[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00368 unsigned char include_flag[((
MAX_NO_PARAMS)/(CHAR_BIT))];
00370 float lib_version;
00371 };
00372
00374
00386
int
00387
mac_init_params(
struct mac_params **h,
00388
struct mac_params_flags **g);
00389
00391
00400
void
00401
mac_free_params(
struct mac_params **h,
00402
struct mac_params_flags **g);
00403
00405
00422
int
00423
mac_get_params (
struct mac_params *h,
00424
struct mac_ifinfo_list *if_ptr,
00425
int argc,
00426 ...);
00427
00429
00445
int
00446
mac_set_params (
struct mac_params *h,
00447
struct mac_ifinfo_list *if_ptr,
00448
int argc,
00449 ...);
00450
00452
00470
int
00471
mac_append_params (
struct mac_ifinfo_list *if_ptr,
00472
unsigned char direction,
00473
int argc,
00474 ...);
00475
00476
#endif
Generated on Tue Aug 24 17:01:41 2004 for libmac by
1.3.8