Linux API/network2009. 7. 30. 15:48
랜선을 뽑고 꼽으면 아래와 같은 메시지가 출력된다.

eth0 : link down
eth0 : link up

dmesg로 매번 감시할수도 없는 노릇이고 그래서 코드로 하는 법을 찾아 왔는데
아직까지는 컴파일도 못시켜 봤다..(써글넘의 타입)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <net/if.h>
#include <netinet/in.h>
#include <ctype.h>

typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;

#include <linux/sockios.h>
#include <linux/ethtool.h>

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
// Get the link status. This returns TRUE if the link is up and FALSE
// otherwise.
//
int32_t link_stat()
{
        int s;
        struct ifreq ifr;
        struct ethtool_value eth;

        if((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) == FAIL)
                ERRORS(Socket);

        bzero(&ifr, sizeof(ifr));
        strcpy(ifr.ifr_name, Eth0);
        ifr.ifr_data = (caddr_t) &eth;
        eth.cmd = ETHTOOL_GLINK;

        if(ioctl(s, SIOCETHTOOL, &ifr) == FAIL)
                ERRORS(Ioctl);
        (void)close(s);

        return (eth.data) ? TRUE:FALSE;
}

void main()
{
        int ret;
        ret = link_stat();

        if(ret == TRUE) printf("link up\n");
        else printF("link down\n");
}

[링크 : http://lkml.indiana.edu/hypermail/linux/kernel/0505.2/0754.html]

'Linux API > network' 카테고리의 다른 글

struct in_addr  (0) 2009.08.18
ifup/ifdown  (0) 2009.08.18
리눅스 소켓 프로그래밍 - linux socket programming  (0) 2009.07.17
fstat - 파일의 상태 얻어오기  (2) 2009.07.02
Linux File Descriptor / File pointer  (0) 2009.06.30
Posted by 구차니
프로그램 사용/busybox2009. 7. 30. 13:16
menu 'Build Options'

config CONFIG_STATIC
    bool "Build BusyBox as a static binary (no shared libs)"
    default n
    help
      If you want to build a static BusyBox binary, which does not
      use or require any shared libraries, then enable this option.
      This can cause BusyBox to be considerably larger, so you should
      leave this option false unless you have a good reason (i.e.
      your target platform does not support shared libraries, or
      you are building an initrd which doesn't need anything but
      BusyBox, etc).

      Most people will leave this set to 'N'.

[링크 : http://stablebox.googlecode.com/svn/trunk/Config.in]

비지박스를 컴파일 하면, 용량이 생각보다 크다.
이 경우에는 위의 옵션을 꺼주면 컴팩트해진다.

1.10.4 기준으로 1.6M에서 600K 정도로 용량이 줄어드는데,
확신할 수는 없지만, 이 옵션을 사용했기 때문에 DNS resolv를 하지 못하는 것 같다.
busybox에서 ping이나 telnet 이 resolv 실패가 뜨면

libresolv.so
libdns.so

를 복사 해주면 되는데, 이 옵션의 영향이 아닐까 생각이된다.
Posted by 구차니
분류가 모호한 글2009. 7. 30. 11:20
An archive of files created with the Unix tar utility. Source-code distributions have been packaged as tarballs since the mid 1980s, even though the term's usage did not become commonplace until the late 1990s.
[링크 : http://www.webopedia.com/TERM/T/tarball.html]

...
The term suggests a ball of tar, the sticky coal derivative used as an adherent and sealant in roofing and other construction work
...
[링크 : http://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci821048,00.html]



tarball 이 어떤 의미인가 궁금해서 찾아보게 되었는데
말 그대로 tar가 굳어 생긴 공 같이 소스코드들의 뭉치, 덩어리를 의미한다.

'분류가 모호한 글' 카테고리의 다른 글

URI URL URN UNC  (0) 2009.10.27
memcpy 속도 향상에 대한 어셈블리 넘사벽...  (2) 2009.09.07
cal / J(줄) 환산  (0) 2009.05.28
개발의 어려움  (4) 2009.05.13
탈리도마증후근과 돼지독감  (0) 2009.04.29
Posted by 구차니
하드웨어2009. 7. 30. 11:04
Intel® Virtualization TechnologyΔ for Directed I/O (VT-d)
[링크 : http://www.intel.com/technology/itj/2006/v10i3/2-io/1-abstract.htm]


AMD 가상화 (AMD-V)
64비트 x86 아키텍처에 대한 AMD의 가상화 확장은 AMD 가상화라고 하며, 이를 줄여서 AMD-V라고 부른다.
AMD-V는 소켓 AM2 (소켓 939 아님)에 "F"나 "G" 계열인 애슬론 64, 애슬론 64 X2에, 또 튜리온 64 X2, 옵테론 2세대, 3세대, 페넘 이후의 프로세서에 존재한다. AMD는 입출력 메모리 관리 장치(IOMMU) 기술 규격을 AMD-V에 추가하였다.

인텔 가상화 기술 (인텔 VT)
인텔 가상화 기술, 곧 인텔 VT는 가상화를 위한 인텔의 기술 집합이다. 2003년에 인텔 개발자 포럼에 처음 선보였으며 2005년에 출시되었다. 인텔 VT는 IA-32 (VT-x)를 위한 가상화 기술, IA-64 (VT-i)를 위한 가상화 기술, Directed I/O (VT-d)를 위한 가상화 기술, Connectivity (VT-c)를 위한 가상화 기술로 이루어져 있다.
[링크 : http://ko.wikipedia.org/wiki/X86_%EA%B0%80%EC%83%81%ED%99%94]

'하드웨어' 카테고리의 다른 글

프레스캇!  (10) 2009.08.07
LGA775/Socket478  (4) 2009.08.04
multicast MAC Address  (2) 2009.07.02
MAC 어드레스는 48비트 앞은 OUI 뒤는?  (0) 2009.06.24
CMOS IMAGE SENSOR - OV6620  (0) 2009.06.14
Posted by 구차니
개소리 왈왈2009. 7. 30. 10:39
근데.. 막상 써보지도 않고 봉인.. OTL

AVR USB ISP니까..
케이스도 이쁘게 하나 만들어 볼까나.. (포스트 잇으로 대충 -ㅁ-)
그러고 보니 USB니까 노트북에서도 되겠구나~




라고 올해에는 꼭 서보 컨트롤을 해보도록 해야겠따고 결심하는 구차니군이었다
(하지만 그 결심은 이미 3년째 ㅠ.ㅠ)
Posted by 구차니
프로그램 사용/busybox2009. 7. 29. 15:13
$ ls /bin/udhcpc*
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpc -> busybox
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpd -> busybox

요즘 busybox는 udhcp 라는 dhcp 서버/클라이언트가 내장되어있다.
물론 기본값으로 busybox에 포함되긴 하지만, 확인 후 사용해야 한다.

아무튼, 옵션은 설정되어 있었음에도 불구하고
심볼릭 링크와, 스크립트가 생성되어 있지 않았다.


/sbin/udhcpc - udhcp Client
/sbin/udhcpd - udhcp Daemon
/usr/share/udhcpc/default.script - 기본 dhcp 스크립트




Posted by 구차니
sftp는 ssh를 이용한 ftp이다.
별다르게 설정하지 않았다면, 기본값으로 ssh를 통해 sftp로 전송이 가능하다.

SYNOPSIS
     sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
          [-o ssh_option] [-P sftp_server_path] [-R num_requests] [-S program]
          [-s subsystem | sftp_server] host
     sftp [[user@]host[:file [file]]]
     sftp [[user@]host[:dir[/]]]
     sftp -b batchfile [user@]host

사용방법은 위와 같은데 간단하게 예를 들자면,

# sftp root@192.168.10.10:/home.tar home.tar
Connecting to 192.168.10.10...
root@192.168.10.10's password:
Fetching /home.tar to home.tar
/home.tar                                       8% 1811MB   6.3MB/s   49:58 ETA

처럼 사용하면 된다. 머랄까.. 저 형식은 cvs나 svn 포맷같기도 하고..
Posted by 구차니
개소리 왈왈/자전거2009. 7. 28. 09:37
음.. 어제는 자전거 수리했는데
오늘오니 바람이 빠져 있었다.

헉? 이런 꼬꼬마들이 또 빼간겨?!? 라고 광분하면서 집에 들어 갔더니
울 누나왈
"니방 천장불 나갔어 언넝 고쳐"

뭥미?

일단은 자전거타고 가려고
혹시나 하는 마음에 펌프로 바람을 넣었더니 바람이 들어간다.

뭥미?


일단은 여름이고 더우니 이발을 하러갔고
이발을 하고나서, 자전거를 보니 바람이 피시시시시시식....


뭥미?


그래서 후다닥 자전거 수리점에 바람 조금 넣고 후딱 가서 튜브 교체
이래저래 돈이구나 ㅠ.ㅠ 후우...


결론 : 불행은 혼자 오지 않듯이, 돈쓸일도 혼자오지 않는다?!

'개소리 왈왈 > 자전거' 카테고리의 다른 글

눈길에 자전거 + 도서관  (2) 2010.01.09
한강공원 - 자전거 가격과 경험의 권력화?  (2) 2009.10.19
아놔 이런 십슬레이션!  (6) 2009.07.26
41.65km  (4) 2009.07.07
자전거 타고 회사왕복하기  (0) 2009.06.25
Posted by 구차니
아이디어!2009. 7. 27. 16:59
문득 수다를 떨다가 나온 내용인데

이질적인 그림체의 게임을 하나로 섞어서
상대방의 주도권에 따라서 그래픽이 변경되면 어떨까?


예를 들어서 사실체 + SD 그래픽 + 만화체 + 단순체 4가지 조합이 있고
주도하는 사람에 따라서 주변 그래픽이 그 분위기를 따라간다

음.. 전투시에 SD 만화체를 택한 캐릭터가 주도를 한다면
던전 그래픽 도 SD 만화체로 바뀌고, 전투역시 SD 만화체로 하게 되고

뒤에서 싸우던 동료가 만화체인데 (순정만화) 이 사람이 갑자기 주도권을 얻게 되면
주변 그래픽은 꽃이 샤방하고 오스칼!! 외치며 펜싱검으로 휘두르며(응?)
장비 던전으로 바뀌면 어떨까라는 망상을 ...




아니 이건 3D개발자에게 칼 맞을꺼야 -ㅁ-

Posted by 구차니
Programming/C Win32 MFC2009. 7. 27. 15:46
NAME
       strtol, strtoll, strtoq - convert a string to a long integer

SYNOPSIS
       #include <stdlib.h>

       long int
       strtol(const char *nptr, char **endptr, int base);

       long long int
       strtoll(const char *nptr, char **endptr, int base);

DESCRIPTION
       The  strtol()  function  converts the initial part of the string in nptr to a long integer value according to the
       given base, which must be between 2 and 36 inclusive, or be the special value 0.

       The string may begin with an arbitrary amount of white space (as determined by isspace(3)) followed by  a  single
       optional  ‘+’ or ‘-’ sign.  If base is zero or 16, the string may then include a ‘0x’ prefix, and the number will
       be read in base 16; otherwise, a zero base is taken as 10 (decimal) unless the next character is  ‘0’,  in  which
       case it is taken as 8 (octal).

       The remainder of the string is converted to a long int value in the obvious manner, stopping at the first charac-
       ter which is not a valid digit in the given base.  (In bases above 10, the letter ‘A’ in either  upper  or  lower
       case represents 10, ‘B’ represents 11, and so forth, with ‘Z’ representing 35.)

       If  endptr  is not NULL, strtol() stores the address of the first invalid character in *endptr.  If there were no
       digits at all, strtol() stores the original value of nptr in *endptr (and returns 0).  In particular, if *nptr is
       not ‘\0’ but **endptr is ‘\0’ on return, the entire string is valid.

       The strtoll() function works just like the strtol() function but returns a long long integer value.

RETURN VALUE
       The  strtol() function returns the result of the conversion, unless the value would underflow or overflow.  If an
       underflow occurs, strtol() returns LONG_MIN.  If an overflow occurs, strtol() returns LONG_MAX.  In  both  cases,
       errno is set to ERANGE.  Precisely the same holds for strtoll() (with LLONG_MIN and LLONG_MAX instead of LONG_MIN
       and LONG_MAX).

EXAMPLE
       The  program  shown  below  demonstrates the use of strtol().  The first command line argument specifies a string
       from which strtol() should parse a number.  The second (optional) argument specifies the base to be used for  the
       conversion.   (This argument is converted to numeric form using atoi(3), a function that performs no error check-
       ing and has a simpler interface than strtol().)  Some examples of the results produced by this  program  are  the
       following:

         $ ./a.out 123
         strtol() returned 123
         $ ./a.out ’    123’
         strtol() returned 123
         $ ./a.out 123abc
         strtol() returned 123
         Further characters after number: abc
         $ ./a.out 123abc 55
         strtol: Invalid argument
         $ ./a.out ’’
         No digits were found
         $ ./a.out 4000000000
         strtol: Numerical result out of range


#include "stdlib.h"
#include "limits.h"
#include "stdio.h"
#include "errno.h"

int main(int argc, char *argv[]) { int base; char *endptr, *str; long val;
if (argc < 2) { fprintf(stderr, "Usage: %s str [base]\n", argv[0]); exit(EXIT_FAILURE); }
str = argv[1]; base = (argc > 2) ? atoi(argv[2]) : 10;
errno = 0; /* To distinguish success/failure after call */ val = strtol(str, &endptr, base);
/* Check for various possible errors */
if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) || (errno != 0 && val == 0)) { perror("strtol"); exit(EXIT_FAILURE); }
if (endptr == str) { fprintf(stderr, "No digits were found\n"); exit(EXIT_FAILURE); }
/* If we got here, strtol() successfully parsed a number */
printf("strtol() returned %ld\n", val);
if (*endptr != ’\0’) /* Not necessarily an error... */ printf("Further characters after number: %s\n", endptr);

exit(EXIT_SUCCESS); }



atoi 보다 막강한 함수라고 한다.

[링크 : http://en.wikipedia.org/wiki/Strtol]
[링크 : http://linux.die.net/man/3/strtol]
Posted by 구차니