Updated makefile

This commit is contained in:
Mark Qvist 2020-06-24 14:01:35 +02:00
parent 26f1e48b19
commit d3ff2f207a
3 changed files with 3 additions and 57 deletions

36
Tcp.c
View File

@ -1,36 +0,0 @@
#include "Tcp.h"
int open_tcp(char* ip, int port) {
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
perror("ERROR opening socket");
exit(1);
}
struct hostent *server;
struct sockaddr_in serv_addr;
server = gethostbyname(ip);
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(port);
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
perror("ERROR connecting");
exit(1);
}
return sockfd;
}
int close_tcp(int fd) {
return close(fd);
}

18
Tcp.h
View File

@ -1,18 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include "Constants.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
int open_tcp(char* ip, int port);
int close_tcp(int fd);

View File

@ -2,7 +2,7 @@
.PHONY: all clean install uninstall tncattach
compiler = gcc
flags = -std=gnu11 -static-libgcc
flags = -Wall -std=gnu11 -static-libgcc
all: tncattach
rebuild: clean all
@ -14,7 +14,7 @@ clean:
tncattach:
@echo "Making tncattach..."
@echo "Compiling with: ${compiler}"
${compiler} ${flags} tncattach.c Serial.c Tcp.c KISS.c TAP.c -o tncattach -Wall
${compiler} ${flags} tncattach.c Serial.c TCP.c KISS.c TAP.c -o tncattach -Wall
install:
@echo "Installing tncattach..."