Создать ответ 
 
Рейтинг темы:
  • Голосов: 0 - Средняя оценка: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Modem using post to an API!
Автор Сообщение
megavolt85 Не на форуме
Супермодератор
******

Сообщений: 3149
Зарегистрирован: 24.03.2012
Рейтинг: 38
Сказал спасибо: 184
Поблагодарили 1556 раз(а) в 915 сообщ.
Сообщение: #3
RE: Modem using post to an API!
Код:
#include <stdio.h>
#include <kos/dbglog.h>

#include <arch/arch.h>

#include <ppp/ppp.h>
#include <kos/net.h>

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);

int main(int argc, char *argv[])
{
    int i,conn_rate = 0;
    
    ppp_init();
    
    i = ppp_modem_init("11111", 0, &conn_rate);
    
    if(i < 0)
        return 0;
    
    ppp_set_login("dream", "dreamcast");
    i = ppp_connect();
    
    if(i < 0)
    {
        printf("Link establishment failed!\n");
        return 0;
    }
    
    printf("Link established, rate is %d bps\n", conn_rate);
    
    printf("Pinging the other side of the link (%d.%d.%d.%d)\n",
    net_default_dev->gateway[0], net_default_dev->gateway[1],
    net_default_dev->gateway[2], net_default_dev->gateway[3]);

    for(i = 0; i < 10; ++i)
    {
        net_icmp_send_echo(net_default_dev, net_default_dev->gateway, 1234, i, NULL, 0);
        thd_sleep(500);
    }

    printf("Pinging sylverant.net (138.197.20.130)\n");
    
    for(i = 0; i < 10; ++i)
    {
        uint8 addr[4] = { 138, 197, 20, 130 };
        net_icmp_send_echo(net_default_dev, addr, 1234, i, NULL, 0);
        thd_sleep(500);
    }

    ppp_shutdown();
    
    return 0;
}

Код:
--
KallistiOS ##version##:
  Пн дек 14 04:23:24 MSK 2020
  megavolt@megavolt85:/home/megavolt/dreamcast/kos
maple: active drivers:
    Dreameye (Camera): Camera
    Sound Input Peripheral: Microphone
    PuruPuru (Vibration) Pack: JumpPack
    VMU Driver: Clock, LCD, MemoryCard
    Mouse Driver: Mouse
    Keyboard Driver: Keyboard
    Controller Driver: Controller
    Lightgun: LightGun
  DMA Buffer at ac0ad800
vid_set_mode: 640x480 VGA
dc-load console support enabled
maple: attached devices:
  A0: Dreamcast Controller          (01000000: Controller)
  A1: Visual Memory                 (0e000000: Clock, LCD, MemoryCard)
lan_adapter: no device detected (wrong type = 0)
net_dev_init: detected 0 usable network device(s)
ppp_modem: connected at 33600 bps
ppp: entering phase Establish
lcp: Peer configure request received with opts:
    peer accm: 00000000
    peer magic: 6126407b
    protocol compression on
    addr/ctrl compression on
lcp: received configure ack
ppp: entering phase Network
ipcp: Peer configure request received with opts:
    unknown option: 2 (len 6)
    peer IP: 192.168.1.99
ipcp: peer sent configure nak with opts:
    our IP: 192.168.1.98
    DNS 1: 192.168.1.99
ipcp: Peer configure request received with opts:
    peer IP: 192.168.1.99
ppp: dropping packet with bad final fcs, got: 9b0b
ppp: was for proto 8021
ppp: was 20 bytes long
ipcp: Peer configure request received with opts:
    unknown option: 2 (len 6)
    peer IP: 192.168.1.99
ipcp: received configure ack
ipcp: Peer configure request received with opts:
    peer IP: 192.168.1.99
ppp: entering phase Network
Link established, rate is 33600 bps
Pinging the other side of the link (192.168.1.99)
16 bytes from 192.168.1.99: icmp_seq=0 ttl=64 time=88.415 ms
16 bytes from 192.168.1.99: icmp_seq=1 ttl=64 time=87.220 ms
16 bytes from 192.168.1.99: icmp_seq=2 ttl=64 time=89.613 ms
16 bytes from 192.168.1.99: icmp_seq=3 ttl=64 time=89.520 ms
16 bytes from 192.168.1.99: icmp_seq=4 ttl=64 time=88.099 ms
16 bytes from 192.168.1.99: icmp_seq=5 ttl=64 time=87.663 ms
16 bytes from 192.168.1.99: icmp_seq=6 ttl=64 time=86.339 ms
16 bytes from 192.168.1.99: icmp_seq=7 ttl=64 time=89.626 ms
16 bytes from 192.168.1.99: icmp_seq=8 ttl=64 time=88.878 ms
16 bytes from 192.168.1.99: icmp_seq=9 ttl=64 time=87.884 ms
Pinging sylverant.net (138.197.20.130)
16 bytes from 138.197.20.130: icmp_seq=0 ttl=52 time=230.623 ms
16 bytes from 138.197.20.130: icmp_seq=1 ttl=52 time=224.942 ms
16 bytes from 138.197.20.130: icmp_seq=2 ttl=52 time=222.708 ms
16 bytes from 138.197.20.130: icmp_seq=3 ttl=52 time=228.495 ms
16 bytes from 138.197.20.130: icmp_seq=4 ttl=52 time=224.635 ms
16 bytes from 138.197.20.130: icmp_seq=5 ttl=52 time=230.281 ms
16 bytes from 138.197.20.130: icmp_seq=6 ttl=52 time=240.357 ms
16 bytes from 138.197.20.130: icmp_seq=7 ttl=52 time=226.467 ms
16 bytes from 138.197.20.130: icmp_seq=8 ttl=52 time=219.864 ms
16 bytes from 138.197.20.130: icmp_seq=9 ttl=52 time=226.144 ms
arch: shutting down kernel
net_unreg_device: 'bba' isn't registered
maple: final stats -- device count = 2, vbl_cntr = 3208, dma_cntr = 3191
vid_set_mode: 640x480 VGA

use DNS for ping

Код:
#include <stdio.h>
#include <string.h>

#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#include <kos/net.h>
#include <kos/dbgio.h>
#include <arch/arch.h>
#include <ppp/ppp.h>

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);

int main(int argc, char *argv[])
{
    int i,conn_rate = 0;
    struct addrinfo *ai;
    struct addrinfo hints;
    int err;
    
    
    ppp_init();
    
    i = ppp_modem_init("11111", 0, &conn_rate);
    
    if(i < 0)
        return 0;
    
    ppp_set_login("dream", "dreamcast");
    i = ppp_connect();
    
    if(i < 0)
    {
        printf("Link establishment failed!\n");
        return 0;
    }
    
    printf("Link established, rate is %d bps\n", conn_rate);
    
    printf("Looking up IPv4 address of sylverant.net\n");
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;

    if((err = getaddrinfo("sylverant.net", NULL, &hints, &ai))) {
        printf("Error looking up IPv4 address information: %d\n", err);
        ppp_shutdown();
    
        return 0;
    }
    
    printf("Ping sylverant.net\n");
    
    uint8_t addr[4];
    
    for (i = 0; i < 4; i++)
    {
        addr[i] = ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr >> (i*8);
    }
    
    for(i = 0; i < 10; ++i)
    {
        net_icmp_send_echo(net_default_dev, addr, 1234, i, NULL, 0);
        thd_sleep(500);
    }
    
    freeaddrinfo(ai);
    ppp_shutdown();
    
    return 0;
}

HKT-3030, Bios mod, SD mod, VGA internal mod, G1ATA mod, Region changer mod, PSU mod
(Последний раз сообщение было отредактировано 03.03.2021 в 15:59, отредактировал пользователь megavolt85.)
03.03.2021 14:58
Найти все сообщения Цитировать это сообщение
 Сказали спасибо: NeoSnk
Создать ответ 


Сообщения в этой теме
Modem using post to an API! - NeoSnk - 02.03.2021, 23:02
RE: Modem using post to an API! - megavolt85 - 03.03.2021 14:58

Похожие темы
Тема: Автор Ответов: Просмотров: Посл. сообщение
  USB Modem Voltage Inducer for Dreamcast aldair 0 6277 08.01.2020 19:12
Посл. сообщение: aldair
  My very first post. Turbokat 2 11146 29.04.2017 14:09
Посл. сообщение: Turbokat
  My first forum post tossEAC 4 18395 03.04.2017 00:33
Посл. сообщение: tossEAC
  Dreamcast DC-PC (FAX MODEM USB): 4X4 Evolution online 100% aldair 0 7921 27.08.2015 20:04
Посл. сообщение: aldair
  Moband Adapter ( Dreamcast modem broadband replacement band ) aldair 1 14692 24.05.2014 21:21
Посл. сообщение: cybdyn
  Connecting to the Internet via USB Modem Dreamcast in emulating win98 win7 aldair 0 7541 16.10.2013 16:55
Посл. сообщение: aldair

Переход:


Пользователи просматривают эту тему: 7 Гость(ей)