Ejemplo n.º 1
0
JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleDNSRecord_Remove( JNIEnv *pEnv, jobject pThis)
{
	jclass					cls = (*pEnv)->GetObjectClass( pEnv, pThis);
	jfieldID				ownerField = (*pEnv)->GetFieldID( pEnv, cls, "fOwner", "Lcom/apple/dnssd/AppleService;");
	jfieldID				recField = (*pEnv)->GetFieldID( pEnv, cls, "fRecord", "J");
	OpContext				*pContext = NULL;
	DNSServiceErrorType		err = kDNSServiceErr_NoError;
	DNSRecordRef			recRef = NULL;

	if ( ownerField != 0)
	{
		jobject		ownerObj = (*pEnv)->GetObjectField( pEnv, pThis, ownerField);
		jclass		ownerClass = (*pEnv)->GetObjectClass( pEnv, ownerObj);
		jfieldID	contextField = (*pEnv)->GetFieldID( pEnv, ownerClass, "fNativeContext", "J");
		if ( contextField != 0)
			pContext = (OpContext*) (long) (*pEnv)->GetLongField(pEnv, ownerObj, contextField);
	}
	if ( recField != 0)
		recRef = (DNSRecordRef) (long) (*pEnv)->GetLongField(pEnv, pThis, recField);
	if ( pContext == NULL || pContext->ServiceRef == NULL)
		return kDNSServiceErr_BadParam;

	err = DNSServiceRemoveRecord( pContext->ServiceRef, recRef, 0);

	return err;
}
Ejemplo n.º 2
0
static void myTimerCallBack(void)
{
    DNSServiceErrorType err = kDNSServiceErr_Unknown;

    switch (operation)
    {
    case 'A':
    {
        switch (addtest)
        {
        case 0:
            printf("Adding Test HINFO record\n");
            err = DNSServiceAddRecord(client, &record, 0, kDNSServiceType_HINFO, sizeof(myhinfoW), &myhinfoW[0], 0);
            addtest = 1;
            break;
        case 1:
            printf("Updating Test HINFO record\n");
            err = DNSServiceUpdateRecord(client, record, 0, sizeof(myhinfoX), &myhinfoX[0], 0);
            addtest = 2;
            break;
        case 2:
            printf("Removing Test HINFO record\n");
            err = DNSServiceRemoveRecord(client, record, 0);
            addtest = 0;
            break;
        }
    }
    break;

    case 'U':
    {
        if (updatetest[1] != 'Z') updatetest[1]++;
        else                      updatetest[1] = 'A';
        updatetest[0] = 3 - updatetest[0];
        updatetest[2] = updatetest[1];
        printf("Updating Test TXT record to %c\n", updatetest[1]);
        err = DNSServiceUpdateRecord(client, NULL, 0, 1+updatetest[0], &updatetest[0], 0);
    }
    break;

    case 'N':
    {
        printf("Adding big NULL record\n");
        err = DNSServiceAddRecord(client, &record, 0, kDNSServiceType_NULL, sizeof(bigNULL), &bigNULL[0], 0);
        timeOut = LONG_TIME;
    }
    break;
    }

    if (err != kDNSServiceErr_NoError)
    {
        fprintf(stderr, "DNSService call failed %ld\n", (long int)err);
        stopNow = 1;
    }
}