diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..6089f46 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.4.1) +include_directories( curve25519 ed25519 playfair plist/plist ) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -march=native -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g") + +aux_source_directory(. play_src) +set(DIR_SRCS ${play_src}) + +add_library( airplay + STATIC + ${DIR_SRCS} + ) + +target_link_libraries( airplay + pthread + curve25519 + ed25519 + playfair + plist ) + + find_package(OpenSSL REQUIRED) + target_link_libraries( airplay OpenSSL::Crypto ) + target_link_libraries( airplay dns_sd ) + diff --git a/lib/fairplay.h b/lib/fairplay.h new file mode 100644 index 0000000..d520817 --- /dev/null +++ b/lib/fairplay.h @@ -0,0 +1,14 @@ +#ifndef FAIRPLAY_H +#define FAIRPLAY_H + +#include "logger.h" + +typedef struct fairplay_s fairplay_t; + +fairplay_t *fairplay_init(logger_t *logger); +int fairplay_setup(fairplay_t *fp, const unsigned char req[16], unsigned char res[142]); +int fairplay_handshake(fairplay_t *fp, const unsigned char req[164], unsigned char res[32]); +int fairplay_decrypt(fairplay_t *fp, const unsigned char input[72], unsigned char output[16]); +void fairplay_destroy(fairplay_t *fp); + +#endif diff --git a/lib/global.h b/lib/global.h new file mode 100644 index 0000000..4f022b4 --- /dev/null +++ b/lib/global.h @@ -0,0 +1,10 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +#define GLOBAL_FEATURES 0x7 +#define GLOBAL_MODEL "AppleTV2,1" +#define GLOBAL_VERSION "130.14" + +#define MAX_HWADDR_LEN 6 + +#endif diff --git a/lib/netutils.h b/lib/netutils.h new file mode 100644 index 0000000..63854ad --- /dev/null +++ b/lib/netutils.h @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2011-2012 Juho Vähä-Herttua + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#ifndef NETUTILS_H +#define NETUTILS_H + +int netutils_init(); +void netutils_cleanup(); + +int netutils_init_socket(unsigned short *port, int use_ipv6, int use_udp); +unsigned char *netutils_get_address(void *sockaddr, int *length); +int netutils_parse_address(int family, const char *src, void *dst, int dstlen); + +#endif diff --git a/lib/utils.h b/lib/utils.h new file mode 100644 index 0000000..58ded9e --- /dev/null +++ b/lib/utils.h @@ -0,0 +1,23 @@ +/** + * Copyright (C) 2011-2012 Juho Vähä-Herttua + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#ifndef UTILS_H +#define UTILS_H + +char *utils_strsep(char **stringp, const char *delim); +int utils_read_file(char **dst, const char *pemstr); +int utils_hwaddr_raop(char *str, int strlen, const char *hwaddr, int hwaddrlen); +int utils_hwaddr_airplay(char *str, int strlen, const char *hwaddr, int hwaddrlen); +char *utils_parse_hex(const char *str, int str_len, int *data_len); +#endif \ No newline at end of file