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 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
25 _retvm_if(dest == NULL, TETHERING_ERROR_INVALID_PARAMETER,
26 "Parameter(dest) is NULL\n");
28 __tethering_client_h *si = NULL;
29 __tethering_client_h *source = NULL;
31 source = (__tethering_client_h *)origin;
33 si = malloc(sizeof(__tethering_client_h));
35 ERR("malloc is failed\n");
36 return TETHERING_ERROR_OUT_OF_MEMORY;
39 memcpy(si, source, sizeof(__tethering_client_h));
40 si->hostname = g_strdup(source->hostname);
41 if (si->hostname == NULL) {
42 ERR("malloc is failed\n");
44 return TETHERING_ERROR_OUT_OF_MEMORY;
47 *dest = (tethering_client_h)si;
49 return TETHERING_ERROR_NONE;
52 API int tethering_client_destroy(tethering_client_h client)
54 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
56 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
57 "Parameter(client) is NULL\n");
59 __tethering_client_h *si = NULL;
61 si = (__tethering_client_h *)client;
67 return TETHERING_ERROR_NONE;
70 API int tethering_client_get_tethering_type(tethering_client_h client, tethering_type_e *type)
72 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
74 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
75 "Parameter(client) is NULL\n");
76 _retvm_if(type == NULL, TETHERING_ERROR_INVALID_PARAMETER,
77 "Parameter(type) is NULL\n");
79 __tethering_client_h *si = (__tethering_client_h *)client;
81 *type = si->interface;
83 return TETHERING_ERROR_NONE;
86 API int tethering_client_get_name(tethering_client_h client, char **name)
88 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
90 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
91 "Parameter(client) is NULL\n");
92 _retvm_if(name == NULL, TETHERING_ERROR_INVALID_PARAMETER,
93 "Parameter(name) is NULL\n");
95 __tethering_client_h *si = (__tethering_client_h *)client;
97 *name = strdup(si->hostname);
99 ERR("strdup is failed\n");
100 return TETHERING_ERROR_OUT_OF_MEMORY;
103 return TETHERING_ERROR_NONE;
106 API int tethering_client_get_ip_address(tethering_client_h client, tethering_address_family_e address_family, char **ip_address)
108 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
110 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
111 "Parameter(client) is NULL\n");
112 _retvm_if(ip_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
113 "Parameter(ip_address) is NULL\n");
115 __tethering_client_h *si = (__tethering_client_h *)client;
117 *ip_address = strdup(si->ip);
118 if (*ip_address == NULL) {
119 ERR("strdup is failed\n");
120 return TETHERING_ERROR_OUT_OF_MEMORY;
123 return TETHERING_ERROR_NONE;
126 API int tethering_client_get_mac_address(tethering_client_h client, char **mac_address)
128 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
130 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
131 "Parameter(client) is NULL\n");
132 _retvm_if(mac_address == NULL, TETHERING_ERROR_INVALID_PARAMETER,
133 "Parameter(mac_address) is NULL\n");
135 __tethering_client_h *si = (__tethering_client_h *)client;
137 *mac_address = strdup(si->mac);
138 if (*mac_address == NULL) {
139 ERR("strdup is failed\n");
140 return TETHERING_ERROR_OUT_OF_MEMORY;
143 return TETHERING_ERROR_NONE;
146 API int tethering_client_get_time(tethering_client_h client, time_t *timestamp)
148 CHECK_FEATURE_SUPPORTED(TETHERING_FEATURE);
150 _retvm_if(client == NULL, TETHERING_ERROR_INVALID_PARAMETER,
151 "Parameter(client) is NULL\n");
153 __tethering_client_h *si = (__tethering_client_h *)client;
157 return TETHERING_ERROR_NONE;