Example #1
0
File: parse_url.c Project: aosm/smb
/* 
 * If URL contains a port then we should get it and set the correct flag.
 *
 *	URL "smb://*****:*****@server:445/share" set the port to 445.
 *
 */
static void SetPortNumberFromURL(struct smb_ctx *ctx, CFURLRef url)
{
	SInt32 port = CFURLGetPortNumber(url);
	
	/* No port defined in the URL */
	if (port == -1)
		return;
	/* They supplied a port number use it and only it */
	ctx->prefs.tcp_port = port;
	ctx->prefs.tryBothPorts = FALSE;
	smb_log_info("Setting port number to %d", ASL_LEVEL_DEBUG, ctx->prefs.tcp_port);	
}
Example #2
0
 CF::Number URL::GetPortNumber( void )
 {
     CF::Number n;
     
     if( this->_cfObject == NULL )
     {
         return 0;
     }
     
     n.SetSInt32Value( CFURLGetPortNumber( this->_cfObject ) );
     
     return n;
 }
Example #3
0
CFNetDiagnosticRef CFNetDiagnosticCreateWithURL(CFAllocatorRef allocator, CFURLRef url) {
	CFMutableDictionaryRef retval;
	SInt32 port = 0;
	
	retval = CFDictionaryCreateMutable(allocator, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
	
	if(retval != NULL && CFURLCanBeDecomposed(url)) {
		port = CFURLGetPortNumber(url);
		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticNameKey, CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleNameKey), retval);		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticBundleKey, CFBundleGetIdentifier( CFBundleGetMainBundle() ), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticRemoteHostKey, CFURLCopyHostName(url), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticProtocolKey, CFURLCopyScheme(url), retval);
		_CFNetDiagnosticSetDictionaryKeyAndReleaseIfNotNull(_CFNetDiagnosticPortKey, CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &port), retval);
		
		_CFNetDiagnosticSetDictionaryKeyIfNotNull(_CFNetDiagnosticMethodKey, CFSTR("CFNetDiagnosticCreateWithURL"), retval);
	}
	
	return (CFNetDiagnosticRef)retval;
}
Example #4
0
static netfsError ParseURL9P(CFURLRef url, CFDictionaryRef * params)
{
        CFMutableDictionaryRef dict;
        CFStringRef str;
        SInt32 port;
        int e;

        TRACE();
        if (url == NULL || params == NULL || !CFURLCanBeDecomposed(url))
                return EINVAL;

        DEBUG("url=%s", NetFSCFStringtoCString(CFURLGetString(url)));
        *params = dict = CreateDict9P();
        if (dict == NULL)
                return ENOMEM;

        /* mandatory */
        str = CFURLCopyScheme(url);
        if (str == NULL)
                goto error;
        CFDictionarySetValue(dict, kNetFSSchemeKey, str);
        CFRelease(str);

        str = CFURLCopyHostName(url);
        if (str == NULL)
                goto error;
        CFDictionarySetValue(dict, kNetFSHostKey, str);
        CFRelease(str);

        /* optional */
        port = CFURLGetPortNumber(url);
        if (port != -1) {
                str =
                    CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
                                             CFSTR("%d"), (int)port);
                if (str == NULL)
                        goto error;
                CFDictionarySetValue(dict, kNetFSAlternatePortKey, str);
                CFRelease(str);
        }

        str = CFURLCopyUserName(url);
        if (str != NULL) {
                CFDictionarySetValue(dict, kNetFSUserNameKey, str);
                CFRelease(str);
        }

        str = CFURLCopyPassword(url);
        if (str != NULL) {
                CFDictionarySetValue(dict, kNetFSPasswordKey, str);
                CFRelease(str);
        }
/*
	str = CFURLCopyPath(url);
	if (str != NULL) {
		CFDictionarySetValue(dict, kNetFSPathKey, str);
		CFRelease(str);
	}
*/
        return 0;

 error:
        e = errno;
        *params = NULL;
        CFRelease(dict);
        return e;
}
Example #5
0
IPPort URL::port(IPPort defaultPort) const
{
    SInt32 port = CFURLGetPortNumber(ref);
    return (port == -1) ? defaultPort : port;
}