コード例 #1
0
ファイル: arp.c プロジェクト: gnarlie/bad-os-64
void arp_packet(struct netdevice* dev, const uint8_t * data) {
    struct arp_packet * arp = (struct arp_packet*) data;

    if (ntol(arp->targetIp) != dev-> ip) return;

    int request = ntos(arp->operation) == 1;
    if (request) {
        // store(arp->senderMac, ntol(arp->senderIp));
        reply(dev, arp->senderMac, ntol(arp->senderIp), 0);
    }
    else {
        arp_store(arp->senderMac, ntol(arp->senderIp));
    }
}
コード例 #2
0
ファイル: arp.c プロジェクト: gnarlie/bad-os-64
static void arp_request(struct netdevice * device, uint32_t targetIp) {
    sbuff * buf = ethernet_sbuff_alloc(sizeof(struct arp_packet));
    add_ref(buf);

    struct arp_packet * arp = (struct arp_packet*)buf->head;
    arp->htype = ntos(1);
    arp->ptype = ntos(0x0800);
    arp->hlen = 6;
    arp->plen = 4;
    arp->operation = ntos(1);
    memcpy(arp->senderMac, device->mac, 6);
    arp->senderIp = ntol(device->ip);
    bzero(arp->targetMac, 6);
    arp->targetIp = ntol(targetIp);

    ethernet_send(buf, 0x0806, BROADCAST_MAC, device);
    release_ref(buf, sbuff_free);
}
コード例 #3
0
ファイル: arp.c プロジェクト: gnarlie/bad-os-64
static void reply(struct netdevice* dev, mac target, uint32_t ip, int broadcast) {
    sbuff * buf = raw_sbuff_alloc(sizeof(struct ethernet_frame) + sizeof(struct arp_packet));
    add_ref(buf);
    sbuff_push(buf, sizeof(struct ethernet_frame));

    struct arp_packet * arp = (struct arp_packet*)buf->head;
    arp->htype = ntos(1);
    arp->ptype = ntos(0x0800);
    arp->hlen = 6;
    arp->plen = 4;
    arp->operation = ntos(2);
    memcpy(arp->senderMac, dev->mac, 6);
    arp->senderIp = ntol(dev->ip);
    memcpy(arp->targetMac, target, 6);
    arp->targetIp = ntol(ip);

    ethernet_send(buf, 0x0806, broadcast ? BROADCAST_MAC : target, dev);
    release_ref(buf, sbuff_free);
}
コード例 #4
0
long OMAxis::getHomeDistance() {
    int res = command(m_slaveAddr, OM_PCODE_PC, CMD_PC_STATUS_REQ, OM_STAT_HOMEDIST);
    
    long ret = 0;
    
    if( res && responseType() != -1 && responseLen() > 3 ) {
        uint8_t* data = (uint8_t*) responseData();
        ret = ntol(data);
    }
    
    return ret;      
}