赞
踩
- /*
- * ===========================================================================
- *
- * Filename: ssdpServer.c
- * Description: 设备发现服务(自实现ssdp协议,获取USERNAME进行绑定)
- * Version: 1.0
- * Created: 08/29/2017 07:20:10 PM
- * Revision: none
- * Compiler: gcc
- * Author: (syc),
- * Company: xxxx
- *
- * ===========================================================================
- */
-
- #include <sys/types.h>
- #include <sys/select.h>
- #include <sys/time.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <net/if.h>
- #include <unistd.h>
- #include <pthread.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "utils/queue.h"
- #include "utils/log.h"
- #include "Discovery/ssdpServer.h"
-
- #define SSDP_MCAST_ADDR ("239.255.255.250")
- #define SSDP_PORT (1900)
- #define M1_PORT (8200)
-
- #define OS_VERSION "3.4.72-rt89"
- #define SERVER_NAME "MiniDLNA"
- #define MINIDLNA_VERSION "1.1.0"
- #define MINIDLNA_SERVER_STRING OS_VERSION " DLNADOC/1.50 UPnP/1.0 " SERVER_NAME "/" MINIDLNA_VERSION
- #define ROOTDESC_PATH "/rootDesc.xml"
-
- #define MAC_ADDR_LEN (16)
- #define IP_ADDR_LEN (16)
- #define MAXSIZE (1024)
-
- queue_t *handle_queue = NULL;
- pthread_t handle_ThreadID;
- pthread_t handle_ThreadID1;
-
- typedef struct _packet_{
- char data[MAXSIZE];
- int len;
- int type;
- }msg_packet_t;
-
- eq_discovery_cb_t callback = {0};
- //全局变量
- struct sockaddr_in addrin ;
- struct timeval rtime ;
- int ssdp_sock ;
- int peer_listen ;
- int peer_sock ;
- socklen_t addrlen ;
- fd_set fds ;
- int maxfdp ;
-
- char buf[1024] ;
-
- //这两个参数根据业务需要而定
- char UUID[32] = {0};//D的唯一标识(MAC地址)
- char M1_IP[32] = {0}; //D的eth0.2的IP地址
-
-
-
- static const char * const known_service_types[] =
- {
- "uuid:00000000-0000-0000-0000-000000000000",
- "upnp:rootdevice",
- "urn:schemas-upnp-org:device:MediaServer:",
- "urn:schemas-upnp-org:service:ContentDirectory:",
- "urn:schemas-upnp-org:service:ConnectionManager:",
- "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:",
- 0
- };
- //获取IP地址
- int get_lan_ip(unsigned char *ipaddr)
- {
- struct sockaddr_in *addr;
- struct ifreq ifr;
- int sockfd;
-
- //char *name = "br-lan";
- char *name = "eth0.2";//eth0.2的IP地址
- if( strlen(name) >= IFNAMSIZ)
- return -1;
-
- strcpy( ifr.ifr_name, name);
- sockfd = socket(AF_INET,SOCK_DGRAM,0);
-
- //get ipaddr
- if(ioctl(sockfd, SIOCGIFADD
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。