/****************************************************************************** * * Copyright (c) 2009 TP-LINK Technologies CO.,LTD. * All rights reserved. * * FILE NAME : tp_domain.h * VERSION : 1.0 * DESCRIPTION: 用于实现我司路由器产品可以域名登录进web管理页面. * * AUTHOR : huangwenzhong * CREATE DATE: 11/30/2010 * * HISTORY : * 01 11/30/2010 huangwenzhong Create. * ******************************************************************************/ #ifndef _TP_DOMAIN_H #define _TP_DOMAIN_H #define DOMAIN_PORT 53 #define ETH_HEADER_LEN ( 2 + 14 ) #define IP_PACKET_TTL 128 #define IP6_PACKET_HOPLIMIT 64 #define BR_STATE_DISABLED 0 #define BR_STATE_LISTENING 1 #define BR_STATE_LEARNING 2 #define BR_STATE_FORWARDING 3 #define BR_STATE_BLOCKING 4 #define BR_HASH_BITS 8 #define BR_HASH_SIZE (1 << BR_HASH_BITS) typedef __u16 port_id; typedef struct bridge_id bridge_id; #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) struct bridge_id { unsigned char prio[2]; unsigned char addr[6]; }; struct net_bridge_port { struct net_bridge *br; struct net_device *dev; struct list_head list; /* STP */ u8 priority; u8 state; u16 port_no; unsigned char topology_change_ack; unsigned char config_pending; port_id port_id; port_id designated_port; bridge_id designated_root; bridge_id designated_bridge; u32 path_cost; u32 designated_cost; struct timer_list forward_delay_timer; struct timer_list hold_timer; struct timer_list message_age_timer; struct kobject kobj; struct rcu_head rcu; }; struct net_bridge { spinlock_t lock; struct list_head port_list; struct net_device *dev; spinlock_t hash_lock; struct hlist_head hash[BR_HASH_SIZE]; struct list_head age_list; unsigned long feature_mask; #ifdef CONFIG_BRIDGE_NETFILTER struct rtable fake_rtable; #endif unsigned long flags; #define BR_SET_MAC_ADDR 0x00000001 /* STP */ bridge_id designated_root; bridge_id bridge_id; u32 root_path_cost; unsigned long max_age; unsigned long hello_time; unsigned long forward_delay; unsigned long bridge_max_age; unsigned long ageing_time; unsigned long bridge_hello_time; unsigned long bridge_forward_delay; u8 group_addr[ETH_ALEN]; u16 root_port; enum { BR_NO_STP, /* no spanning tree */ BR_KERNEL_STP, /* old STP in kernel */ BR_USER_STP, /* new RSTP in userspace */ } stp_enabled; unsigned char topology_change; unsigned char topology_change_detected; struct timer_list hello_timer; struct timer_list tcn_timer; struct timer_list topology_change_timer; struct timer_list gc_timer; struct kobject *ifobj; }; #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #if 0 #define DNS_ANSWER_TTL 0 #else #define DNS_ANSWER_TTL ( 2 * 24 * 60 *60 ) #endif #define IP_ADDR_LEN sizeof( __u32 ) #define IP6_ADDR_LEN 16 #define PORT_LEN sizeof( __u16 ) #define UDP_HEADER_LEN sizeof( struct udphdr ) #define DNS_HEADER_LEN sizeof( DNS_HEADER ) #define DNS_RESPONSE_PACKET ( 0x8000 ) /* response packet flag */ #define DNS_QUERY_TYPE_A ( 0x0001 ) /* query type,type A */ #define DNS_QUERY_TYPE_AAAA ( 0x001c ) /* query type,type AAAA */ #define DNS_QUERY_CLASS ( 0x0001 ) /* query class,clase internet */ #define DNS_RESPONSE_FLAG ( 0x8080 ) /* response flag value */ #define DNS_RESPONSE_POINTER ( 0xc00c )/* response field pointer */ #define DNS_RESOURCE_LEN_A ( 0x0004 ) /* response field IPv4 length */ #define DNS_RESOURCE_LEN_AAAA ( 0x0010 ) /* response field IPv6 length */ /* DNS报文头部结构.added by huangwenzhong. 11/30/2010. */ #define br_port_get_rcu(dev) \ ((struct net_bridge_port *) rcu_dereference(dev->rx_handler_data)) #define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) typedef struct { __u16 transaction_id; __u16 flag; __u16 questions; __u16 answers_rrs; __u16 authority_rrs; __u16 additional_rrs; }__attribute__ ((__packed__))DNS_HEADER; #endif /* #ifndef _TP_DOMAIN_H */