summaryrefslogtreecommitdiff
path: root/SmartDeviceLink
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2016-09-28 15:07:17 -0700
committerMuller, Alexander (A.) <amulle19@ford.com>2016-09-28 15:07:17 -0700
commit32b28ede4d624ed9d6ce934c4ec513a2a9e92394 (patch)
tree2a704ce91ea449cd62d1e1d5e7336fdf8d5fa295 /SmartDeviceLink
parent4a77f0cf6de1e85027c45490d96dedc023ac7b70 (diff)
downloadsdl_ios-32b28ede4d624ed9d6ce934c4ec513a2a9e92394.tar.gz
Initial removal of SDLSiphonServer
Diffstat (limited to 'SmartDeviceLink')
-rw-r--r--SmartDeviceLink/SDLDebugTool.m6
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m2
-rw-r--r--SmartDeviceLink/SDLLifecycleConfiguration.h1
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m13
-rw-r--r--SmartDeviceLink/SDLProxy.h3
-rw-r--r--SmartDeviceLink/SDLProxy.m11
-rw-r--r--SmartDeviceLink/SDLSiphonServer.h20
-rw-r--r--SmartDeviceLink/SDLSiphonServer.m452
-rw-r--r--SmartDeviceLink/SmartDeviceLink.h1
9 files changed, 2 insertions, 507 deletions
diff --git a/SmartDeviceLink/SDLDebugTool.m b/SmartDeviceLink/SDLDebugTool.m
index 8bf8c7bda..c696ac6b5 100644
--- a/SmartDeviceLink/SDLDebugTool.m
+++ b/SmartDeviceLink/SDLDebugTool.m
@@ -5,8 +5,6 @@
#import "NSThread+ThreadIndex.h"
#import "SDLHexUtility.h"
#import "SDLRPCMessage.h"
-#import "SDLSiphonServer.h"
-
@interface SDLDebugTool ()
@@ -171,10 +169,6 @@
if ((output & SDLDebugOutput_File) == SDLDebugOutput_File) {
[SDLDebugTool writeToLogFile:outputString];
}
-
- //Output To Siphon
- [SDLSiphonServer init];
- [SDLSiphonServer _siphonNSLogData:outputString];
}
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index 5cf4ceb21..a55fccf0b 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -11,7 +11,6 @@
#import "SDLIAPSession.h"
#import "SDLIAPTransport.h"
#import "SDLIAPTransport.h"
-#import "SDLSiphonServer.h"
#import "SDLStreamDelegate.h"
#import "SDLTimer.h"
#import <CommonCrypto/CommonDigest.h>
@@ -51,7 +50,6 @@ int const streamOpenTimeoutSeconds = 2;
_transmit_queue = dispatch_queue_create("com.sdl.transport.iap.transmit", DISPATCH_QUEUE_SERIAL);
[self sdl_startEventListening];
- [SDLSiphonServer init];
}
[SDLDebugTool logInfo:@"SDLIAPTransport Init"];
diff --git a/SmartDeviceLink/SDLLifecycleConfiguration.h b/SmartDeviceLink/SDLLifecycleConfiguration.h
index 638c1703a..09dbd8fac 100644
--- a/SmartDeviceLink/SDLLifecycleConfiguration.h
+++ b/SmartDeviceLink/SDLLifecycleConfiguration.h
@@ -22,7 +22,6 @@ typedef NS_OPTIONS(NSUInteger, SDLLogOutput) {
SDLLogOutputNone = 0,
SDLLogOutputConsole = 1 << 0,
SDLLogOutputFile = 1 << 1,
- SDLLogOutputSiphon = 1 << 2
};
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 718f8c330..75e77ecff 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -420,7 +420,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
return YES;
}
- + (void)sdl_updateLoggingWithFlags : (SDLLogOutput)logFlags {
++ (void)sdl_updateLoggingWithFlags:(SDLLogOutput)logFlags {
[SDLDebugTool disable];
if ((logFlags & SDLLogOutputConsole) == SDLLogOutputConsole) {
@@ -432,15 +432,6 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
} else {
[SDLDebugTool disableDebugToLogFile];
}
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ((logFlags & SDLLogOutputSiphon) == SDLLogOutputSiphon) {
- [SDLProxy enableSiphonDebug];
- } else {
- [SDLProxy disableSiphonDebug];
- }
-#pragma clang diagnostic pop
}
@@ -483,4 +474,4 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
@end
-NS_ASSUME_NONNULL_END \ No newline at end of file
+NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLProxy.h b/SmartDeviceLink/SDLProxy.h
index 05da1c2b5..ed9ae4052 100644
--- a/SmartDeviceLink/SDLProxy.h
+++ b/SmartDeviceLink/SDLProxy.h
@@ -48,9 +48,6 @@ __deprecated_msg("Use SDLManager instead")
- (void)addSecurityManagers:(NSArray<Class> *)securityManagerClasses forAppId:(NSString *)appId;
-+ (void)enableSiphonDebug;
-+ (void)disableSiphonDebug;
-
/**
* Puts data into a file on the module
* @abstract Performs a putFile for a given input stream, performed in chunks, for handling very large files.
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index a631d0475..06547736a 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -37,7 +37,6 @@
#import "SDLRPCResponse.h"
#import "SDLRegisterAppInterfaceResponse.h"
#import "SDLRequestType.h"
-#import "SDLSiphonServer.h"
#import "SDLStreamingMediaManager.h"
#import "SDLSystemContext.h"
#import "SDLSystemRequest.h"
@@ -811,14 +810,4 @@ const int POLICIES_CORRELATION_ID = 65535;
}
}
-
-#pragma mark - Siphon management
-+ (void)enableSiphonDebug {
- [SDLSiphonServer enableSiphonDebug];
-}
-
-+ (void)disableSiphonDebug {
- [SDLSiphonServer disableSiphonDebug];
-}
-
@end
diff --git a/SmartDeviceLink/SDLSiphonServer.h b/SmartDeviceLink/SDLSiphonServer.h
deleted file mode 100644
index 31033e7eb..000000000
--- a/SmartDeviceLink/SDLSiphonServer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// SDLSiphonServer.h
-//
-
-
-#import <Foundation/Foundation.h>
-
-@interface SDLSiphonServer : NSObject <NSStreamDelegate, NSNetServiceDelegate> {
-}
-
-+ (void)enableSiphonDebug;
-+ (void)disableSiphonDebug;
-+ (bool)_siphonRawTransportDataFromApp:(const void *)msgBytes msgBytesLength:(int)msgBytesLength;
-+ (bool)_siphonRawTransportDataFromSDL:(const void *)msgBytes msgBytesLength:(int)msgBytesLength;
-+ (bool)_siphonNSLogData:(NSString *)textToLog;
-+ (bool)_siphonFormattedTraceData:(NSString *)traceData;
-+ (bool)_siphonIsActive;
-+ (void)init;
-+ (void)dealloc;
-
-@end
diff --git a/SmartDeviceLink/SDLSiphonServer.m b/SmartDeviceLink/SDLSiphonServer.m
deleted file mode 100644
index 15367be41..000000000
--- a/SmartDeviceLink/SDLSiphonServer.m
+++ /dev/null
@@ -1,452 +0,0 @@
-// SDLSiphonServer.m
-//
-
-
-/*******************************
- * Description:
- * This class opens a socket on port 7474.
- * The 'sendSiphonData' Function will
- * write to the socket that the SDL Relay Sniffer is
- * listening on.
- ******************************/
-
-//#define ZERO_CONFIG //Uncomment when implementing zero-config.
-//#define DEBUG_SIPHON //Uncomment to have output to SDLDebugTool.
-
-#import "SDLSiphonServer.h"
-#import "SDLDebugTool.h"
-#include <CFNetwork/CFNetwork.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-typedef enum {
- fromApp = 0x01,
- fromSDL = 0x00,
- appLog = 0x02,
- formattedTrace = 0x03
-} SiphonDataType;
-
-const Byte siphonMsgVersionNumber = 1;
-volatile int siphonSocket = 0;
-NSObject *siphonLock = nil;
-CFSocketRef _listeningSocket;
-NSNetService *netService = nil;
-volatile bool initStarted = false;
-bool siphonServerEnabled = false;
-bool sendingFormattedTrace = false;
-NSDate *startTimeStamp;
-int FIRST_PORT_TO_ATTEMPT_CONNECTION = 7474;
-
-void _closeSiphonSocket();
-bool _sendDataToSiphonSocket(int soc, const void *pData, int dataLength);
-bool _sendSiphonData(const void *dataBytes, int dataBytesLength, SiphonDataType siphonDataType);
-void _startServerOnPort(int port);
-void _stopServer(NSString *reason);
-
-
-@implementation SDLSiphonServer
-
-// Model currently counts on init being called before any apps call _siphonNSLogData()
-// The following is not thread safe (i.e. two threads could create siphon lock),
-// but will assume for now that we won't have two transports created in the same proxy.
-+ (void)init {
- if (initStarted) {
- return;
- } // end-if
-
- if (!siphonLock) {
- siphonLock = [NSData alloc];
- } // end-if
-
- @synchronized(siphonLock) {
- if (initStarted) {
- return;
- }
-
- initStarted = true;
-
- startTimeStamp = [NSDate date];
-
- _closeSiphonSocket();
-
- _startServerOnPort(FIRST_PORT_TO_ATTEMPT_CONNECTION);
- }
-}
-
-+ (void)enableSiphonDebug {
- siphonServerEnabled = true;
-}
-
-+ (void)disableSiphonDebug {
- siphonServerEnabled = false;
-}
-
-void _closeSiphonSocket() {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: Resetting siphon socket ..."];
-#endif
- if (siphonLock) {
- @synchronized(siphonLock) {
- if (siphonSocket) {
- close(siphonSocket);
- siphonSocket = 0;
- } // end-if
- } // end-lock
- } // end-if
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: siphon socket reset complete"];
-#endif
-} // end-method
-
-+ (void)dealloc {
-#ifdef ZERO_CONFIG
- _stopServer(@"Shutting Down");
-#endif
-}
-
-+ (bool)_siphonIsActive {
- if (siphonSocket == 0) {
- return NO;
- }
- return YES;
-}
-
-
-+ (bool)_siphonFormattedTraceData:(NSString *)traceData {
- if ((traceData == NULL) || (traceData.length == 0)) {
- return NO;
- } // end-if
-
- NSData *traceBytes = [traceData dataUsingEncoding:NSUTF8StringEncoding];
-
- if (traceBytes == nil) {
- return NO;
- } // end-if
-
- bool dataSent = NO;
-
- sendingFormattedTrace = true;
-
- dataSent = _sendSiphonData(traceBytes.bytes, (int)traceBytes.length, formattedTrace);
-
- return dataSent;
-} // end-method
-
-+ (bool)_siphonNSLogData:(NSString *)textToLog {
- if ((textToLog == NULL) || (textToLog.length == 0)) {
- return NO;
- } // end-if
-
- NSData *textBytes = [textToLog dataUsingEncoding:NSUTF8StringEncoding];
-
- if (textBytes == nil) {
- return NO;
- } // end-if
-
- bool dataSent = NO;
-
- dataSent = _sendSiphonData(textBytes.bytes, (int)textBytes.length, appLog);
-
- return dataSent;
-} // end-method
-
-+ (bool)_siphonRawTransportDataFromApp:(const void *)msgBytes msgBytesLength:(int)msgBytesLength {
- if (sendingFormattedTrace) {
- return false;
- } // end-if
-
- if (msgBytes == NULL || msgBytesLength == 0) {
- return false;
- } // end-if
-
- return _sendSiphonData(msgBytes, msgBytesLength, fromApp);
-}
-
-+ (bool)_siphonRawTransportDataFromSDL:(const void *)msgBytes msgBytesLength:(int)msgBytesLength {
- if (sendingFormattedTrace) {
- return false;
- } // end-if
-
- if (msgBytes == NULL || msgBytesLength == 0) {
- return false;
- } // end-if
-
- return _sendSiphonData(msgBytes, msgBytesLength, fromSDL);
-}
-
-bool _sendSiphonData(const void *dataBytes, int dataBytesLength, SiphonDataType siphonDataType) {
- bool wasSent = NO;
-
- if (dataBytes == NULL || dataBytesLength == 0 || !siphonServerEnabled) {
- return false;
- } // end-if
-
- NSDate *currentTime = [NSDate date];
- NSTimeInterval deltaTimeMillis = ([currentTime timeIntervalSinceDate:startTimeStamp] * 1000.0);
- uint32_t integerDeltaTimeMillis = ((uint32_t)deltaTimeMillis);
-
- integerDeltaTimeMillis = htonl(integerDeltaTimeMillis);
-
- if (siphonLock) {
- @synchronized(siphonLock) {
- if (siphonSocket) {
- Byte sdt = (Byte)siphonDataType;
- sdt = (Byte)0x80 | sdt;
- uint32_t sizeBytes = htonl(dataBytesLength + sizeof(sdt) + sizeof(integerDeltaTimeMillis) + sizeof(siphonMsgVersionNumber));
-
- wasSent = _sendDataToSiphonSocket(siphonSocket, &sizeBytes, sizeof(sizeBytes));
-
- if (wasSent) {
- wasSent = _sendDataToSiphonSocket(siphonSocket, &sdt, sizeof(sdt));
- }
-
- if (wasSent) {
- wasSent = _sendDataToSiphonSocket(siphonSocket, &siphonMsgVersionNumber, sizeof(siphonMsgVersionNumber));
- }
-
- if (wasSent) {
- wasSent = _sendDataToSiphonSocket(siphonSocket, &integerDeltaTimeMillis, sizeof(integerDeltaTimeMillis));
- }
-
- if (wasSent) {
- wasSent = _sendDataToSiphonSocket(siphonSocket, dataBytes, dataBytesLength);
- }
-
- if (wasSent) {
- return YES;
- } else {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: failure sending to siphon socket"];
-#endif
- _closeSiphonSocket();
- return NO;
- } // end-if
- } else {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: siphon socket is NULL"];
-#endif
- } // end-if
- } //end Synchronized
- } // end-if
- return NO;
-
-} // end-method
-
-bool _sendDataToSiphonSocket(int soc, const void *pData, int dataLength) {
- int bytesRemainingToSend = dataLength;
- ssize_t bytesSent = 0;
- const UInt8 *pd = pData;
-
- if (pData == NULL || dataLength == 0) {
- return false;
- } // end-if
-
- while (bytesRemainingToSend > 0) {
- if (soc) {
- bytesSent = send(soc, pd, bytesRemainingToSend, 0);
-
- if (bytesSent == -1) {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: got bytesSent==-1 on send(siphonSocket)"];
-#endif
- return NO;
- } // end-if
-
- bytesRemainingToSend -= bytesSent;
- pd += bytesSent;
- } // end-if
-
- } // end-while
-
- return YES;
-
-} // end-method
-
-
-void _serverDidStartOnPort(int port) {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: server started on port: %d", port];
-#endif
-}
-
-#ifdef ZERO_CONFIG
-
-#pragma mark
-#pragma mark Server
-
-- (void)_didSendData:(NSData *)data {
-}
-
-void _serverDidStopWithReason(NSString *reason) {
-}
-
-- (void)_updateStatus:(NSString *)statusString {
- [SDLDebugTool logFormat:@"siphon: %@", statusString];
-}
-
-- (void)_SendDidStopWithStatus:(NSString *)statusString {
- [SDLDebugTool logInfo:@"siphon: server configured for output"];
-}
-
-- (BOOL)isStarted {
- return (netService != nil);
-}
-#endif
-
-
-void _acceptConnection(int fd) {
- if (siphonLock) {
- @synchronized(siphonLock) {
- int socketOps = 1;
-
- _closeSiphonSocket();
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logFormat:@"siphon: storing newly accepted siphon socket handle %08x ...", fd];
-#endif
- siphonSocket = fd;
-
- setsockopt(siphonSocket, SOL_SOCKET, SO_NOSIGPIPE, (void *)&socketOps, sizeof(int));
- [SDLDebugTool logInfo:@"Siphon connected." withType:SDLDebugType_Debug];
-
- } // end-lock
- } // end-if
- return;
-}
-
-static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) {
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logInfo:@"siphon: accepted siphon connection ..."];
-#endif
-
-#pragma unused(type)
- assert(type == kCFSocketAcceptCallBack);
-#pragma unused(address)
- assert(data != NULL);
-
-#pragma unused(s)
- assert(s == _listeningSocket);
-
- _acceptConnection(*(int *)data);
-}
-
-
-#ifdef ZERO_CONFIG
-- (void)netService:(NSNetService *)sender didNotPublish:(NSDictionary *)errorDict {
-#pragma unused(sender)
- assert(sender == netService);
-#pragma unused(errorDict)
-
- _stopServer(@"Registration failed");
-}
-#endif
-
-void _startServerOnPort(int port) {
- BOOL success;
- int err;
- int fd;
- struct sockaddr_in addr;
- int const retryLimit = 1000;
-
- fd = socket(AF_INET, SOCK_STREAM, 0);
- success = (fd != -1);
-
- if (success) {
- memset(&addr, 0, sizeof(addr));
- addr.sin_len = sizeof(addr);
- addr.sin_family = AF_INET;
-
- addr.sin_addr.s_addr = INADDR_ANY;
-
- bool openPortFound = false;
- short bindPort = (short)port;
- success = false;
- for (int retryCount = 0; retryCount < retryLimit && !openPortFound; retryCount++) {
- addr.sin_port = htons(bindPort);
- err = bind(fd, (const struct sockaddr *)&addr, sizeof(addr));
- if (err == 0) {
- openPortFound = true;
- success = (err == 0);
- // port = bindPort;
- } else {
- bindPort++;
- }
- } // end-for
- }
- if (success) {
- err = listen(fd, 5);
- success = (err == 0);
- }
- if (success) {
- socklen_t addrLen;
-
- addrLen = sizeof(addr);
- err = getsockname(fd, (struct sockaddr *)&addr, &addrLen);
- success = (err == 0);
-
- if (success) {
- assert(addrLen == sizeof(addr));
- // port = ntohs(addr.sin_port);
- }
-#ifdef DEBUG_SIPHON
- [SDLDebugTool logFormat:@"siphon: my port is %d ", port];
-#endif
- }
- if (success) {
- _listeningSocket = CFSocketCreateWithNative(
- NULL,
- fd,
- kCFSocketAcceptCallBack,
- AcceptCallback,
- NULL);
- success = (_listeningSocket != NULL);
-
- if (success) {
- CFRunLoopSourceRef rls;
- // fd = -1;
- rls = CFSocketCreateRunLoopSource(NULL, _listeningSocket, 0);
- assert(rls != NULL);
- CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
- CFRelease(rls);
- }
- }
-
-#ifdef ZERO_CONFIG
-
- if (success) {
- UIDevice *device = [UIDevice currentDevice];
- ;
- NSString *serviceName = [NSString stringWithFormat:@"%@_%d ", device.name, port];
- netService = [[[NSNetService alloc] initWithDomain:@"local." type:@"_sync._tcp." name:serviceName port:port] autorelease];
- success = (netService != nil);
- }
- if (success) {
- [netService publishWithOptions:NSNetServiceNoAutoRename];
- }
-
- if (success) {
- assert(port != 0);
- _serverDidStartOnPort(port);
- } else {
- _stopServer(@"Start failed");
- if (fd != -1) {
- assert(startFailed == 0);
- }
- }
-
-#endif
-}
-
-void _stopServer(NSString *reason) {
-#ifdef ZERO_CONFIG
- if (netService != nil) {
- [netService stop];
- netService = nil;
- }
- _serverDidStopWithReason(reason);
-#endif
-}
-
-@end
diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h
index 176bee596..535e15b40 100644
--- a/SmartDeviceLink/SmartDeviceLink.h
+++ b/SmartDeviceLink/SmartDeviceLink.h
@@ -26,7 +26,6 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[];
#import "SDLConsoleController.h"
#import "SDLDebugTool.h"
#import "SDLDebugToolConsole.h"
-#import "SDLSiphonServer.h"
/***** Transport *****/
#import "SDLAbstractTransport.h"