Rev 1882 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1882 | Rev 4248 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
Line -... | Line 2... | ||
- | 2 | ||
- | 3 | ||
- | 4 | unsigned long inet_addr(char *cp) |
|
- | 5 | { |
|
- | 6 | // Adapted from here http://stackoverflow.com/a/1684635 |
|
- | 7 | unsigned long __ret; |
|
- | 8 | unsigned int c1,c2,c3,c4; |
|
- | 9 | sscanf(cp, "%d.%d.%d.%d", &c1,&c2,&c3,&c4); |
|
- | 10 | __ret = (unsigned long)c4+c3*256+c2*256*256+c1*256*256*256; |
|
- | 11 | return htonl(__ret); |
|
- | 12 | } |
|
- | 13 | ||
- | 14 | int socket(int domain, int type, int protocol) |
|
- | 15 | { |
|
- | 16 | int __ret; |
|
- | 17 | __asm__("int $0x40":"=a"(__ret):"a"(_SOCKETF),"b"(_OPENSF),"c"(domain),"d"(type),"S"(protocol)); |
|
- | 18 | return __ret; |
|
- | 19 | } |
|
- | 20 | ||
- | 21 | int close_socket(int s) |
|
- | 22 | { |
|
- | 23 | int __ret; |
|
- | 24 | __asm__("int $0x40":"=a"(__ret):"a"(_SOCKETF),"b"(_CLOSESF),"c"(s)); |
|
- | 25 | return __ret; |
|
- | 26 | } |
|
- | 27 | ||
- | 28 | ||
- | 29 | int connect(int sockfd, const struct sockaddr *serv_addr, int addrlen) |
|
- | 30 | { |
|
- | 31 | int __ret; |
|
- | 32 | __asm__("int $0x40":"=a"(__ret):"a"(_SOCKETF),"b"(_CONNECTSF),"c"(sockfd),"d"(serv_addr),"S"(addrlen)); |
|
- | 33 | return __ret; |
|
- | 34 | } |
|
- | 35 | ||
- | 36 | int send(int s, const void *buf, int len, int flags) |
|
- | 37 | { |
|
- | 38 | int __ret; |
|
- | 39 | __asm__("int $0x40":"=a"(__ret):"a"(_SOCKETF),"b"(_SENDSF),"c"(s),"d"(buf),"S"(len),"D"(flags)); |
|
- | 40 | return __ret; |
|
- | 41 | } |
|
- | 42 | ||
- | 43 | int recv(int sockfd, void *buf, int len, int flags) |
|
- | 44 | { |
|
- | 45 | int __ret; |
|
- | 46 | __asm__("int $0x40":"=a"(__ret):"a"(_SOCKETF),"b"(_RECEIVESF),"c"(sockfd),"d"(buf),"S"(len),"D"(flags)); |
|
- | 47 | return __ret; |
|
- | 48 | } |
|
- | 49 | ||
- | 50 | ||
- | 51 | ||
- | 52 | // -------------------------------------------------------------- |
|
2 | 53 | ||
3 | __u32 __menuet__open_UDP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip) |
54 | __u32 __menuet__open_UDP_socket(__u32 local_port,__u32 remote_port,__u32 remote_ip) |
4 | { |
55 | { |
5 | __u32 __ret; |
56 | __u32 __ret; |
6 | __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_open_UDP), |
57 | __asm__("int $0x40":"=a"(__ret):"a"(__NET_socket),"b"(__NET_sock_open_UDP), |