00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _IP_H_
00012 #define _IP_H_
00013
00014 #include "usi-structs.h"
00015 #include "datalink.h"
00016 #include "Layer2.h"
00017 #include <stdio.h>
00018
00019 namespace usipp {
00020
00024 class IP : public Layer2 {
00025 protected:
00026 struct iphdr iph;
00027 char ipOptions[40];
00028 struct sockaddr_in saddr;
00029 char host[1000];
00030
00031 char *reassemble(char *, int, int *);
00032 public:
00033
00036 IP(const char*, u_int8_t);
00037
00040 IP(u_int32_t, u_int8_t);
00041
00044 virtual ~IP();
00045
00048 u_int8_t get_hlen();
00049
00052 u_int8_t get_vers();
00053
00056 u_int8_t get_tos();
00057
00061 u_int16_t get_totlen();
00062
00065 u_int16_t get_id();
00066
00069 u_int16_t get_fragoff();
00070
00071
00072 u_int16_t get_fflags();
00073
00077 u_int8_t get_ttl();
00078
00081 u_int8_t get_proto();
00082
00085 u_int16_t get_sum();
00086
00089 u_int32_t get_src();
00090
00093 u_int32_t get_dst();
00094
00097 IP &operator=(const IP&);
00098
00101 IP(const IP&);
00102
00106 char *get_src(int resolv, char *buf, size_t buflen);
00107
00110 char *get_dst(int resolv, char *buf, size_t buflen);
00111
00115 int set_hlen(u_int8_t);
00116
00119 int set_vers(u_int8_t);
00120
00121
00122 int set_tos(u_int8_t);
00123
00126 int set_totlen(u_int16_t);
00127
00130 int set_id(u_int16_t);
00131
00132
00133 int set_fragoff(u_int16_t);
00134
00135
00136 int set_fflags(u_int16_t);
00137
00140 int set_ttl(u_int8_t);
00141
00145 int set_proto(u_int8_t);
00146
00147
00148 int set_sum(u_int16_t);
00149
00152 int set_src(u_int32_t);
00153
00156 int set_dst(u_int32_t);
00157
00160 int set_src(const char *ip_or_name);
00161
00165 int set_dst(const char*);
00166
00170 iphdr get_iphdr();
00171
00174 virtual int sendpack(void *payload, size_t paylen);
00175
00176
00177 virtual int sendpack(char *pay_string);
00178
00181 virtual int sniffpack(void *buf, size_t len);
00182
00183
00184 virtual int init_device(char *, int, size_t);
00185 };
00186
00187
00188 }
00189
00190 #endif // _IP_H_
00191