2016-01-14 17:17:15 +01:00
|
|
|
/****************************************************************************
|
2018-06-08 15:07:21 +02:00
|
|
|
* libs/libc/netdb/lib_dnsinit.c
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2017-04-03 01:46:22 +02:00
|
|
|
#include <string.h>
|
2016-01-14 17:17:15 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2016-01-14 22:12:42 +01:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
2022-04-01 06:26:30 +02:00
|
|
|
#include <nuttx/sched.h>
|
2022-05-29 17:59:14 +02:00
|
|
|
#include <nuttx/mutex.h>
|
2016-01-14 17:17:15 +01:00
|
|
|
#include "netdb/lib_dns.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-04-24 11:21:37 +02:00
|
|
|
/* Protects DNS cache, nameserver list and notify list. */
|
2019-03-19 17:02:10 +01:00
|
|
|
|
2022-05-29 17:59:14 +02:00
|
|
|
static rmutex_t g_dns_lock = NXRMUTEX_INITIALIZER;
|
2016-01-14 17:17:15 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2022-11-09 18:23:22 +01:00
|
|
|
* Name: dns_lock
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2022-05-29 17:59:14 +02:00
|
|
|
* Take the DNS lock, ignoring errors due to the receipt of signals.
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-11-09 18:23:22 +01:00
|
|
|
void dns_lock(void)
|
2016-01-14 17:17:15 +01:00
|
|
|
{
|
2022-05-29 17:59:14 +02:00
|
|
|
nxrmutex_lock(&g_dns_lock);
|
2016-01-14 17:17:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2022-11-09 18:23:22 +01:00
|
|
|
* Name: dns_unlock
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2022-05-29 17:59:14 +02:00
|
|
|
* Release the DNS lock
|
2016-01-14 17:17:15 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-11-09 18:23:22 +01:00
|
|
|
void dns_unlock(void)
|
2016-01-14 17:17:15 +01:00
|
|
|
{
|
2022-05-29 17:59:14 +02:00
|
|
|
nxrmutex_unlock(&g_dns_lock);
|
2016-01-14 17:17:15 +01:00
|
|
|
}
|