DESERT 4.0.0
msocket.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36#ifndef MSOCKET_H
37#define MSOCKET_H
38
39#include <uwmconnector.h>
40
41#include <arpa/inet.h>
42#include <errno.h>
43#include <fcntl.h>
44#include <netdb.h>
45#include <netinet/in.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <string.h>
49#include <string>
50#include <sys/socket.h>
51#include <sys/types.h>
52#include <unistd.h>
53
58class Msocket : public UWMconnector
59{
60 int sockfd;
61 int portno;
62 int rc;
63 pthread_t thread_id;
64 struct sockaddr_in serv_addr;
67 std::string server_host;
71 struct hostent *server;
72 char msg_tx[_MAX_MSG_LENGTH];
75
80 void error(const char *);
81
82public:
91 Msocket(UWMdriver *, std::string);
92
97
105 virtual int openConnection();
106
110 virtual void closeConnection();
111
118 virtual int writeToModem(std::string);
119
126 int
128 {
129 return sockfd;
130 }
131};
132
137extern "C" {
138void *read_process_msocket(void *);
139}
140
141#endif /* MSOCKET_H */
void * read_process_msocket(void *)
Definition msocket.cpp:139
Definition msocket.h:59
virtual int writeToModem(std::string)
pthread_t thread_id
Definition msocket.h:63
char msg_tx[_MAX_MSG_LENGTH]
Definition msocket.h:72
int rc
Definition msocket.h:62
int getSocket()
Definition msocket.h:127
struct sockaddr_in serv_addr
Definition msocket.h:64
struct hostent * server
Definition msocket.h:71
virtual int openConnection()
int modem_queue_length
Definition msocket.h:74
virtual void closeConnection()
int sockfd
Definition msocket.h:60
int portno
Definition msocket.h:61
Msocket(UWMdriver *, std::string)
std::string server_host
Definition msocket.h:67
void error(const char *)
Definition uwmconnector.h:79
Definition uwmdriver.h:94