INET Framework for OMNeT++/OMNEST
inet::httptools Namespace Reference

Classes

class  HttpBaseMessage
 Class generated from inet/applications/httptools/common/HttpMessages.msg:72 by nedtool. More...
 
class  HttpBrowser
 Browser module. More...
 
class  HttpBrowserBase
 A simulated browser module for OMNeT++ simulations. More...
 
class  HttpBrowserDirect
 A simulated browser module for OMNeT++ simulations. More...
 
class  HttpController
 The controller module for HttpTools simulations. More...
 
class  HttpNodeBase
 The base class for browser and server nodes. More...
 
class  HttpReplyMessage
 Class generated from inet/applications/httptools/common/HttpMessages.msg:111 by nedtool. More...
 
class  HttpRequestMessage
 Class generated from inet/applications/httptools/common/HttpMessages.msg:88 by nedtool. More...
 
class  HttpServer
 HttpServerDirect module. More...
 
class  HttpServerBase
 Web server base class. More...
 
class  HttpServerDirect
 Server module for direct message passing. More...
 
class  HttpServerDirectEvilA
 An evil attacker server demonstration - type A. More...
 
class  HttpServerDirectEvilB
 An evil attacker server demonstration - type B. More...
 
class  HttpServerEvilA
 An evil attacker server demonstration - type A. More...
 
class  HttpServerEvilB
 An evil attacker server demonstration - type B. More...
 
class  HttpServerStatusUpdateMsg
 Class generated from inet/applications/httptools/common/HttpEventMessages.msg:31 by nedtool. More...
 
class  rdConstant
 Constant distribution random object. More...
 
class  rdExponential
 Exponential distribution random object. More...
 
class  rdHistogram
 Histogram distribution random object. More...
 
class  rdNormal
 Normal distribution random object. More...
 
class  rdObject
 Base random object. More...
 
class  rdObjectFactory
 A factory class used to construct random distribution objects based on XML elements. More...
 
class  rdUniform
 Uniform distribution random object. More...
 
class  rdZipf
 Zipf distribution random object. More...
 

Enumerations

enum  HttpContentType { CT_UNKNOWN = 0, CT_HTML = 1, CT_IMAGE = 2, CT_TEXT = 3 }
 Enum generated from inet/applications/httptools/common/HttpMessages.msg:99 by nedtool. More...
 
enum  LOG_FORMAT { lf_short, lf_long }
 
enum  DISTR_TYPE {
  dt_normal, dt_uniform, dt_exponential, dt_histogram,
  dt_constant, dt_zipf
}
 

Functions

 Define_Module (HttpBrowser)
 
 Define_Module (HttpBrowserDirect)
 
void doParsimPacking (omnetpp::cCommBuffer *b, const HttpServerStatusUpdateMsg &obj)
 
void doParsimUnpacking (omnetpp::cCommBuffer *b, HttpServerStatusUpdateMsg &obj)
 
void doParsimPacking (omnetpp::cCommBuffer *b, const HttpBaseMessage &obj)
 
void doParsimUnpacking (omnetpp::cCommBuffer *b, HttpBaseMessage &obj)
 
void doParsimPacking (omnetpp::cCommBuffer *b, const HttpRequestMessage &obj)
 
void doParsimUnpacking (omnetpp::cCommBuffer *b, HttpRequestMessage &obj)
 
void doParsimPacking (omnetpp::cCommBuffer *b, const HttpReplyMessage &obj)
 
void doParsimUnpacking (omnetpp::cCommBuffer *b, HttpReplyMessage &obj)
 
bool isnotspace (int c)
 
std::string trimLeft (std::string s)
 
std::string trimLeft (std::string str, std::string delim)
 
std::string trimRight (std::string s)
 
std::string trimRight (std::string str, std::string delim)
 
std::string trim (std::string str)
 
std::string extractServerName (const char *url)
 
std::string extractResourceName (const char *url)
 
std::vector< std::string > parseResourceName (std::string resource)
 
std::string getDelimited (std::string str, std::string ldelim, std::string rdelim)
 
HttpContentType getResourceCategory (std::vector< std::string > res)
 
HttpContentType getResourceCategory (std::string resourceExt)
 
std::string htmlErrFromCode (int code)
 
double safeatof (const char *strval, double defaultVal)
 
int safeatoi (const char *strval, int defaultVal)
 
int safeatobool (const char *strval, bool defaultVal)
 
std::vector< std::string > splitFile (std::string fileName)
 
 Define_Module (HttpController)
 
 Define_Module (HttpServer)
 
 Define_Module (HttpServerDirect)
 
 Define_Module (HttpServerDirectEvilA)
 
 Define_Module (HttpServerDirectEvilB)
 
 Define_Module (HttpServerEvilA)
 
 Define_Module (HttpServerEvilB)
 

Enumeration Type Documentation

Enumerator
dt_normal 
dt_uniform 
dt_exponential 
dt_histogram 
dt_constant 
dt_zipf 
Definition: HttpRandom.h:33
Definition: HttpRandom.h:33
Definition: HttpRandom.h:33
Definition: HttpRandom.h:33
Definition: HttpRandom.h:33
Definition: HttpRandom.h:33

Enum generated from inet/applications/httptools/common/HttpMessages.msg:99 by nedtool.

//
// Content type of HTTP responses.
//
enum HttpContentType
{
CT_UNKNOWN = 0;
CT_HTML = 1;
CT_IMAGE = 2;
CT_TEXT = 3;
}
Enumerator
CT_UNKNOWN 
CT_HTML 
CT_IMAGE 
CT_TEXT 
160  {
161  CT_UNKNOWN = 0,
162  CT_HTML = 1,
163  CT_IMAGE = 2,
164  CT_TEXT = 3
165 };
Definition: HttpMessages_m.h:163
Definition: HttpMessages_m.h:161
Definition: HttpMessages_m.h:162
Definition: HttpMessages_m.h:164
Enumerator
lf_short 
lf_long 
44 { lf_short, lf_long };
Definition: HttpNodeBase.h:44
Definition: HttpNodeBase.h:44

Function Documentation

inet::httptools::Define_Module ( HttpBrowser  )
inet::httptools::Define_Module ( HttpServerDirectEvilB  )
inet::httptools::Define_Module ( HttpServerEvilA  )
inet::httptools::Define_Module ( HttpServerEvilB  )
inet::httptools::Define_Module ( HttpController  )
inet::httptools::Define_Module ( HttpServer  )
inet::httptools::Define_Module ( HttpServerDirectEvilA  )
inet::httptools::Define_Module ( HttpBrowserDirect  )
inet::httptools::Define_Module ( HttpServerDirect  )
void inet::httptools::doParsimPacking ( omnetpp::cCommBuffer *  b,
const HttpServerStatusUpdateMsg obj 
)
inline
96 {obj.parsimPack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimPacking ( omnetpp::cCommBuffer *  b,
const HttpBaseMessage obj 
)
inline
98 {obj.parsimPack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimPacking ( omnetpp::cCommBuffer *  b,
const HttpRequestMessage obj 
)
inline
141 {obj.parsimPack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimPacking ( omnetpp::cCommBuffer *  b,
const HttpReplyMessage obj 
)
inline
211 {obj.parsimPack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimUnpacking ( omnetpp::cCommBuffer *  b,
HttpServerStatusUpdateMsg obj 
)
inline
97 {obj.parsimUnpack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimUnpacking ( omnetpp::cCommBuffer *  b,
HttpBaseMessage obj 
)
inline
99 {obj.parsimUnpack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimUnpacking ( omnetpp::cCommBuffer *  b,
HttpRequestMessage obj 
)
inline
142 {obj.parsimUnpack(b);}
value< double, units::m > b
Definition: Units.h:1054
void inet::httptools::doParsimUnpacking ( omnetpp::cCommBuffer *  b,
HttpReplyMessage obj 
)
inline
212 {obj.parsimUnpack(b);}
value< double, units::m > b
Definition: Units.h:1054
std::string inet::httptools::extractResourceName ( const char *  url)

Referenced by inet::httptools::HttpBrowserBase::readScriptedEvents().

83 {
84  std::string str(url);
85  int position = str.find("http://");
86  if (position != -1) {
87  str = str.erase(0, position);
88  }
89  else {
90  position = str.find("https://");
91  if (position != -1) {
92  str = str.erase(0, position);
93  }
94  }
95 
96  position = str.find("/");
97  if (position != -1)
98  return str.substr(position + 1, str.size() - position);
99  else
100  return "";
101 }
std::string inet::httptools::extractServerName ( const char *  url)

Referenced by inet::httptools::HttpController::getServerInfo(), inet::httptools::HttpController::getServerModule(), inet::httptools::HttpServerBase::handleReceivedMessage(), inet::httptools::HttpBrowserBase::readScriptedEvents(), and inet::httptools::HttpController::registerServer().

61 {
62  std::string str(url);
63  int position = str.find("http://");
64  if (position != -1) {
65  str = str.erase(0, position);
66  }
67  else {
68  position = str.find("https://");
69  if (position != -1) {
70  str = str.erase(0, position);
71  }
72  }
73 
74  position = str.find("/");
75  if (position != -1) {
76  str = str.substr(0, position);
77  }
78 
79  return str;
80 }
std::string inet::httptools::getDelimited ( std::string  str,
std::string  ldelim,
std::string  rdelim 
)

Referenced by inet::httptools::HttpServerBase::readSiteDefinition().

129 {
130  int lpos = str.find(ldelim);
131  int rpos;
132  if (rdelim == "")
133  rpos = str.rfind(ldelim);
134  else
135  rpos = str.rfind(rdelim);
136  if (lpos == -1 || rpos == -1 || lpos == rpos)
137  return ""; // Not found
138  else
139  return str.substr(lpos + 1, rpos - lpos - 1);
140 }
HttpContentType inet::httptools::getResourceCategory ( std::vector< std::string >  res)

Referenced by inet::httptools::HttpBrowserBase::generateResourceRequest(), and inet::httptools::HttpServerBase::handleGetRequest().

143 {
144  if (res.size() == 2)
145  return CT_HTML;
146  else if (res.size() > 2)
147  return getResourceCategory(res[2]); // get the category from the extension
148  return CT_UNKNOWN;
149 }
Definition: HttpMessages_m.h:161
Definition: HttpMessages_m.h:162
HttpContentType getResourceCategory(std::string resourceExt)
Definition: HttpUtils.cc:151
HttpContentType inet::httptools::getResourceCategory ( std::string  resourceExt)
152 {
153  if (resourceExt == "" || resourceExt == "htm" || resourceExt == "html")
154  return CT_HTML;
155  else if (resourceExt == "jpg" || resourceExt == "gif" || resourceExt == "png" || resourceExt == "bmp")
156  return CT_IMAGE;
157  else if (resourceExt == "css" || resourceExt == "txt" || resourceExt == "js")
158  return CT_TEXT;
159  return CT_UNKNOWN;
160 }
Definition: HttpMessages_m.h:163
Definition: HttpMessages_m.h:161
Definition: HttpMessages_m.h:162
Definition: HttpMessages_m.h:164
std::string inet::httptools::htmlErrFromCode ( int  code)

Referenced by inet::httptools::HttpServerBase::generateErrorReply().

163 {
164  switch (code) {
165  case 200:
166  return "OK";
167 
168  case 400:
169  return "ERROR";
170 
171  case 404:
172  return "NOT FOUND";
173 
174  default:
175  return "???";
176  }
177 }
bool inet::httptools::isnotspace ( int  c)
inline

Referenced by trimLeft(), and trimRight().

27 { return !isspace(c); }
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
std::vector< std::string > inet::httptools::parseResourceName ( std::string  resource)

Referenced by inet::httptools::HttpServerBase::handleGetRequest(), and inet::httptools::HttpBrowserBase::readScriptedEvents().

104 {
105  std::string path = "";
106  std::string resourceName = "";
107  std::string extension = "";
108 
109  int slashpos = resource.rfind("/");
110  if (slashpos != -1)
111  path = resource.substr(0, slashpos);
112  int dotpos = resource.rfind(".");
113  if (dotpos != -1) {
114  resourceName = resource.substr(slashpos + 1, dotpos - slashpos - 1);
115  extension = resource.substr(dotpos + 1, resource.size() - dotpos - 1);
116  }
117  else {
118  resourceName = resource.substr(slashpos + 1, resource.size() - slashpos);
119  }
120 
121  std::vector<std::string> res;
122  res.push_back(path);
123  res.push_back(resourceName);
124  res.push_back(extension);
125  return res;
126 }
int inet::httptools::safeatobool ( const char *  strval,
bool  defaultVal 
)

Referenced by inet::httptools::HttpBrowserBase::handleDataMessage().

200 {
201  try {
202  return strcmp(strval, "TRUE") == 0 || strcmp(strval, "true") == 0;
203  }
204  catch (...) {
205  return defaultVal;
206  }
207 }
double inet::httptools::safeatof ( const char *  strval,
double  defaultVal 
)

Referenced by inet::httptools::rdHistogram::__parseBinString(), and inet::httptools::HttpBrowserBase::handleDataMessage().

180 {
181  try {
182  return atof(strval);
183  }
184  catch (...) {
185  return defaultVal;
186  }
187 }
int inet::httptools::safeatoi ( const char *  strval,
int  defaultVal 
)

Referenced by inet::httptools::rdHistogram::__parseBinString(), and inet::httptools::HttpBrowserBase::handleDataMessage().

190 {
191  try {
192  return atoi(strval);
193  }
194  catch (...) {
195  return defaultVal;
196  }
197 }
std::vector< std::string > inet::httptools::splitFile ( std::string  fileName)

Referenced by inet::httptools::HttpServerBase::readSiteDefinition().

210 {
211  std::string path = "";
212  std::string file = "";
213  std::string ext = "";
214 
215  int slashpos = fileName.rfind("/");
216  if (slashpos == -1)
217  slashpos = fileName.rfind("\\");
218  if (slashpos != -1) {
219  path = fileName.substr(0, slashpos + 1);
220  fileName = fileName.substr(slashpos + 1, fileName.size() - slashpos - 1);
221  }
222 
223  int dotpos = fileName.find(".");
224  if (dotpos != -1) {
225  ext = fileName.substr(dotpos + 1, fileName.size() - dotpos - 1);
226  file = fileName.substr(0, dotpos);
227  }
228  else {
229  file = fileName;
230  }
231 
232  std::vector<std::string> res;
233  res.push_back(path);
234  res.push_back(file);
235  res.push_back(ext);
236  return res;
237 }
std::string inet::httptools::trim ( std::string  str)

Referenced by inet::httptools::HttpServerBase::readHtmlBodyFile(), inet::httptools::HttpBrowserBase::readScriptedEvents(), and inet::httptools::HttpServerBase::readSiteDefinition().

54 {
55  str = trimLeft(str);
56  str = trimRight(str);
57  return str;
58 }
std::string trimLeft(std::string str, std::string delim)
Definition: HttpUtils.cc:35
std::string trimRight(std::string str, std::string delim)
Definition: HttpUtils.cc:47
std::string inet::httptools::trimLeft ( std::string  s)

Referenced by inet::httptools::rdHistogram::__parseBinString(), inet::httptools::HttpBrowserBase::generateResourceRequest(), inet::httptools::HttpServerBase::handleGetRequest(), inet::httptools::HttpServerBase::readSiteDefinition(), and trim().

30 {
31  s.erase(s.begin(), std::find_if(s.begin(), s.end(), isnotspace));
32  return s;
33 }
bool isnotspace(int c)
Definition: HttpUtils.cc:27
value< double, units::s > s
Definition: Units.h:1049
std::string inet::httptools::trimLeft ( std::string  str,
std::string  delim 
)
36 {
37  int pos = str.find(delim);
38  return pos == -1 ? str : str.substr(pos + 1, str.size() - pos - 1);
39 }
std::string inet::httptools::trimRight ( std::string  s)

Referenced by inet::httptools::rdHistogram::__parseBinString(), and trim().

42 {
43  s.erase(std::find_if(s.rbegin(), s.rend(), isnotspace).base(), s.end());
44  return s;
45 }
bool isnotspace(int c)
Definition: HttpUtils.cc:27
value< double, units::s > s
Definition: Units.h:1049
std::string inet::httptools::trimRight ( std::string  str,
std::string  delim 
)
48 {
49  int pos = str.rfind(delim);
50  return pos == -1 ? str : str.substr(0, pos - 1);
51 }