diff options
author | Sebastian Stumpf <sebastian.stumpf87@googlemail.com> | 2017-01-08 16:31:50 +0100 |
---|---|---|
committer | Sebastian Stumpf <sebastian.stumpf87@googlemail.com> | 2017-01-23 13:54:58 +0100 |
commit | d1c904c4a6d3a862a37d62fdffbb74284a44b24d (patch) | |
tree | c49fab8ca640e77b09fae56943adafc5036974c1 /tests/virtsock/virtsock_client.c | |
parent | bf286abc409d04dc1f317a2d74f050235958dac4 (diff) |
VIRT-PHY: Added functionality to cooperate with osmocom-bb virt-phy.
This patch improves the virtual physical layer designed to replace the
air interface. The purpose is to get rid of the hardware requirements
and be able to start testing and implementing layer 2 communication
functionality on one machine. Multicast sockets are used to enable
bidirectional communication between the BTS and the MS process.
The GSMTAP protocol designed for wireshark capturing is used to
encapsulate the payload on the virtual physical layer.
* Working mcast socket communication and extraction of its
functionality.
* Fixed OML and RSL startup sequences.
* Icludes tests for mcast socket and virtual UM.
* Ecapsulation and parsing methods to and from GSMTAP messages.
* Basic handlers for file descriptor callbacks from incoming mcast
messages.
* Multiplexing to different channels based on GSMTAP header channel
type.
Diffstat (limited to 'tests/virtsock/virtsock_client.c')
-rw-r--r-- | tests/virtsock/virtsock_client.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/virtsock/virtsock_client.c b/tests/virtsock/virtsock_client.c new file mode 100644 index 00000000..ba0f50c8 --- /dev/null +++ b/tests/virtsock/virtsock_client.c @@ -0,0 +1,57 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> + +void error(const char *msg) +{ + perror(msg); + exit(0); +} + +int main(int argc, char *argv[]) +{ + int sockfd, portno, n; + struct sockaddr_in serv_addr; + struct hostent *server; + + char buffer[256]; + if (argc < 3) { + fprintf(stderr,"usage %s hostname port\n", argv[0]); + exit(0); + } + portno = atoi(argv[2]); + sockfd = socket(AF_INET, SOCK_STREAM, 0); + if (sockfd < 0) + error("ERROR opening socket"); + server = gethostbyname(argv[1]); + if (server == NULL) { + fprintf(stderr,"ERROR, no such host\n"); + exit(0); + } + bzero((char *) &serv_addr, sizeof(serv_addr)); + serv_addr.sin_family = AF_INET; + bcopy((char *)server->h_addr, + (char *)&serv_addr.sin_addr.s_addr, + server->h_length); + serv_addr.sin_port = htons(portno); + if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) + error("ERROR connecting"); + printf("Please enter the message: "); + bzero(buffer,256); + fgets(buffer,255,stdin); + n = write(sockfd,buffer,strlen(buffer)); + if (n < 0) + error("ERROR writing to socket"); + bzero(buffer,256); + n = read(sockfd,buffer,255); + if (n < 0) + error("ERROR reading from socket"); + printf("%s\n",buffer); + close(sockfd); + return 0; +} |