network.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2007, IRTrans GmbH
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions are met:
00007  *     * Redistributions of source code must retain the above copyright
00008  *       notice, this list of conditions and the following disclaimer. 
00009  *     * Redistributions in binary form must reproduce the above copyright
00010  *       notice, this list of conditions and the following disclaimer in the
00011  *       documentation and/or other materials provided with the distribution. 
00012  *     * Neither the name of IRTrans GmbH nor the
00013  *       names of its contributors may be used to endorse or promote products
00014  *       derived from this software without specific prior written permission. 
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY IRTrans GmbH ``AS IS'' AND ANY
00017  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00019  * DISCLAIMED. IN NO EVENT SHALL IRTrans GmbH BE LIABLE FOR ANY
00020  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00022  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
00025  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  */
00027 
00028 #ifdef LINUX
00029 typedef int SOCKET;
00030 typedef int WSAEVENT;
00031 #endif
00032 
00033 
00034 #define PROTOCOL_VERSION        209
00035 
00036 #define MAX_IR_DEVICES  256
00037 
00038 
00039 #define COMMAND_SEND            1
00040 #define COMMAND_LRNREM          2
00041 #define COMMAND_LRNTIM          3
00042 #define COMMAND_LRNCOM          4
00043 #define COMMAND_CLOSE           5
00044 #define COMMAND_STATUS          6
00045 #define COMMAND_RESEND          7
00046 #define COMMAND_LRNRAW          8
00047 #define COMMAND_LRNRPT          9
00048 #define COMMAND_LRNTOG          10
00049 #define COMMAND_SETSTAT         11
00050 #define COMMAND_LRNLONG         12
00051 #define COMMAND_LRNRAWRPT       13
00052 #define COMMAND_RELOAD          14
00053 #define COMMAND_LCD                     15
00054 #define COMMAND_LEARNSTAT       16
00055 #define COMMAND_TEMP            17
00056 #define COMMAND_GETREMOTES      18
00057 #define COMMAND_GETCOMMANDS     19
00058 #define COMMAND_STORETRANS      20
00059 #define COMMAND_LOADTRANS       21
00060 #define COMMAND_SAVETRANS       22
00061 #define COMMAND_FLASHTRANS      23
00062 #define COMMAND_FUNCTIONS       24
00063 #define COMMAND_TESTCOM         25
00064 #define COMMAND_LONGSEND        26
00065 #define COMMAND_SHUTDOWN        27
00066 #define COMMAND_SENDCCF         28
00067 #define COMMAND_LCDINIT         29
00068 #define COMMAND_SETSWITCH       30
00069 #define COMMAND_STATUSEX        31
00070 #define COMMAND_RESET           32
00071 #define COMMAND_DEVICEDATA      33
00072 #define COMMAND_STARTCLOCK      34
00073 #define COMMAND_LCDSTATUS       35
00074 #define COMMAND_FUNCTIONEX      36
00075 #define COMMAND_MCE_CHARS       37
00076 #define COMMAND_SUSPEND         38
00077 #define COMMAND_RESUME          39
00078 #define COMMAND_DELETECOM       40
00079 #define COMMAND_EMPTY           41
00080 #define COMMAND_SETSTAT2        42
00081 #define COMMAND_STATUSEXN       43
00082 #define COMMAND_BRIGHTNESS      44
00083 #define COMMAND_DEFINECHAR      45
00084 #define COMMAND_STOREIRDB       46
00085 #define COMMAND_FLASHIRDB       47
00086 #define COMMAND_SAVEIRDB        48
00087 #define COMMAND_LOADIRDB        49
00088 #define COMMAND_LED                     50
00089 #define COMMAND_TRANSFILE       51
00090 #define COMMAND_IRDBFILE        52
00091 #define COMMAND_LISTBUS         53
00092 #define COMMAND_SENDCCFSTR      54
00093 #define COMMAND_LEARNDIRECT     55
00094 #define COMMAND_TESTCOMEX       56
00095 #define COMMAND_SENDCCFSTRS     57
00096 #define COMMAND_SETSTATEX       58
00097 #define COMMAND_DELETEREM       59
00098 #define COMMAND_READ_ANALOG 60
00099 #define COMMAND_RS232_SEND      61
00100 #define COMMAND_SENDCCFLONG     62
00101 #define COMMAND_STORETIMER      63
00102 
00103 #define COMMAND_ASCII           65
00104 #define COMMAND_SENDSTRING      's' // 115
00105 
00106 
00107 
00108 
00109 #define STATUS_MESSAGE                  1
00110 #define STATUS_TIMING                   2
00111 #define STATUS_DEVICEMODE               3
00112 #define STATUS_RECEIVE                  4
00113 #define STATUS_LEARN                    5
00114 #define STATUS_REMOTELIST               6
00115 #define STATUS_COMMANDLIST              7
00116 #define STATUS_TRANSLATE                8
00117 #define STATUS_FUNCTION                 9
00118 #define STATUS_DEVICEMODEEX             10
00119 #define STATUS_DEVICEDATA               11
00120 #define STATUS_LCDDATA                  12
00121 #define STATUS_FUNCTIONEX               13
00122 #define STATUS_DEVICEMODEEXN    14
00123 #define STATUS_IRDB                             15
00124 #define STATUS_TRANSLATIONFILE  16
00125 #define STATUS_IRDBFILE                 17
00126 #define STATUS_BUSLIST                  18
00127 #define STATUS_LEARNDIRECT              19
00128 #define STATUS_IRDBFLASH                20
00129 #define STATUS_ANALOGINPUT              21
00130 #define STATUS_RECEIVE_ASCII    22
00131 
00132 #define STATUS_ASCII                    65
00133 
00134 #define FILE_MODE_SAVE                  0
00135 #define FILE_MODE_SAVEAS                1
00136 #define FILE_MODE_OVERWRITE             2
00137 
00138 
00139 #pragma pack(1)
00140 
00141 typedef struct {
00142         uint32_t clientid;
00143         int16_t statuslen;
00144         int16_t statustype;
00145         int16_t adress;
00146     uint8_t align[2];
00147         IRDATA ird;
00148 } IRDATA_BUFFER;
00149 
00150 typedef struct {
00151         uint8_t mode;
00152         uint8_t time_cnt;
00153         uint8_t ir_repeat;
00154         uint8_t repeat_pause;
00155         uint16_t pause_len[TIME_LEN];
00156         uint16_t pulse_len[TIME_LEN];
00157         uint8_t data[CODE_LEN];
00158 } TIMINGDATA;
00159 
00160 typedef struct {
00161         uint8_t netcommand;
00162         uint8_t mode;
00163         uint16_t timeout;
00164         int32_t adress;
00165         int8_t remote[80];
00166         int8_t command[20];
00167         uint8_t trasmit_freq;
00168 } OLD_NETWORKCOMMAND;
00169 
00170 
00171 typedef struct {
00172         uint8_t netcommand;
00173         uint8_t mode;
00174         uint8_t lcdcommand;
00175         uint8_t timeout;
00176         int32_t adress;
00177         uint8_t wid;
00178         uint8_t hgt;
00179         int8_t framebuffer[200];
00180 } OLD_LCDCOMMAND;
00181 
00182 
00183 typedef struct {
00184         uint8_t netcommand;
00185         uint8_t mode;
00186         uint16_t timeout;
00187         int32_t adress;
00188         int32_t protocol_version;
00189         int8_t remote[80];
00190         int8_t command[20];
00191         uint8_t trasmit_freq;
00192 } NETWORKCOMMAND;
00193 
00194 typedef struct {
00195         uint8_t netcommand;
00196         uint8_t mode;
00197         uint16_t timeout;
00198         int32_t adress;
00199         int32_t protocol_version;
00200         uint8_t num;
00201         uint8_t tim_mode;
00202     uint8_t status;
00203     uint8_t year;
00204     uint8_t month;
00205     uint8_t day;
00206     uint8_t hour;
00207     uint8_t min;
00208     uint8_t weekday;
00209         uint8_t remote[81];
00210         uint8_t ircommand[21];
00211         uint8_t ledselect;
00212         uint16_t targetmask;
00213 } TIMERCOMMAND;
00214 
00215 typedef struct {
00216         uint8_t         netcommand;
00217         uint8_t         mode;
00218         uint16_t        timeout;
00219         int32_t         adress;
00220         int32_t         protocol_version;
00221         int8_t          hotremote[80];
00222         int8_t          hotcommand[20];
00223         int8_t          hotremote_2[80];
00224         int8_t          hotcommand_2[20];
00225         int32_t         targetmask;
00226         uint8_t         extmode;
00227         uint8_t         extmode_2;
00228         uint8_t         extmode_3;
00229         uint8_t         extmode_4;
00230         uint8_t         wakeup_mac[6];
00231 } MODUSCOMMAND;
00232 
00233 
00234 // Adress:
00235 // xxxx ffff    Netmask
00236 // xxx1 xxxx    Netmask active Flag
00237 // xxx6 xxxx    LED select
00238 // x7f8 xxxx    Bus Select
00239 // 38xx xxxx    Extended LED select
00240 // 8xxx xxxx    Extended LED enable
00241 // 4xxx xxxx    Bus Broadcast
00242 
00243 // xxxxxxxx xxxxxxxx 11111111 11111111  Netmask  (wie bisher genutzt)
00244 // xxxxxxxx xxxxxxx1 xxxxxxxx xxxxxxxx  Netmask aktiv (wie bisher genutzt)
00245 // xxxxxxxx xxxxx11x xxxxxxxx xxxxxxxx  LED Auswahl (intern / extern)
00246 // xxxxx111 11111xxx xxxxxxxx xxxxxxxx  Bus Auswahl (mehrere USB / LAN Module; max: 0-255 = 256 Stück)
00247 // 1x111xxx xxxxxxxx xxxxxxxx xxxxxxxx  Auswahl mehrer externer LEDs - bis zu 8
00248 // x1xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx  Broadcast über alle USB / LAN Module
00249 
00250 
00251 typedef struct {
00252         uint32_t        clientid;
00253         int16_t         statuslen;
00254         int16_t         statustype;
00255         int8_t          memsize[32];
00256         int8_t          flashsize[8];
00257         int8_t          remotes[8];
00258         int8_t          commands[8];
00259         int8_t          actions[8];
00260 } IRDB_FLASHINFO;
00261 
00262 
00263 typedef struct {
00264         uint8_t netcommand;
00265         uint8_t mode;
00266         uint16_t timeout;
00267         int32_t adress;
00268         int32_t protocol_version;
00269         uint8_t len;
00270         uint8_t align;
00271         uint16_t align2;
00272         uint8_t data[256];
00273 } SERCOMMAND;
00274 
00275 
00276 typedef struct {
00277         uint8_t netcommand;
00278         uint8_t mode;
00279         uint16_t timeout;
00280         int32_t adress;
00281         int32_t protocol_version;
00282         uint16_t ccf_data[256];
00283 } CCFCOMMAND;
00284 
00285 typedef struct {
00286         uint8_t netcommand;
00287         uint8_t mode;
00288         uint16_t timeout;
00289         int32_t adress;
00290         int32_t protocol_version;
00291         uint16_t ccf_data[450];
00292 } LONGCCFCOMMAND;
00293 
00294 
00295 typedef struct {
00296         uint8_t netcommand;
00297         uint8_t mode;
00298         uint16_t timeout;
00299         int32_t adress;
00300         int32_t protocol_version;
00301         char ccf_data[1100];
00302         byte repeatmode;
00303 } CCFSTRINGCOMMAND;
00304 
00305 typedef struct {
00306         uint8_t netcommand;
00307         uint8_t mode;
00308         uint16_t timeout;
00309         int32_t adress;
00310         int32_t protocol_version;
00311         char ccf_data[980];
00312         byte repeatmode;
00313 } CCFSTRINGCOMMAND_SHORT;
00314 
00315 
00316 typedef struct {
00317         uint8_t netcommand;
00318         uint8_t mode;
00319         uint8_t lcdcommand;
00320         uint8_t timeout;
00321         int32_t adress;
00322         int32_t protocol_version;
00323         uint8_t wid;
00324         uint8_t hgt;
00325         int8_t framebuffer[200];
00326 } LCDCOMMAND;
00327 
00328 
00329 typedef struct {
00330         uint8_t netcommand;
00331         uint8_t mode;
00332         uint16_t timeout;
00333         int32_t adress;
00334         int32_t protocol_version;
00335         int32_t number;
00336         uint8_t setup;
00337         uint8_t type;
00338         uint8_t accelerator_timeout;
00339         uint8_t accelerator_repeat;
00340     uint16_t wait_timeout;
00341     uint8_t remote_num;
00342     uint8_t group_num;
00343         int8_t remote[80];
00344         int8_t command[20];
00345         int32_t source_mask;
00346         int32_t target_mask;
00347     uint8_t multi_num;
00348     uint8_t include_names;
00349         uint8_t dummy[2];
00350 } TRANSLATECOMMAND;
00351 
00352 
00353 typedef struct {
00354     int32_t send_mask;
00355     uint8_t device_mode;
00356     uint8_t extended_mode;
00357     uint8_t extended_mode2;
00358     uint8_t align;
00359         uint16_t switch_mode;
00360     uint16_t align2;
00361         uint32_t features;
00362     uint16_t align3;
00363     int8_t version[10];
00364         int8_t remote[80];
00365         int8_t command[20];
00366 } MODELINE;
00367 
00368 typedef struct {
00369     int32_t send_mask;
00370     uint8_t device_mode;
00371     uint8_t extended_mode;
00372     uint8_t extended_mode2;
00373     uint8_t align;
00374         uint16_t switch_mode;
00375     uint16_t switch_mode2;
00376         uint32_t features;
00377     uint8_t extended_mode3;
00378     uint8_t extended_mode4;
00379     int8_t version[10];
00380         int8_t remote[80];
00381         int8_t command[20];
00382         int8_t remote2[80];
00383         int8_t command2[20];
00384 } MODELINEN;
00385 
00386 typedef struct {
00387         uint32_t clientid;
00388         int16_t statuslen;
00389         int16_t statustype;
00390         int16_t adress;
00391     uint8_t align[2];
00392         int8_t data[32768];
00393 } STATUSBUFFER;
00394 
00395 typedef struct {
00396         uint32_t clientid;
00397         int16_t statuslen;
00398         int16_t statustype;
00399         int16_t adress;
00400     uint8_t align[2];
00401         int8_t data[256];
00402 } DATABUFFER;
00403 
00404 typedef struct {
00405         uint32_t clientid;
00406         int16_t statuslen;
00407         int16_t statustype;
00408         int32_t serno;
00409         int32_t functions;
00410 } FUNCTIONBUFFER;
00411 
00412 typedef struct {
00413         uint32_t clientid;
00414         int16_t statuslen;
00415         int16_t statustype;
00416         ANALOG_INPUTS inputs;
00417 } ANALOGBUFFER;
00418 
00419 typedef struct {
00420         uint32_t clientid;
00421         int16_t statuslen;
00422         int16_t statustype;
00423         int32_t serno;
00424         int32_t functions;
00425         int8_t version[8];
00426 } FUNCTIONBUFFEREX;
00427 
00428 /*
00429 typedef struct {
00430         uint32_t target_mask;
00431         uint32_t source_mask;
00432         int8_t name[80];
00433 } REMOTELINE;
00434 */
00435 
00436 typedef struct {
00437         uint32_t clientid;
00438         int16_t statuslen;
00439         int16_t statustype;
00440     int16_t offset;
00441     int16_t count_buffer;
00442         int16_t count_total;
00443         int16_t count_remaining;
00444         REMOTELINE remotes[40];
00445 } REMOTEBUFFER;
00446 
00447 typedef struct {
00448         uint32_t clientid;
00449         int16_t statuslen;
00450         int16_t statustype;
00451     int16_t offset;
00452     int16_t count_buffer;
00453         int16_t count_total;
00454         int16_t count_remaining;
00455         int8_t commands[200][20];
00456 } COMMANDBUFFER;
00457 
00458 typedef struct {
00459         uint32_t clientid;
00460         int16_t statuslen;
00461         int16_t statustype;
00462     int16_t offset;
00463     int16_t count_buffer;
00464         int16_t count_total;
00465         int16_t count_remaining;
00466         TRANSLATECOMMAND trdata[30];
00467 } TRANSLATEBUFFER;
00468 
00469 
00470 typedef struct {
00471         uint8_t netcommand;
00472         uint8_t mode;
00473         uint16_t timeout;
00474         int32_t adress;
00475         int32_t protocol_version;
00476         int32_t number;
00477         uint8_t relais;
00478         uint8_t type;
00479         uint8_t action_type;
00480         uint8_t action_len;
00481         int32_t remote_num;
00482         int32_t command_num;
00483         uint32_t ip;
00484         uint16_t port;
00485         uint16_t align;
00486         int8_t remote[80];
00487         int8_t command[20];
00488         uint8_t action[256];
00489 } IRDBCOMMAND;
00490 
00491 typedef struct {
00492         uint8_t netcommand;
00493         uint8_t mode;
00494         uint16_t timeout;
00495         int32_t adress;
00496         int32_t protocol_version;
00497         int32_t number;
00498         uint8_t active;
00499         uint8_t type;
00500         word    port;
00501         uint8_t default_action[100];
00502         uint8_t err_status[20];
00503         uint8_t ok_status[20];
00504         uint8_t inputmode[4];
00505         uint8_t min[4];
00506         uint8_t max[4];
00507         uint8_t hyst[4];
00508         uint8_t minledsel[4];
00509         uint8_t maxledsel[4];
00510         int32_t minmask[4];
00511         int32_t maxmask[4];
00512         int8_t minremote[4][80];
00513         int8_t mincommand[4][50];
00514         int8_t maxremote[4][80];
00515         int8_t maxcommand[4][50];
00516         uint32_t ip;
00517         uint8_t rs232_config[4];
00518 } IRDBHEADER;
00519 
00520 
00521 
00522 typedef struct {
00523         uint32_t clientid;
00524         int16_t statuslen;
00525         int16_t statustype;
00526     int16_t offset;
00527     int16_t count_buffer;
00528         int16_t count_total;
00529         int16_t count_remaining;
00530         IRDBCOMMAND dbdata[12];
00531 } IRDBBUFFER;
00532 
00533 typedef struct {
00534         uint32_t clientid;
00535         int16_t statuslen;
00536         int16_t statustype;
00537     int16_t offset;
00538     int16_t count_buffer;
00539         int16_t count_total;
00540         int16_t count_remaining;
00541         IRDBHEADER header;
00542 } IRDBHEADERBUFFER;
00543 
00544 typedef struct {
00545         uint32_t clientid;
00546         int16_t statuslen;
00547         int16_t statustype;
00548         int16_t adress;
00549     uint8_t align[2];
00550     MODELINE stat[16];
00551 } NETWORKMODE;
00552 
00553 typedef struct {
00554         uint32_t clientid;
00555         int16_t statuslen;
00556         int16_t statustype;
00557         int16_t adress;
00558     uint8_t align;
00559         uint8_t count;
00560         uint8_t dev_adr[8];
00561     MODELINE stat[8][16];
00562 } NETWORKMODEEX;
00563 
00564 typedef struct {
00565         uint32_t clientid;
00566         int16_t statuslen;
00567         int16_t statustype;
00568         int16_t adress;
00569     uint8_t offset;
00570         uint8_t count;
00571         uint8_t dev_adr[8];
00572     MODELINEN stat[8][16];
00573 } NETWORKMODEEXN;
00574 
00575 typedef struct {
00576         uint32_t clientid;
00577         int16_t statuslen;
00578         int16_t statustype;
00579         int16_t adress;
00580         uint16_t netstatus;
00581         uint16_t statuslevel;
00582     uint8_t align[2];
00583         int8_t message[256];
00584 } NETWORKSTATUS;
00585 
00586 typedef struct {
00587         uint32_t clientid;
00588         int16_t statuslen;
00589         int16_t statustype;
00590         int16_t adress;
00591         uint16_t netstatus;
00592         uint16_t statuslevel;
00593     uint8_t align;
00594         uint8_t virtual_col;
00595         uint8_t numcol;
00596         uint8_t numrows;
00597         uint8_t clockflag;
00598 } NETWORKLCDSTAT;
00599 
00600 typedef struct {
00601         uint32_t clientid;
00602         int16_t statuslen;
00603         int16_t statustype;
00604         int16_t adress;
00605     uint8_t align[2];
00606         TIMINGDATA timing;
00607 } NETWORKTIMING;
00608 
00609 typedef struct {
00610         uint32_t clientid;
00611         int16_t statuslen;
00612         int16_t statustype;
00613         int16_t adress;
00614     uint16_t command_num;
00615         int8_t remote[80];
00616         int8_t command[20];
00617         int8_t data[200];
00618 } NETWORKRECV;
00619 
00620 
00621 typedef struct {
00622         uint32_t clientid;
00623         int16_t statuslen;
00624         int16_t statustype;
00625         int16_t adress;
00626         int16_t learnok;
00627         int8_t remote[80];
00628         int16_t num_timings;
00629         int16_t num_commands;
00630         int8_t received[CODE_LEN];
00631 } NETWORKLEARNSTAT;
00632 
00633 
00634 typedef struct {
00635         SOCKET fd;
00636         int32_t type;
00637         int32_t mode;
00638         uint32_t clientid;
00639         uint32_t callno;
00640         int8_t ip[20];
00641         WSAEVENT event;
00642         FILE *fp;
00643         char filename[84];
00644         int32_t timing;
00645         uint8_t resend_load;
00646         IRDATA ird;
00647         NETWORKLEARNSTAT learnstatus;
00648         int8_t restdata[sizeof (LCDCOMMAND)];
00649         int32_t restlen;
00650         int32_t restread;
00651 } NETWORKCLIENT;
00652 
00653 
00654 #define MODE_ASCII              1
00655 
00656 
00657 #define TCP_PORT                21000
00658 #define IRTRANS_PORT    21000
00659 #define LIRC_PORT               8765
00660 #define UDP_PORT                21000
00661 #define WEB_PORT                80
00662 #define ALTERNATE_WEB   8080
00663 #define XAP_PORT                3639
00664 
00665 
00666 #ifdef WIN32
00667 #define CLIENT_COUNT    MAXIMUM_WAIT_OBJECTS - 3
00668 #endif
00669 
00670 #ifdef LINUX
00671 #define CLIENT_COUNT    64
00672 #endif
00673 
00674 
00675 


ir_drivers
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 2 2015 03:06:05