亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? binarycomms.c

?? linux下的dvb收看解析軟件代碼; 帶參考程序
?? C
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*Copyright (C) 2006  Adam CharrettThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU General Public Licenseas published by the Free Software Foundation; either version 2of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USAbinarycomms.cBinary Communications protocol for control DVBStreamer.*/#include "config.h"#include <limits.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <sys/types.h>#include <sys/poll.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include "ts.h"#include "udpoutput.h"#include "outputs.h"#include "logging.h"#include "cache.h"#include "messages.h"#include "main.h"#include "binarycomms.h"#define MAX_CONNECTIONS 2 /* 1 for monitoring by web and another for control */#define LOG_MALFORMED(_connection, _field) \    printlog(LOG_DEBUG, "%s:%d : Malformed message, not enough data in message to read %s field!\n", \        inet_ntoa((_connection)->clientAddress.sin_addr), (_connection)->clientAddress.sin_port, _field)#define IFAUTHENTICATED(_dofunc, _connection, _message) \    do { \        if ((_connection)->authenticated)\        {\            _dofunc(_connection, _message);\        }\        else \        { \          MessageRERR(_message, RERR_NOTAUTHORISED, "Not authorised!"); \        }\    }while(0)#define MessageRERR(_msg, _errcode, _str) \    do{\        MessageInit(_msg, MSGCODE_RERR);\        MessageEncode(_msg, "bs", _errcode, _str);\    }while(0)#define STRINGIFY(x) #x#define TOSTRING(x) STRINGIFY(x)#define READSTRING(_var)\    do { \        if (MessageReadString(message, &_var))\        {\            LOG_MALFORMED(connection, TOSTRING(_var));\            connection->connected = FALSE;\            return ;\        }\    }while(0)#define READ2STRINGS(_var1, _var2)\    do { \        if (MessageReadString(message, &_var1))\        {\            LOG_MALFORMED(connection, TOSTRING(_var1));\            connection->connected = FALSE;\            return ;\        }\        if (MessageReadString(message, &_var2))\        {\            LOG_MALFORMED(connection, TOSTRING(_var2));\            connection->connected = FALSE;\            free(_var1);\            return ;\        }\    }while(0)#define READUINT8(_var)\    do { \        if (MessageReadUint8(message, &_var))\        {\            LOG_MALFORMED(connection, TOSTRING(_var));\            connection->connected = FALSE;\            return ;\        }\    }while(0)#define READUINT16(_var)\    do { \        if (MessageReadUint16(message, &_var))\        {\            LOG_MALFORMED(connection, TOSTRING(_var));\            connection->connected = FALSE;\            return ;\        }\    }while(0)#define READUINT32(_var)\    do { \        if (MessageReadUint32(message, &_var))\        {\            LOG_MALFORMED(connection, TOSTRING(_var));\            connection->connected = FALSE;\            return ;\        }\    }while(0)typedef struct Connection_t{    int socketfd;    struct sockaddr_in clientAddress;    bool authenticated;    bool active;    bool connected;    pthread_t thread;    Message_t message;}Connection_t;static void HandleConnection(Connection_t *connection);static void ProcessMessage(Connection_t *connection, Message_t *message);static void ProcessInfo(Connection_t *connection, Message_t *message);static void ProcessAuth(Connection_t *connection, Message_t *message);static void ProcessPrimaryServiceSelect(Connection_t *connection, Message_t *message);static void ProcessSecondaryServiceAdd(Connection_t *connection, Message_t *message);static void ProcessSecondaryServiceSet(Connection_t *connection, Message_t *message);static void ProcessSecondaryServiceRemove(Connection_t *connection, Message_t *message);static void ProcessOutputAdd(Connection_t *connection, Message_t *message);static void ProcessOutputRemove(Connection_t *connection, Message_t *message);static void ProcessOutputPIDAdd(Connection_t *connection, Message_t *message);static void ProcessOutputPIDRemove(Connection_t *connection, Message_t *message);static void ProcessPrimaryServiceCurrent(Connection_t *connection, Message_t *message);static void ProcessSecondaryServiceList(Connection_t *connection, Message_t *message);static void ProcessOutputsList(Connection_t *connection, Message_t *message);static void ProcessOutputListPids(Connection_t *connection, Message_t *message);static void ProcessServiceFilterPacketCount(Connection_t *connection, Message_t *message);static void ProcessOutputPacketCount(Connection_t *connection, Message_t *message);static void ProcessTSStats(Connection_t *connection, Message_t *message);static void ProcessFEStatus(Connection_t *connection, Message_t *message);static void ProcessServiceList(Connection_t *connection, Message_t *message, int all);static void ProcessServicePids(Connection_t *connection, Message_t *message);static int activeConnections = 0;static pthread_mutex_t activeConnectionsMutex = PTHREAD_MUTEX_INITIALIZER;static int serverSocket;static Connection_t connections[MAX_CONNECTIONS];static char *infoStreamerName;static char *authUsername;static char *authPassword;static time_t serverStartTime;int BinaryCommsInit(int adapter, char *streamername, char *username, char *password){    struct sockaddr_in serverAddress;    serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);    if (serverSocket < 0)    {        printlog(LOG_ERROR, "Failed to create server socket!\n");        return 1;    }    bzero((char *) &serverAddress, sizeof(serverAddress));    serverAddress.sin_family = AF_INET;    serverAddress.sin_addr.s_addr = INADDR_ANY;    serverAddress.sin_port = htons(BINARYCOMMS_PORT + adapter);    if (bind(serverSocket, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) < 0)    {        printlog(LOG_ERROR, "Failed to bind server to port %d", BINARYCOMMS_PORT + adapter);        close(serverSocket);        return 1;    }    listen(serverSocket, 1);    infoStreamerName = strdup(streamername);    authUsername = strdup(username);    authPassword = strdup(password);    time(&serverStartTime);    printlog(LOG_INFO, "Server created %s", ctime(&serverStartTime));    printlog(LOG_DEBUG, "Username    : %s\n", authUsername);    printlog(LOG_DEBUG, "Password    : %s\n", authPassword);    printlog(LOG_DEBUG, "Server Name : %s\n", infoStreamerName);    return 0;}void BinaryCommsDeInit(void){    int i;    close(serverSocket);    for ( i = 0; i < MAX_CONNECTIONS; i ++)    {        if (connections[i].connected)        {            /* Force closure of the sockets should cause the thread to terminate. */            close(connections[i].socketfd);            connections[i].connected = FALSE;        }    }}void BinaryCommsAcceptConnections(void){    struct pollfd pfd[1];    pfd[0].fd = serverSocket;    pfd[0].events = POLLIN;    while (!ExitProgram)    {        if (poll(pfd, 1, 200))        {            if (pfd[0].revents & POLLIN)            {                int clientfd;                struct sockaddr_in clientAddress;                int clientAddressSize;                clientAddressSize = sizeof(clientAddress);                clientfd = accept(serverSocket, (struct sockaddr *) & clientAddress, &clientAddressSize);                pthread_mutex_lock(&activeConnectionsMutex);                if (activeConnections >= MAX_CONNECTIONS)                {                    printlog(LOG_INFO, "Connection attempt from %s:%d rejected as too many open connections!\n",                             inet_ntoa(clientAddress.sin_addr), clientAddress.sin_port);                    close(clientfd);                }                else                {                    int found = -1;                    int i;                    for (i = 0; i < MAX_CONNECTIONS; i ++)                    {                        if (!connections[i].active)                        {                            found = i;                            break;                        }                    }                    if (found >= 0)                    {                        connections[i].active = TRUE;                        connections[i].connected = TRUE;                        connections[i].socketfd = clientfd;                        connections[i].clientAddress = clientAddress;                        activeConnections ++;                        printlog(LOG_INFO, "Connection attempt from %s:%d accepted!\n",                                 inet_ntoa(clientAddress.sin_addr), clientAddress.sin_port);                        pthread_create(&connections[i].thread, NULL, (void*)HandleConnection, (void*)&connections[i]);                    }                    else                    {                        printlog(LOG_INFO, "Connection attempt from %s:%d rejected as no connections structures left!\n",                                 inet_ntoa(clientAddress.sin_addr), clientAddress.sin_port);                        close(clientfd);                    }                }                pthread_mutex_unlock(&activeConnectionsMutex);            }        }    }}static void HandleConnection(Connection_t *connection){    struct pollfd pfd[1];    int socketfd = connection->socketfd;    pfd[0].fd = socketfd;    pfd[0].events = POLLIN;    Message_t *message = &connection->message;    while (!ExitProgram && connection->connected)    {        if (MessageRecv(message, socketfd))        {            /* Socket must be dead exit this connection! */            break;        }        ProcessMessage(connection, message);        if (connection->connected)        {            printlog(LOG_DEBUG, "%s:%d : Response 0x%04x length %d\n",                     inet_ntoa(connection->clientAddress.sin_addr), connection->clientAddress.sin_port,                     MessageGetCode(message), MessageGetLength(message));            if (MessageSend(message, socketfd))            {                /* Socket must be dead exit this connection! */                break;            }        }    }    printlog(LOG_INFO, "%s:%d : Connection closed!\n",             inet_ntoa(connection->clientAddress.sin_addr), connection->clientAddress.sin_port);    /* Close the socket and free our resources */    close(socketfd);    connection->connected = FALSE;    pthread_mutex_lock(&activeConnectionsMutex);    connection->active = FALSE;    activeConnections --;    pthread_mutex_unlock(&activeConnectionsMutex);}static void ProcessMessage(Connection_t *connection, Message_t *message){    printlog(LOG_DEBUG, "%s:%d : Processing message 0x%04x length %d\n",             inet_ntoa(connection->clientAddress.sin_addr), connection->clientAddress.sin_port,             MessageGetCode(message), MessageGetLength(message));    switch (message->code)    {        case MSGCODE_INFO:            ProcessInfo(connection, message);            break;        case MSGCODE_AUTH:            ProcessAuth(connection, message);            break;            /* Control Messages */        case MSGCODE_CSPS:            IFAUTHENTICATED(ProcessPrimaryServiceSelect, connection, message);            break;        case MSGCODE_CSSA:            IFAUTHENTICATED(ProcessSecondaryServiceAdd, connection, message);            break;        case MSGCODE_CSSS:            IFAUTHENTICATED(ProcessSecondaryServiceSet, connection, message);            break;        case MSGCODE_CSSR:            IFAUTHENTICATED(ProcessSecondaryServiceRemove, connection, message);            break;        case MSGCODE_COAO:            IFAUTHENTICATED(ProcessOutputAdd, connection, message);            break;        case MSGCODE_CORO:            IFAUTHENTICATED(ProcessOutputRemove, connection, message);            break;        case MSGCODE_COAP:            IFAUTHENTICATED(ProcessOutputPIDAdd, connection, message);            break;        case MSGCODE_CORP:            IFAUTHENTICATED(ProcessOutputPIDRemove, connection, message);            break;            /* Status Messages */        case MSGCODE_SSPS:            ProcessPrimaryServiceCurrent(connection, message);            break;        case MSGCODE_SSFL:            ProcessSecondaryServiceList(connection, message);            break;        case MSGCODE_SSPC:            ProcessServiceFilterPacketCount(connection, message);            break;        case MSGCODE_SOLO:            ProcessOutputsList(connection, message);            break;        case MSGCODE_SOLP:            ProcessOutputListPids(connection, message);            break;        case MSGCODE_SOPC:            ProcessOutputPacketCount(connection, message);            break;        case MSGCODE_STSS:            ProcessTSStats(connection, message);            break;        case MSGCODE_SFES:            ProcessFEStatus(connection, message);            break;        case MSGCODE_SSLA:            ProcessServiceList(connection, message, 1);            break;        case MSGCODE_SSLM:            ProcessServiceList(connection, message, 0);            break;        case MSGCODE_SSPL:            ProcessServicePids(connection, message);            break;        default:            MessageRERR(message, RERR_GENERIC, "Unknown message type!");            break;    }}static void ProcessInfo(Connection_t *connection, Message_t *message){    uint8_t info;    READUINT8(info);    switch (info)    {        case INFO_NAME:            MessageRERR(message, RERR_OK, infoStreamerName);            break;        case INFO_FETYPE:            MessageRERR(message, RERR_OK, "Not implemented!");            break;        case INFO_AUTHENTICATED:            MessageRERR(message, RERR_OK, connection->authenticated ? "Authenticated" : "Not authenticated");            break;        case INFO_UPSECS:            {                char buffer[11];                time_t now;                time(&now);                sprintf(buffer, "%d", (int)difftime(now, serverStartTime));                MessageRERR(message, RERR_OK, buffer);            }            break;        case INFO_UPTIME:            {                char buffer[50];                time_t now;                int seconds;                int d, h, m, s;                time(&now);                seconds = (int)difftime(now, serverStartTime);                d = seconds / (24 * 60 * 60);                h = (seconds - (d * 24 * 60 * 60)) / (60 * 60);                m = (seconds - ((d * 24 * 60 * 60) + (h * 60 * 60))) / 60;                s = (seconds - ((d * 24 * 60 * 60) + (h * 60 * 60) + (m * 60)));                sprintf(buffer, "%d Days %d Hours %d Minutes %d seconds", d, h, m, s);                MessageRERR(message, RERR_OK, buffer);            }            break;        default:            MessageRERR(message, RERR_GENERIC, "Unknown field");            break;    }}static void ProcessAuth(Connection_t *connection, Message_t *message){    char *msgUsername = NULL;    char *msgPassword = NULL;    READ2STRINGS(msgUsername, msgPassword);    connection->authenticated = (strcmp(msgUsername, authUsername) == 0) &&                                (strcmp(msgPassword, authPassword) == 0);    MessageRERR(message, connection->authenticated ? RERR_OK : RERR_NOTAUTHORISED, NULL);    free(msgUsername);    free(msgPassword);}static void ProcessPrimaryServiceSelect(Connection_t *connection, Message_t *message){    char *serviceName;    READSTRING(serviceName);

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一本大道综合伊人精品热热| 国产河南妇女毛片精品久久久| 国产精品乱人伦| 久久综合成人精品亚洲另类欧美| 91麻豆精品国产自产在线观看一区| 色综合欧美在线| 在线观看日韩高清av| 91福利视频在线| 91成人看片片| 欧美日韩精品一区二区天天拍小说 | 一区二区三区在线观看国产| 亚洲图片另类小说| 亚洲自拍与偷拍| 国产日韩亚洲欧美综合| 偷拍亚洲欧洲综合| 亚洲一区二区三区四区在线 | 一本色道久久加勒比精品| 欧美中文字幕一区| 国产在线精品一区二区三区不卡 | 99综合影院在线| voyeur盗摄精品| 色哟哟国产精品免费观看| 欧美日韩亚洲综合在线| 制服视频三区第一页精品| 精品奇米国产一区二区三区| 久久综合五月天婷婷伊人| 欧美经典三级视频一区二区三区| 国产精品二区一区二区aⅴ污介绍| 中文字幕视频一区| 午夜精品视频一区| 久久99精品久久久久婷婷| 国产成人高清视频| 91美女在线看| 精品久久久久久久久久久久包黑料| 亚洲一级在线观看| 日韩av中文字幕一区二区三区| 久久精品国产亚洲一区二区三区| 国产成人在线免费| 日本丶国产丶欧美色综合| 91精品国产美女浴室洗澡无遮挡| 精品成人一区二区三区| 欧美国产日韩一二三区| 亚洲一二三四在线观看| 国产自产高清不卡| 91丨九色porny丨蝌蚪| 91精品国产欧美一区二区| 国产欧美精品区一区二区三区 | 久久久综合激的五月天| 中文字幕一区视频| 欧美a一区二区| 成人免费av网站| 678五月天丁香亚洲综合网| 日本一区二区三级电影在线观看| 亚洲福利一区二区三区| 国模一区二区三区白浆| 日本精品免费观看高清观看| 亚洲欧美一区二区三区极速播放| 午夜亚洲福利老司机| 国产精品一卡二卡在线观看| 欧美亚洲综合另类| 国产日韩精品一区二区浪潮av | 不卡的av电影| 91精品国产全国免费观看 | 久久精品国产精品亚洲精品| 99久久综合国产精品| 欧美大片一区二区三区| 一区二区三区精密机械公司| 国产一区二区在线观看免费| 欧美日韩国产小视频在线观看| 中文字幕精品一区二区精品绿巨人 | 国产一区二区0| 欧美日韩视频在线第一区| 中文无字幕一区二区三区| 日本aⅴ免费视频一区二区三区| 欧美在线播放高清精品| 欧美一区二区三区免费在线看| 国产精品每日更新在线播放网址 | av成人老司机| 欧美精品一区二区久久久| 亚洲一区二区三区四区在线观看| 暴力调教一区二区三区| 久久久久久久久伊人| 男男gaygay亚洲| 欧美日韩国产bt| 一区二区三区日韩在线观看| 99久久精品99国产精品| 久久精品一区二区三区四区| 久久精品久久精品| 欧美一级国产精品| 天天综合色天天| 欧美日韩在线亚洲一区蜜芽| 亚洲精品综合在线| 99精品在线观看视频| 中文字幕一区不卡| 99精品热视频| 日韩伦理av电影| 成人av网站免费| 国产精品不卡视频| 97久久超碰国产精品| 国产精品久久久久久久久果冻传媒 | 成人av免费观看| 久久久亚洲精华液精华液精华液| 奇米一区二区三区| 91精品欧美一区二区三区综合在| 亚洲成人福利片| 欧美美女激情18p| 婷婷激情综合网| 6080yy午夜一二三区久久| 夜夜嗨av一区二区三区网页| 欧美亚洲动漫另类| 亚洲成人免费在线观看| 欧美日韩激情在线| 日韩精品久久理论片| 日韩一区二区三区视频在线 | 91一区二区三区在线观看| **性色生活片久久毛片| 97久久精品人人爽人人爽蜜臀| 亚洲乱码精品一二三四区日韩在线| 91麻豆123| 天天操天天色综合| 欧美大黄免费观看| 国产一区二区电影| 久久久精品免费观看| av午夜精品一区二区三区| 亚洲欧美色一区| 成人免费毛片app| 国产日韩欧美综合一区| 国产一区二区三区黄视频| 国产偷国产偷精品高清尤物 | 欧美不卡视频一区| 97国产精品videossex| 一区二区三区四区视频精品免费 | 成人在线视频首页| 综合分类小说区另类春色亚洲小说欧美| 99re热这里只有精品视频| 亚洲精品日产精品乱码不卡| 欧美日韩视频一区二区| 极品少妇xxxx精品少妇| 国产精品丝袜一区| 欧美日韩免费高清一区色橹橹 | 91污在线观看| 日韩不卡一二三区| 国产欧美日韩卡一| 欧美日本精品一区二区三区| 激情综合一区二区三区| 中文字幕欧美一| 777午夜精品免费视频| 欧美亚州韩日在线看免费版国语版 | 久久久高清一区二区三区| 99久久婷婷国产综合精品| 亚洲成人动漫一区| 久久婷婷综合激情| 91黄色免费看| 国产精品一区二区三区网站| 亚洲人妖av一区二区| 欧美一级黄色录像| 一本一道久久a久久精品| 久久精品免费看| 一区二区三区中文免费| 欧美精品一区视频| 欧美色视频在线| 高清在线观看日韩| 日韩国产欧美在线视频| 综合色天天鬼久久鬼色| 欧美不卡一区二区三区| 欧美性猛片aaaaaaa做受| 精品一区二区久久久| 亚洲香蕉伊在人在线观| 国产三级三级三级精品8ⅰ区| 欧美电影影音先锋| 色综合天天综合网天天看片| 国产毛片精品国产一区二区三区| 亚洲不卡av一区二区三区| 国产精品美女久久久久久久网站| 日韩三级在线观看| 欧美伊人精品成人久久综合97| 高清视频一区二区| 国产一区二区三区国产| 日本欧美韩国一区三区| aaa欧美日韩| 麻豆成人在线观看| 一区二区三区高清在线| 中文字幕不卡在线| 精品粉嫩超白一线天av| 91精品国产日韩91久久久久久| 色综合天天综合| 成人午夜私人影院| 国产伦精品一区二区三区免费迷 | 99精品黄色片免费大全| 国产一区视频导航| 麻豆成人综合网| 蜜臀久久99精品久久久画质超高清 | 欧美国产日韩精品免费观看| 日韩精品一区二区三区视频在线观看| 欧美在线视频日韩| 色88888久久久久久影院野外| 成人精品一区二区三区中文字幕| 国产成人一级电影| 国产剧情av麻豆香蕉精品| 美国毛片一区二区|