Бит выставлен. Вот, короче кусок кода:
void send_DHCP_DISCOVER(SOCKET s)
{
uint16 i;
uint8 addr[4];
uint16 k = 0;
MSG.op = DHCP_BOOTREQUEST;
MSG.htype = DHCP_HTYPE100MB;
MSG.hlen = DHCP_HLENETHERNET;
MSG.hops = DHCP_HOPS; // Client set to zero
MSG.xid = DHCP_XID; //Transaction ID
MSG.secs = DHCP_SECS; //Filled in by client, address acquisition or renewal process
MSG.flags = DHCP_FLAGSBROADCAST;
// client's IP addres
memset(MSG.ciaddr, 0x00, sizeof(MSG.ciaddr));
// your (i.e., client) IP address (filled in by server)
memset(MSG.yiaddr, 0x00, sizeof(MSG.yiaddr));
// server's IP address
memset(MSG.siaddr, 0x00, sizeof(MSG.siaddr));
// agent IP address
memset(MSG.giaddr, 0x00,sizeof(MSG.giaddr));
// Client hardware address
memset(MSG.chaddr, 0x00,sizeof(MSG.chaddr));
for (i = 0; i < 6; i++) MSG.chaddr[i] = Mac[i];
// Optinal server host name
memset(MSG.sname, 0x00, sizeof(MSG.sname));
// Boot file name
memset(MSG.file, 0x00, sizeof(MSG.file));
// MAGIC_COOKIE
MSG.OPT[k++] = MAGIC0; MSG.OPT[k++] = MAGIC1;
MSG.OPT[k++] = MAGIC2; MSG.OPT[k++] = MAGIC3;
MSG.OPT[k++] = dhcpMessageType;
MSG.OPT[k++] = 0x01;
MSG.OPT[k++] = DHCP_DISCOVER;
MSG.OPT[k++] = dhcpClientIdentifier;
MSG.OPT[k++] = 0x07;
MSG.OPT[k++] = 0x01;
MSG.OPT[k++] = Mac[0];
MSG.OPT[k++] = Mac[1];
MSG.OPT[k++] = Mac[2];
MSG.OPT[k++] = Mac[3];
MSG.OPT[k++] = Mac[4];
MSG.OPT[k++] = Mac[5];
MSG.OPT[k++] = hostName;
MSG.OPT[k++] = 14;
for (i = 0; i < 14; i++) MSG.OPT[k++] = Device_Name[i];
MSG.OPT[k++] = dhcpIPaddrLeaseTime;
MSG.OPT[k++] = 0x04;
MSG.OPT[k++] = 0xff;
MSG.OPT[k++] = 0xff;
MSG.OPT[k++] = 0xff;
MSG.OPT[k++] = 0xff;
MSG.OPT[k++] = dhcpParamRequest;
MSG.OPT[k++] = 0x02;
MSG.OPT[k++] = subnetMask;
MSG.OPT[k++] = routersOnSubnet;
/*
MSG.OPT[k++] = dhcpParamRequest;
MSG.OPT[k++] = 0x06;
MSG.OPT[k++] = subnetMask;
MSG.OPT[k++] = routersOnSubnet;
MSG.OPT[k++] = dns;
MSG.OPT[k++] = dhcpT1value;
MSG.OPT[k++] = dhcpT2value;
*/
MSG.OPT[k++] = endOption;
// Null Padding
for (i = k; i < OPT_SIZE; i++) MSG.OPT[i] = 0;
// DST IP : BroadCasting
S_port = DHCP_SERVER_PORT;
for (i=0; i<4; i++) addr[i] = 0xFF;
#ifdef DHCP_DEBUG
printf("send_DHCP_DISCOVER : \r\n");
#endif
uint16 tt;
// send MSG to Broadcasting
tt=sendto(s, (uint8 *)(&MSG.op), RIP_MSG_SIZE, addr, S_port);
#ifdef DHCP_DEBUG
printf("DHCP_DISCOVER was sent %d\r\n", tt);
#endif
}
И хидер.
// DHCP state machine.
#define STATE_DHCP_DISCOVER 1
#define STATE_DHCP_REQUEST 2
#define STATE_DHCP_LEASED 3
#define STATE_DHCP_REREQUEST 4
#define STATE_DHCP_RELEASE 5
#define MAX_DHCP_RETRY 10
#define DHCP_WAIT_TIME 5
/* UDP port numbers for DHCP */
#define DHCP_SERVER_PORT 67 /* from server to client */
#define DHCP_CLIENT_PORT 68 /* from client to server */
/* DHCP message OP code */
#define DHCP_BOOTREQUEST 1
#define DHCP_BOOTREPLY 2
/* DHCP message type */
#define DHCP_DISCOVER 1
#define DHCP_OFFER 2
#define DHCP_REQUEST 3
#define DHCP_DECLINE 4
#define DHCP_ACK 5
#define DHCP_NAK 6
#define DHCP_RELEASE 7
#define DHCP_INFORM 8
/* DHCP RETRANSMISSION TIMEOUT (microseconds) */
#define DHCP_INITIAL_RTO ( 4*1000000)
#define DHCP_MAX_RTO (64*1000000)
#define DHCP_HTYPE10MB 1
#define DHCP_HTYPE100MB 2
#define DHCP_HLENETHERNET 6
#define DHCP_HOPS 0
//#define DHCP_XID 0x12345678 // Client Unique ID
#define DHCP_SECS 0
#define DHCP_FLAGSBROADCAST 0x8000
#define MAGIC_COOKIE 0x63825363
#define DEFAULT_LEASETIME 0xffffffff /* infinite lease time */
#define htons(X) (X)
#define ntohs(X) (X)
#define htonl(X) (X)
#define ntohl(X) (X)
/* bsd */
typedef uint8 u_char; /**< 8-bit value */
typedef uint16 u_short; /**< 16-bit value */
typedef uint16 u_int; /**< 16-bit value */
typedef uint32 u_long; /**< 32-bit value */
typedef union _un_l2cval {
u_long lVal;
u_char cVal[4];
}un_l2cval;
typedef union _un_i2cval {
u_int iVal;
u_char cVal[2];
}un_i2cval;
/* DHCP option and value (cf. RFC1533) */
typedef enum _OPTION
{
padOption = 0,
subnetMask =1,
timerOffset =2,
routersOnSubnet=3,
timeServer=4,
nameServer=5,
dns=6,
logServer=7,
cookieServer=8,
lprServer=9,
impressServer=10,
resourceLocationServer=11,
hostName=12,
bootFileSize=13,
meritDumpFile=14,
domainName=15,
swapServer=16,
rootPath=17,
extentionsPath=18,
IPforwarding=19,
nonLocalSourceRouting=20,
policyFilter=21,
maxDgramReasmSize=22,
defaultIPTTL=23,
pathMTUagingTimeout=24,
pathMTUplateauTable=25,
ifMTU=26,
allSubnetsLocal=27,
broadcastAddr=28,
performMaskDiscovery=29,
maskSupplier=30,
performRouterDiscovery=31,
routerSolicitationAddr=32,
staticRoute=33,
trailerEncapsulation=34,
arpCacheTimeout=35,
ethernetEncapsulation=36,
tcpDefaultTTL=37,
tcpKeepaliveInterval=38,
tcpKeepaliveGarbage=39,
nisDomainName=40,
nisServers=41,
ntpServers=42,
vendorSpecificInfo=43,
netBIOSnameServer=44,
netBIOSdgramDistServer=45,
netBIOSnodeType=46,
netBIOSscope=47,
xFontServer=48,
xDisplayManager=49,
dhcpRequestedIPaddr=50,
dhcpIPaddrLeaseTime=51,
dhcpOptionOverload=52,
dhcpMessageType=53,
dhcpServerIdentifier=54,
dhcpParamRequest=55,
dhcpMsg=56,
dhcpMaxMsgSize=57,
dhcpT1value=58,
dhcpT2value=59,
dhcpClassIdentifier=60,
dhcpClientIdentifier=61,
endOption = 255
}OPTION;
#define OPT_SIZE 312 //DHCP total size : 544
#define RIP_MSG_SIZE (240 + OPT_SIZE)
#define POS_OPTION (240)
typedef struct _RIP_MSG{
uint8 op; //Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY
uint8 htype; //Hardware address type (e.g., '1' = 10Mb Ethernet)
uint8 hlen; //Hardware address length (e.g. '6' for 10Mb Ethernet)
uint8 hops; //Client sets to zero, optionally used by relay agents when booting via a relay agent.
uint32 xid; //Transaction ID.
uint16 secs; //Seconds passed since client began the request process
uint16 flags;
uint8 ciaddr[4]; //Client IP address
uint8 yiaddr[4]; //Your(Client) IP address
uint8 siaddr[4]; //Server IP address
uint8 giaddr[4]; //Relay agent IP address
uint8 chaddr[16]; // Client hardware address
uint8 sname[64]; //Optional server host name
uint8 file[128]; //Boot file name
uint8 OPT[OPT_SIZE]; //Optional parameters
}RIP_MSG;
// DEFINE DHCP MACGIC COOKIE
#define MAGIC0 0x63
#define MAGIC1 0x82
#define MAGIC2 0x53
#define MAGIC3 0x63
void send_DHCP_DISCOVER(SOCKET s);
char parseDHCPMSG(SOCKET s,uint16 length);
char DHCP_SetIP();
void check_dhcp(void);
void send_DHCP_REQUEST(SOCKET s, uint8 REREQ);
void set_network(void);
#define MAX_BUF_SIZE 0x2000 // Max Receive buffer size : 8192
#define MAX_SBUF_SIZE 0x2000 // Max Serial Buffer size : 8192
#define SOCK_DHCP 0
#define TIMER0_COUNT 0xE35B // 1ms W7100
#define predTL0 (TIMER0_COUNT & 0xff)
#define predTH0 (TIMER0_COUNT >> 8)
void Init_Net_Default(void);
void Init_Net(void);
void Init_Timer0(void);
#endif
-
- На первый взгляд похоже... Commview хорошо разбирает пакеты, с шарком не работал. Подзабыл уже, но с QNAPом я напоролся и стал принимать и анализировать UDP с 66(67?) порта с любым IP назначения на этапе DHCP. Винда кладет на этот бит и шлет Andreas(108 знак., 15.10.2014 09:23)
- Что за QNAP? - Звероящер(15.10.2014 10:20)
- вместо сервака у нас стоит, очень своеобразная штука... - Andreas(15.10.2014 10:54, ссылка)
- Что за QNAP? - Звероящер(15.10.2014 10:20)
- На первый взгляд похоже... Commview хорошо разбирает пакеты, с шарком не работал. Подзабыл уже, но с QNAPом я напоролся и стал принимать и анализировать UDP с 66(67?) порта с любым IP назначения на этапе DHCP. Винда кладет на этот бит и шлет Andreas(108 знак., 15.10.2014 09:23)