mirror of
https://github.com/markqvist/tncattach.git
synced 2024-12-22 18:45:39 -05:00
Updated makefile
This commit is contained in:
parent
26f1e48b19
commit
d3ff2f207a
36
Tcp.c
36
Tcp.c
@ -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
18
Tcp.h
@ -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);
|
6
makefile
6
makefile
@ -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..."
|
||||
@ -23,4 +23,4 @@ install:
|
||||
|
||||
uninstall:
|
||||
@echo "Uninstalling tncattach"
|
||||
rm /usr/local/sbin/tncattach
|
||||
rm /usr/local/sbin/tncattach
|
||||
|
Loading…
Reference in New Issue
Block a user