IPPOLib
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Macros
lib
util.h
Go to the documentation of this file.
1
/*
2
* ippo-lib - IP oPtion-based active PrObing
3
* An Active Probing Library for IP Options Equipped probes (http://traffic.comics.unina.it/ippolib)
4
*
5
* Copyright : (C) 2012 by Pietro Marchetta, Walter de Donato, Francesco Cesareo,
6
* Antonio Pescape' (PI)
7
* of the COMICS (COMputer for Interaction and
8
* CommunicationS) Group, Dipartimento di Informatica
9
* e Sistemistica of the University of Napoli "Federico II".
10
*
11
* email : pietro.marchetta@unina.it , walter.dedonato@unina.it , cesareo.francesco@gmail.com
12
* pescape@unina.it
13
*
14
* This program is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU General Public License for more details.
23
*
24
* You should have received a copy of the GNU General Public License
25
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
*
27
*/
28
29
#ifndef UTIL_H
30
#define UTIL_H
31
32
#include <string>
33
#include <stdlib.h>
34
#include <sys/socket.h>
35
#include <netinet/in.h>
36
#include <arpa/inet.h>
37
#include <netdb.h>
38
39
typedef
unsigned
short
uint16
;
40
typedef
unsigned
int
uint32
;
41
42
class
Util
43
{
44
public
:
51
static
uint32
string2number
(std::string &addr)
52
{
53
uint32
ip;
54
inet_pton(AF_INET,addr.c_str(),&ip);
55
return
ip;
56
}
57
64
static
char
*
number2string
(
uint32
addr)
65
{
66
char
* ip = (
char
*) malloc(INET_ADDRSTRLEN);
67
inet_ntop(AF_INET,&addr, ip,INET_ADDRSTRLEN);
68
return
ip;
69
}
70
};
71
72
#endif // UTIL_H
Generated on Tue Jan 15 2013 16:25:17 for IPPOLib by
1.8.1.2