00001 /* 00002 * hdhomerun_control.h 00003 * 00004 * Copyright © 2006 Silicondust USA Inc. <www.silicondust.com>. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 3 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * As a special exception to the GNU Lesser General Public License, 00020 * you may link, statically or dynamically, an application with a 00021 * publicly distributed version of the Library to produce an 00022 * executable file containing portions of the Library, and 00023 * distribute that executable file under terms of your choice, 00024 * without any of the additional requirements listed in clause 4 of 00025 * the GNU Lesser General Public License. 00026 * 00027 * By "a publicly distributed version of the Library", we mean 00028 * either the unmodified Library as distributed by Silicondust, or a 00029 * modified version of the Library that is distributed under the 00030 * conditions defined in the GNU Lesser General Public License. 00031 */ 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 struct hdhomerun_control_sock_t; 00037 00038 /* 00039 * Create a control socket. 00040 * 00041 * This function will not attempt to connect to the device. 00042 * The connection will be established when first used. 00043 * 00044 * uint32_t device_id = 32-bit device id of device. Set to HDHOMERUN_DEVICE_ID_WILDCARD to match any device ID. 00045 * uint32_t device_ip = IP address of device. Set to 0 to auto-detect. 00046 * struct hdhomerun_debug_t *dbg: Pointer to debug logging object. May be NULL. 00047 * 00048 * Returns a pointer to the newly created control socket. 00049 * 00050 * When no longer needed, the socket should be destroyed by calling hdhomerun_control_destroy. 00051 */ 00052 extern LIBTYPE struct hdhomerun_control_sock_t *hdhomerun_control_create(uint32_t device_id, uint32_t device_ip, struct hdhomerun_debug_t *dbg); 00053 extern LIBTYPE void hdhomerun_control_destroy(struct hdhomerun_control_sock_t *cs); 00054 00055 /* 00056 * Get the actual device id or ip of the device. 00057 * 00058 * Returns 0 if the device id cannot be determined. 00059 */ 00060 extern LIBTYPE uint32_t hdhomerun_control_get_device_id(struct hdhomerun_control_sock_t *cs); 00061 extern LIBTYPE uint32_t hdhomerun_control_get_device_ip(struct hdhomerun_control_sock_t *cs); 00062 extern LIBTYPE uint32_t hdhomerun_control_get_device_id_requested(struct hdhomerun_control_sock_t *cs); 00063 extern LIBTYPE uint32_t hdhomerun_control_get_device_ip_requested(struct hdhomerun_control_sock_t *cs); 00064 00065 extern LIBTYPE void hdhomerun_control_set_device(struct hdhomerun_control_sock_t *cs, uint32_t device_id, uint32_t device_ip); 00066 00067 /* 00068 * Get the local machine IP address used when communicating with the device. 00069 * 00070 * This function is useful for determining the IP address to use with set target commands. 00071 * 00072 * Returns 32-bit IP address with native endianness, or 0 on error. 00073 */ 00074 extern LIBTYPE uint32_t hdhomerun_control_get_local_addr(struct hdhomerun_control_sock_t *cs); 00075 00076 /* 00077 * Low-level communication. 00078 */ 00079 extern LIBTYPE int hdhomerun_control_send_recv(struct hdhomerun_control_sock_t *cs, struct hdhomerun_pkt_t *tx_pkt, struct hdhomerun_pkt_t *rx_pkt, uint16_t type); 00080 00081 /* 00082 * Get/set a control variable on the device. 00083 * 00084 * const char *name: The name of var to get/set (c-string). The supported vars is device/firmware dependant. 00085 * const char *value: The value to set (c-string). The format is device/firmware dependant. 00086 00087 * char **pvalue: If provided, the caller-supplied char pointer will be populated with a pointer to the value 00088 * string returned by the device, or NULL if the device returned an error string. The string will remain 00089 * valid until the next call to a control sock function. 00090 * char **perror: If provided, the caller-supplied char pointer will be populated with a pointer to the error 00091 * string returned by the device, or NULL if the device returned an value string. The string will remain 00092 * valid until the next call to a control sock function. 00093 * 00094 * Returns 1 if the operation was successful (pvalue set, perror NULL). 00095 * Returns 0 if the operation was rejected (pvalue NULL, perror set). 00096 * Returns -1 if a communication error occurs. 00097 */ 00098 extern LIBTYPE int hdhomerun_control_get(struct hdhomerun_control_sock_t *cs, const char *name, char **pvalue, char **perror); 00099 extern LIBTYPE int hdhomerun_control_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror); 00100 extern LIBTYPE int hdhomerun_control_set_with_lockkey(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror); 00101 00102 /* 00103 * Upload new firmware to the device. 00104 * 00105 * FILE *upgrade_file: File pointer to read from. The file must have been opened in binary mode for reading. 00106 * 00107 * Returns 1 if the upload succeeded. 00108 * Returns 0 if the upload was rejected. 00109 * Returns -1 if an error occurs. 00110 */ 00111 extern LIBTYPE int hdhomerun_control_upgrade(struct hdhomerun_control_sock_t *cs, FILE *upgrade_file); 00112 00113 #ifdef __cplusplus 00114 } 00115 #endif
1.5.5