forked from abrasive/shairport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shairport.h
83 lines (70 loc) · 2.3 KB
/
shairport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __SHAIRPORT_H__
#define __SHAIRPORT_H__
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <openssl/bio.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "socketlib.h"
#include <regex.h>
#include <sys/types.h>
#include <regex.h>
#define HWID_SIZE 6
#define SHAIRPORT_LOG 1
#define LOG_INFO 1
#define LOG_DEBUG 5
#define LOG_DEBUG_V 6
#define LOG_DEBUG_VV 7
struct shairbuffer
{
char *data;
int current;
int maxsize;
int marker;
};
struct keyring
{
char *aeskey;
char *aesiv;
char *fmt;
};
struct comms
{
int in[2];
int out[2];
};
struct connection
{
struct shairbuffer recv;
struct shairbuffer resp;
struct keyring *keys; // Does not point to malloc'd memory.
struct comms *hairtunes;
int clientSocket;
char *password;
};
RSA *loadKey();
int startAvahi(const char *pHwAddr, const char *pServerName, int pPort);
void cleanupBuffers(struct connection *pConnection);
void cleanup(struct connection *pConnection);
void handleClient(int pSock, char *pPassword, char *pHWADDR);
int getAvailChars(struct shairbuffer *pBuf);
char *getTrimmedMalloc(char *pChar, int pSize, int pEndStr, int pAddNL);
char *getTrimmed(char *pChar, int pSize, int pEndStr, int pAddNL, char *pTrimDest);
void initBuffer(struct shairbuffer *pBuf, int pNumChars);
void printBufferInfo(struct shairbuffer *pBuf, int pLevel);
void addToShairBuffer(struct shairbuffer *pBuf, char *pNewBuf);
void addNToShairBuffer(struct shairbuffer *pBuf, char *pNewBuf, int pNofNewBuf);
int readDataFromClient(int pSock, struct shairbuffer *pClientBuffer);
int parseMessage(struct connection *pConn,unsigned char *pIpBin, unsigned int pIpBinLen, char *pHWADDR);
void closePipe(int *pPipe);
void setKeys(struct keyring *pKeys, char *pIV, char* pAESKey, char *pFmtp);
void initConnection(struct connection *pConn, struct keyring *pKeys,
struct comms *pComms, int pSocket, char *pPassword);
void writeDataToClient(int pSock, struct shairbuffer *pResponse);
void propogateCSeq(struct connection *pConn);
int buildAppleResponse(struct connection *pConn, unsigned char *pIpBin, unsigned int pIpBinLen, char *pHwAddr);
void sim(int pLevel, char *pValue1, char *pValue2);
void slog(int pLevel, char *pFormat, ...);
int isLogEnabledFor(int pLevel);
#endif