2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "tethering_private.h"
21 API int tethering_client_clone(tethering_client_h *dest, tethering_client_h origin)
23 _retvm_if(dest == NULL, TETHERING_ERROR_INVALID_PARAMETER,
24 "Parameter(dest) is NULL\n");
26 __tethering_client_h *si = NULL;
28 si = malloc(sizeof(__tethering_client_h));
30 ERR("malloc is failed\n");
31 return TETHERING_ERROR_OUT_OF_MEMORY;
34 memcpy(si, (__tethering_client_h *)origin,
35 sizeof(__tethering_client_h));
37 *dest = (tethering_client_h)si;
39 return TETHERING_ERROR_NONE;
42 API int tethering_client_destroy(tethering_client_h client)
44 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
45 "Parameter(client) is NULL\n");
49 return TETHERING_ERROR_NONE;
52 API int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
54 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
55 "Parameter(client) is NULL\n");
56 _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
57 "Parameter(type) is NULL\n");
59 __tethering_client_h *si = (__tethering_client_h *)client;
61 *type = si->interface;
63 return TETHERING_ERROR_NONE;
66 API int tethering_client_get_name(tethering_client_h client, char **name)
68 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
69 "Parameter(client) is NULL\n");
70 _retvm_if(name == NULL, TETHERING_ERROR_INVALID_PARAMETER,
71 "Parameter(name) is NULL\n");
73 __tethering_client_h *si = (__tethering_client_h *)client;
75 *name = strdup(si->hostname);
77 ERR("strdup is failed\n");
78 return TETHERING_ERROR_OUT_OF_MEMORY;
81 return TETHERING_ERROR_NONE;
84 API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
86 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
87 "Parameter(client) is NULL\n");
88 _retvm_if(ip_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
89 "Parameter(ip_address) is NULL\n");
91 __tethering_client_h *si = (__tethering_client_h *)client;
93 *ip_address = strdup(si->ip);
94 if (*ip_address == NULL) {
95 ERR("strdup is failed\n");
96 return TETHERING_ERROR_OUT_OF_MEMORY;
99 return TETHERING_ERROR_NONE;
102 API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
104 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
105 "Parameter(client) is NULL\n");
106 _retvm_if(mac_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
107 "Parameter(mac_address) is NULL\n");
109 __tethering_client_h *si = (__tethering_client_h *)client;
111 *mac_address = strdup(si->mac);
112 if (*mac_address == NULL) {
113 ERR("strdup is failed\n");
114 return TETHERING_ERROR_OUT_OF_MEMORY;
117 return TETHERING_ERROR_NONE;