zoukankan      html  css  js  c++  java
  • IPV4 IPV6 数据成员

    typedef uint16_t in_port_t;
    
    // Internet address. --- IPV4
    typedef uint32_t in_addr_t;
    struct in_addr{
         in_addr_t s_addr;
    };
    
    
    
    // IPv6 address
    struct in6_addr
    {
    	union
    	{   
    		uint8_t __u6_addr8[16];
    	} __in6_u;
    };  
    
    
    // Structure describing an Internet socket address   --- IPV4
    struct sockaddr_in
    {
    	__SOCKADDR_COMMON (sin_);
    	in_port_t sin_port;         /* Port number.  */
    	struct in_addr sin_addr;        /* Internet address.  */
    
    	/* Pad to size of `struct sockaddr'.  */
    	unsigned char sin_zero[sizeof (struct sockaddr) -
    		__SOCKADDR_COMMON_SIZE -
    		sizeof (in_port_t) -
    		sizeof (struct in_addr)];
    };
    
    
    /* Ditto, for IPv6.  */
    struct sockaddr_in6
    {
    	__SOCKADDR_COMMON (sin6_);
    	in_port_t sin6_port;    /* Transport layer port # */
    	uint32_t sin6_flowinfo; /* IPv6 flow information */
    	struct in6_addr sin6_addr;  /* IPv6 address */
    	uint32_t sin6_scope_id; /* IPv6 scope-id */
    };
    
    struct in_addr 仅一个成员, s_addr (uint32_t)
    struct in6_addr 仅一个成员 __u6_addr ( uint8_t [16])
    
    IPV4: socket_in 共4个成员:
    	unsignedshort	sin_family	--> 协议族类型
    	uint16_t  sin_port 		--> 端口号
    	struct in_addr     sin_addr     --> ip地址
    	unsigned   char sin_zero        --> 
    IPV6: socket_in6 共4个成员:
    	uint16_t sin6_port;   		/* Transport layer port # */
    	uint32_t sin6_flowinfo; 	/* IPv6 flow information */
    	struct in6_addr sin6_addr;	/* IPv6 address */
    	uint32_t sin6_scope_id; 	/* IPv6 scope-id */
    
    struct sockaddr{
      unsignedshort sa_family; /* address family */ 
      char sa_data[14]; /* up to 14 bytes of direct address */
    };
    

      

  • 相关阅读:
    STM32 端口复用配置
    stm32 新建文件记得添加到工程
    keil解决SYSTEMsysstm32f10x.h(298): error: #67: expected a "}"
    解决Keil复制中文乱码
    STM32 MPU6050 源码
    STM32 PWM输出
    STM32定时器
    STM32 看门狗操作姿势
    开课博客
    第二周学习进度
  • 原文地址:https://www.cnblogs.com/mathzzz/p/2669832.html
Copyright © 2011-2022 走看看